Om Prakash Singh commited on
Commit
3ab8725
1 Parent(s): 81224f9

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +26 -0
  2. gender_classifier_model.h5 +3 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tensorflow.keras.models import load_model
2
+ import tensorflow as tf
3
+ import gradio as gr
4
+ import numpy as np
5
+
6
+ loaded_model = load_model("gender_classifier_model.h5")
7
+
8
+
9
+ def myfun(img):
10
+ # Gradio automatically converts the input image to a NumPy array
11
+ # Convert the image to the required input format for the model
12
+ img = tf.image.resize(img, (64, 64))
13
+ x = tf.keras.preprocessing.image.img_to_array(img)
14
+ x = np.expand_dims(x, axis=0)
15
+
16
+ # Use the loaded model for predictions
17
+ loaded_classes = loaded_model.predict(x, batch_size=1)
18
+ print(loaded_classes)
19
+ if loaded_classes[0] > 0.5:
20
+ return 'Is a Man'
21
+ else:
22
+ return 'Is A Woman'
23
+
24
+
25
+ iface = gr.Interface(fn=myfun, inputs=gr.Image(label='Drop an Image or Open Camera to Classify'), outputs=gr.Text())
26
+ iface.launch()
gender_classifier_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f38374af8edc29f67e0cb917d2df1fbc0635ccef1f2fe23006ca37502acbdcc
3
+ size 388168184