Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
from PIL import Image | |
import numpy as np | |
def predict_image(image): | |
pipe = pipeline("image-classification", model="itsTomLie/Jaundice_Classifier") | |
if isinstance(image, np.ndarray): | |
image = Image.fromarray(image.astype('uint8')) | |
elif isinstance(image, str): | |
image = Image.open(image) | |
result = pipe(image) | |
label = result[0]['label'] | |
confidence = result[0]['score'] | |
print(f"Prediction: {label}, Confidence: {confidence}") | |
return label, confidence | |
interface = gr.Interface( | |
fn=predict_image, | |
inputs=gr.Image(type="numpy", label="Upload an Image"), | |
outputs=[gr.Textbox(label="Prediction"), gr.Textbox(label="Confidence")] | |
) | |
interface.launch() |