Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,18 +50,29 @@ def load_text_model():
|
|
| 50 |
# ---------------------------
|
| 51 |
# LOAD IMAGE MODEL (PyTorch only, no TensorFlow)
|
| 52 |
# ---------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
@st.cache_resource
|
| 54 |
def load_image_model():
|
| 55 |
-
import os
|
| 56 |
-
|
| 57 |
-
model_path = "image_model.h5"
|
| 58 |
-
|
| 59 |
-
if not os.path.exists(model_path):
|
| 60 |
-
url = "https://huggingface.co/syeda-Rija20/image-detector/resolve/main/image_detector_finetuned.h5"
|
| 61 |
-
response = requests.get(url)
|
| 62 |
-
with open(model_path, "wb") as f:
|
| 63 |
-
f.write(response.content)
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
model = tf.keras.models.load_model(model_path)
|
| 66 |
return model
|
| 67 |
|
|
|
|
| 50 |
# ---------------------------
|
| 51 |
# LOAD IMAGE MODEL (PyTorch only, no TensorFlow)
|
| 52 |
# ---------------------------
|
| 53 |
+
# @st.cache_resource
|
| 54 |
+
# def load_image_model():
|
| 55 |
+
# import os
|
| 56 |
+
# import tensorflow as tf
|
| 57 |
+
# model_path = "image_model.h5"
|
| 58 |
+
|
| 59 |
+
# if not os.path.exists(model_path):
|
| 60 |
+
# url = "https://huggingface.co/syeda-Rija20/image-detector/resolve/main/image_detector_finetuned.h5"
|
| 61 |
+
# response = requests.get(url)
|
| 62 |
+
# with open(model_path, "wb") as f:
|
| 63 |
+
# f.write(response.content)
|
| 64 |
+
|
| 65 |
+
# model = tf.keras.models.load_model(model_path)
|
| 66 |
+
# return model
|
| 67 |
@st.cache_resource
|
| 68 |
def load_image_model():
|
| 69 |
+
import os, tensorflow as tf
|
| 70 |
+
from huggingface_hub import hf_hub_download
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
model_path = hf_hub_download(
|
| 73 |
+
repo_id="Muniba930/image-detector",
|
| 74 |
+
filename="image_detector_v2.h5"
|
| 75 |
+
)
|
| 76 |
model = tf.keras.models.load_model(model_path)
|
| 77 |
return model
|
| 78 |
|