arsath-sm commited on
Commit
71e8e9b
1 Parent(s): 8b1b73a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,16 +1,21 @@
1
  import gradio as gr
2
  import tensorflow as tf
3
- from tensorflow.keras.models import load_model
4
  from tensorflow.keras.preprocessing import image
5
  import numpy as np
6
- from huggingface_hub import from_pretrained_keras
 
 
 
 
 
7
 
8
  # Load the models
9
- model1 = tf.keras.layers.TFSMLayer("arsath-sm/face_classification_model1", call_endpoint='serving_default')
10
- model2 = tf.keras.layers.TFSMLayer("arsath-sm/face_classification_model2", call_endpoint='serving_default')
11
 
12
  # Preprocess the image
13
  def preprocess_image(img):
 
14
  img = image.img_to_array(img)
15
  img = np.expand_dims(img, axis=0)
16
  img = img / 255.0
 
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 hf_hub_download
6
+ import os
7
+
8
+ # Download the models
9
+ model1_path = hf_hub_download(repo_id="arsath-sm/face_classification_model1", filename="model.h5")
10
+ model2_path = hf_hub_download(repo_id="arsath-sm/face_classification_model2", filename="model.h5")
11
 
12
  # Load the models
13
+ model1 = tf.keras.models.load_model(model1_path)
14
+ model2 = tf.keras.models.load_model(model2_path)
15
 
16
  # Preprocess the image
17
  def preprocess_image(img):
18
+ img = img.resize((224, 224)) # Adjust size as needed
19
  img = image.img_to_array(img)
20
  img = np.expand_dims(img, axis=0)
21
  img = img / 255.0