from tensorflow.keras.models import load_model from tensorflow.keras.preprocessing import image import numpy as np from PIL import Image styles = ["Adenocarcinoma","Large cell carcinoma","normal","squamous cell carcinoma" ] import gradio as gr def preprocess(img): new_img = Image.fromarray((img * 255).astype('uint8')) new_img = new_img.resize((224, 224)) model = load_model("chest.h5") new_img = image.img_to_array(new_img) new_img = np.expand_dims(new_img, axis=0) pred = model.predict(new_img) return styles[np.argmax(pred)] iface = gr.Interface( fn = preprocess, # Function to call on user input inputs = gr.Image(), # Input type (image upload) outputs = "text", # Output type (text label) live=True, title="Image Classification made by Siddhant Bashisth", description="Upload the image", ) # Launch the Gradio app iface.launch(debug = True)