File size: 1,390 Bytes
5ce154b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import tensorflow as tf
tf.__version__
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from tensorflow.keras.applications import vgg16
#from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, Dropout, Input, Dense, Flatten
from tensorflow.keras.utils import load_img, img_to_array
from sklearn.metrics import confusion_matrix
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from tensorflow.keras.applications import vgg16
#from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, Dropout, Input, Dense, Flatten
from tensorflow.keras.utils import load_img, img_to_array
from sklearn.metrics import confusion_matrix


model = tf.keras.models.load_model('my_model.keras')


import gradio as gr
import numpy as np
from PIL import Image

def sepia(input_img_path):
    img = load_img(input_img_path,target_size=(224,224))
    img = img_to_array(img)
    img = img / 255
    img = img.reshape(1,224,224,3)
    p = (model.predict(img)>=0.5).astype(int)[0][0]
    if p==0:
        return "Men"
    else:
        return "women"

demo = gr.Interface(fn=sepia,inputs= gr.Image(type="filepath",height=200,width=300),outputs="text")
demo.launch()