jatinbittu13's picture
Upload 4 files
5ab4572
raw
history blame
709 Bytes
from keras.models import model_from_json
import cv2
import numpy as np
class_names = ['Selfie','Non-Selfie']
f = open("model_cnn1.json",'r+')
json_string = f.read()
f.close()
model = model_from_json(json_string)
model.load_weights('model_cnn1.h5')
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
def predict_image(img):
prediction = model.predict(img.reshape(-1,100,100,3))[0]
return {class_names[i]: float(prediction[i]) for i in range(2)}
import gradio as gr
image = gr.inputs.Image(shape=(100,100))
label = gr.outputs.Label(num_top_classes=5)
gr.Interface(fn=predict_image, inputs=image, outputs=label,interpretation='default').launch(debug='True',share='True')