Spaces:
Runtime error
Runtime error
| import requests | |
| import tensorflow as tf | |
| import numpy as np | |
| import cv2 | |
| import gradio as gr | |
| from tensorflow.keras.models import load_model | |
| response = requests.get("https://raw.githubusercontent.com/IuryChagas25/Chest_Cancer_Detection/main/Labels.txt") | |
| labels = response.text.split("\n") | |
| model = load_model("model2.h5") # load the model | |
| def classify_image(image): | |
| new_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) | |
| new_image = new_image / 255.0 | |
| resized_image = cv2.resize(new_image,(250,250)) | |
| prediction = model.predict(np.array([resized_image])).flatten() | |
| return {labels[i]: float(prediction[i]) for i in range(4)} | |
| image = gr.inputs.Image(shape=(250, 250)) | |
| label = gr.outputs.Label(num_top_classes=4) | |
| demo = gr.Interface( | |
| fn=classify_image, inputs=image, outputs=label, examples=[["000110.png"], ["000111 (2).png"], ["6 - Copy.png"]], theme="huggingface", interpretation="shap", num_shap = 5) | |
| if __name__ == "__main__": | |
| demo.launch(share='True') |