Spaces:
Sleeping
Sleeping
shaheer-data
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,22 @@ from huggingface_hub import hf_hub_url, HfApi # Import Hugging Face utilities
|
|
7 |
# Title of the Streamlit app
|
8 |
st.title("Yellow Rust Severity Prediction")
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
-
if
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Set Hugging Face token for authentication
|
|
|
|
|
|
|
|
|
|
|
17 |
HfApi().set_access_token(huggingface_api_token)
|
18 |
|
19 |
# Model repository details
|
|
|
7 |
# Title of the Streamlit app
|
8 |
st.title("Yellow Rust Severity Prediction")
|
9 |
|
10 |
+
# Function to get Hugging Face API token securely
|
11 |
+
def get_huggingface_api_token():
|
12 |
+
if "HUGGINGFACE_API_TOKEN" not in st.session_state:
|
13 |
+
st.session_state.HUGGINGFACE_API_TOKEN = st.text_input(
|
14 |
+
"Enter your Hugging Face API Token",
|
15 |
+
type="password",
|
16 |
+
label_visibility="collapsed"
|
17 |
+
)
|
18 |
+
return st.session_state.HUGGINGFACE_API_TOKEN
|
19 |
|
20 |
# Set Hugging Face token for authentication
|
21 |
+
huggingface_api_token = get_huggingface_api_token()
|
22 |
+
if not huggingface_api_token:
|
23 |
+
st.warning("Please enter your Hugging Face API Token.")
|
24 |
+
st.stop()
|
25 |
+
|
26 |
HfApi().set_access_token(huggingface_api_token)
|
27 |
|
28 |
# Model repository details
|