mramjad commited on
Commit
228bfb2
·
verified ·
1 Parent(s): b6356f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -1,11 +1,18 @@
1
  import gradio as gr
2
  import tensorflow as tf
3
- from tensorflow.keras.preprocessing import image
4
  import numpy as np
5
- from huggingface_hub import from_pretrained_keras
 
 
 
 
 
 
 
 
6
 
7
- # Load the trained model from Hugging Face Hub
8
- model = from_pretrained_keras("mramjad/cats_dogs_model")
9
  model.compile(optimizer="adam", loss="categorical_crossentropy")
10
 
11
  # Class labels
@@ -34,5 +41,5 @@ iface = gr.Interface(
34
  allow_flagging="never"
35
  )
36
 
37
- # 🚀 **Launch Fix (No `share=True`)**
38
- iface.launch(server_name="0.0.0.0", server_port=7860)
 
1
  import gradio as gr
2
  import tensorflow as tf
 
3
  import numpy as np
4
+ from tensorflow.keras.preprocessing import image
5
+ from huggingface_hub import hf_hub_download
6
+
7
+ # Define model repository and filename
8
+ MODEL_REPO = "mramjad/cats_dogs_model"
9
+ MODEL_FILENAME = "cats_dogs_model.h5"
10
+
11
+ # Download the model file
12
+ model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILENAME)
13
 
14
+ # Load the model (ensure it's in `.h5` format)
15
+ model = tf.keras.models.load_model(model_path)
16
  model.compile(optimizer="adam", loss="categorical_crossentropy")
17
 
18
  # Class labels
 
41
  allow_flagging="never"
42
  )
43
 
44
+ # Launch the Gradio app
45
+ iface.launch(server_name="0.0.0.0", server_port=7860)