# -*- coding: utf-8 -*- """gradioApp.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/19rOnZUE7tNaMyAjlhnO4vLKb8mojrf2V """ # Commented out IPython magic to ensure Python compatibility. # %%capture # #Use capture to not show the output of installing the libraries! # !pip install gradio import gradio as gr import numpy as np import tensorflow as tf model = tf.keras.models.load_model('/content/drive/MyDrive/project_image_2023_NO/saved_models/saved_model/densenet') labels = ['Healthy', 'Patient'] def classify_image(inp): inp = inp.reshape((-1, 224, 224, 3)) inp = tf.keras.applications.densenet.preprocess_input(inp) prediction = model.predict(inp) confidences = {labels[i]: float(prediction[0][i]) for i in range(2)} return confidences gr.Interface(fn=classify_image, inputs=gr.Image(shape=(224, 224)), outputs=gr.Label(num_top_classes = 2), title="Demo", description="Here's a sample image classification. Enjoy!", ).launch(share = True)