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 vgg16_model = vgg16.VGG16(include_top=False, input_shape=(224,224,3), weights='imagenet') vgg16_model.trainable = False model = Sequential() model.add(vgg16_model) model.add(Flatten()) model.add(Dense(4096, activation='relu')) model.add(Dense(4096, activation='relu')) model.add(Dropout(0.25)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['Accuracy']) model.load_weights("cp.ckpt") 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=700,width=600),outputs="text") demo.launch()