File size: 637 Bytes
4e4bccc
c2d9f80
976190a
 
 
 
c2d9f80
 
976190a
c2d9f80
976190a
 
 
 
 
c2d9f80
 
4e4bccc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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')

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")
demo.launch()