Spaces:
Runtime error
Runtime error
File size: 690 Bytes
f45506b e758c0d f45506b e758c0d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
CLASS_NAMES = ["Oral Homogenous Leukoplakia", "Oral Non-Homogenous Leukoplakia", "Other Oral White Lesions"]
model = tf.keras.models.load_model('./model.keras')
def predict(image):
img = image.convert("RGB").resize((224, 224))
arr = (np.array(img, dtype=np.float32) / 127.5) - 1.0
preds = model.predict(np.expand_dims(arr, 0))[0]
idx = int(np.argmax(preds))
return {CLASS_NAMES[i]: float(preds[i]) for i in range(len(CLASS_NAMES))}
demo = gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs=gr.Label(num_top_classes=3),
title="OralScan AI"
)
demo.launch() |