import gradio as gr import tensorflow as tf import numpy as np import keras import tensorflow_hub as hub model = tf.keras.models.load_model('20220815-14421660574557-full-image-set-mobilenetv2-Adam.h5', custom_objects = {"KerasLayer":hub.KerasLayer}) class_name = {0:"Other",1:"monkeypox"} def predict_image(img): img_3d=img.reshape(-1,224,224,3) prediction=model.predict(img_3d)[0] return {class_name[i]: float(prediction[i]) for i in range(2)} image = gr.inputs.Image(shape=(224,224)) label = gr.outputs.Label(num_top_classes=2) gr.Interface(fn=predict_image, inputs=image, outputs=label, capture_session=True, examples=["is_monkeypox.jpg", "not_monkeypox.jpg"]).launch(debug='True')