Spaces:
Sleeping
Sleeping
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() |