syeda-Rija20 commited on
Commit
6e46d0b
·
verified ·
1 Parent(s): d04595c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
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
- 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
 
 
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