shaheer-data commited on
Commit
2b40245
·
verified ·
1 Parent(s): 1738230

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
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
- # Load Hugging Face API token from environment
11
- huggingface_api_token = os.getenv("HUGGINGFACE_TOKEN")
12
- if huggingface_api_token is None:
13
- st.error("YellowRust API token not found in environment. Please set it.")
14
- st.stop()
 
 
 
 
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