Spaces:
Sleeping
Sleeping
Jyantkumar
commited on
Commit
•
5ce154b
1
Parent(s):
0938d30
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tensorflow as tf
|
2 |
+
tf.__version__
|
3 |
+
import numpy as np
|
4 |
+
import pandas as pd
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
+
import seaborn as sns
|
7 |
+
from tensorflow.keras.applications import vgg16
|
8 |
+
#from keras.preprocessing.image import ImageDataGenerator
|
9 |
+
from keras.models import Sequential
|
10 |
+
from keras.layers import Conv2D, MaxPooling2D, Dropout, Input, Dense, Flatten
|
11 |
+
from tensorflow.keras.utils import load_img, img_to_array
|
12 |
+
from sklearn.metrics import confusion_matrix
|
13 |
+
import numpy as np
|
14 |
+
import pandas as pd
|
15 |
+
import matplotlib.pyplot as plt
|
16 |
+
import seaborn as sns
|
17 |
+
from tensorflow.keras.applications import vgg16
|
18 |
+
#from keras.preprocessing.image import ImageDataGenerator
|
19 |
+
from keras.models import Sequential
|
20 |
+
from keras.layers import Conv2D, MaxPooling2D, Dropout, Input, Dense, Flatten
|
21 |
+
from tensorflow.keras.utils import load_img, img_to_array
|
22 |
+
from sklearn.metrics import confusion_matrix
|
23 |
+
|
24 |
+
|
25 |
+
model = tf.keras.models.load_model('my_model.keras')
|
26 |
+
|
27 |
+
|
28 |
+
import gradio as gr
|
29 |
+
import numpy as np
|
30 |
+
from PIL import Image
|
31 |
+
|
32 |
+
def sepia(input_img_path):
|
33 |
+
img = load_img(input_img_path,target_size=(224,224))
|
34 |
+
img = img_to_array(img)
|
35 |
+
img = img / 255
|
36 |
+
img = img.reshape(1,224,224,3)
|
37 |
+
p = (model.predict(img)>=0.5).astype(int)[0][0]
|
38 |
+
if p==0:
|
39 |
+
return "Men"
|
40 |
+
else:
|
41 |
+
return "women"
|
42 |
+
|
43 |
+
demo = gr.Interface(fn=sepia,inputs= gr.Image(type="filepath",height=200,width=300),outputs="text")
|
44 |
+
demo.launch()
|