Spaces:
Sleeping
Sleeping
shaheer-data
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,38 +1,26 @@
|
|
1 |
import streamlit as st
|
2 |
import tensorflow as tf
|
|
|
3 |
from PIL import Image
|
4 |
import os
|
5 |
-
from huggingface_hub import
|
|
|
6 |
|
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 |
-
|
|
|
|
|
|
|
27 |
|
28 |
-
# Model repository details
|
29 |
-
model_repo_id = "shaheer-data/Yellow-Rust-Prediction"
|
30 |
-
model_file_path = "final_meta_model.keras"
|
31 |
|
32 |
# Construct the model URL
|
33 |
st.write("Loading model from Hugging Face repo:", model_repo_id)
|
34 |
-
|
35 |
-
loaded_model =
|
36 |
|
37 |
# Function to make predictions
|
38 |
def predict_image(image):
|
|
|
1 |
import streamlit as st
|
2 |
import tensorflow as tf
|
3 |
+
from tf.keras.models import load_model
|
4 |
from PIL import Image
|
5 |
import os
|
6 |
+
from huggingface_hub import notebook_login
|
7 |
+
from huggingface_hub import hf_hub_download
|
8 |
|
9 |
# Title of the Streamlit app
|
10 |
st.title("Yellow Rust Severity Prediction")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
# Downloading Model from hugging face url
|
15 |
+
st.write("Downloading model from Hugging Face repo:", model_repo_id)
|
16 |
+
# Download the model file from Hugging Face
|
17 |
+
model_path = hf_hub_download(repo_id="shaheer-data/Yellow-Rust-Prediction", filename="final_meta_model.keras")
|
18 |
|
|
|
|
|
|
|
19 |
|
20 |
# Construct the model URL
|
21 |
st.write("Loading model from Hugging Face repo:", model_repo_id)
|
22 |
+
|
23 |
+
loaded_model = load_model(model_path) # Load model using tf.keras directly
|
24 |
|
25 |
# Function to make predictions
|
26 |
def predict_image(image):
|