Spaces:
Sleeping
Sleeping
import gradio as gr | |
import cv2 | |
import tensorflow as tf | |
import numpy as np | |
class_names = ['Kharbandhi Lhakhang', 'Milarepa Lhakhang', 'Pasakha Lhakhang'] | |
img_height, img_width = 256, 256 | |
model = tf.keras.models.load_model('CSR_models.h5') | |
examples = [ | |
'img/Milarepa.jpg', | |
'img/kharbandhi.jpg', | |
'img/pasakha.jpeg' | |
] | |
def greet(sample_image): | |
sample_image_resized = cv2.resize(sample_image, (img_height, img_width)) | |
sample_image_expanded = np.expand_dims(sample_image_resized, axis=0) | |
predictions = model.predict(sample_image_expanded) | |
image_output_class = class_names[np.argmax(predictions)] | |
return image_output_class | |
demo = gr.Interface(fn=greet, inputs="image", outputs="text", examples = examples) | |
demo.launch() |