arsath-sm commited on
Commit
2b3c229
1 Parent(s): 33d54d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -1,17 +1,16 @@
1
  import gradio as gr
 
2
  import tensorflow as tf
3
- from PIL import Image
4
  import numpy as np
5
 
6
- # Load the models
7
- model1 = tf.keras.models.load_model('face_detection_model1.h5')
8
- model2 = tf.keras.models.load_model('face_detection_model2.h5')
9
 
10
  def preprocess_image(image):
11
- img = Image.fromarray(image.astype('uint8'), 'RGB')
12
- img = img.resize((150, 150))
13
- img_array = np.array(img) / 255.0
14
- return np.expand_dims(img_array, axis=0)
15
 
16
  def predict_image(image):
17
  preprocessed_image = preprocess_image(image)
 
1
  import gradio as gr
2
+ from huggingface_hub import from_pretrained_keras
3
  import tensorflow as tf
 
4
  import numpy as np
5
 
6
+ # Load models from Hugging Face Hub
7
+ model1 = from_pretrained_keras("arsath-sm/real-fake-face-detection-model1")
8
+ model2 = from_pretrained_keras("arsath-sm/real-fake-face-detection-model2")
9
 
10
  def preprocess_image(image):
11
+ img = tf.image.resize(image, (150, 150))
12
+ img = img / 255.0
13
+ return tf.expand_dims(img, 0)
 
14
 
15
  def predict_image(image):
16
  preprocessed_image = preprocess_image(image)