oralscan-api / app.py
NerdyAlgorithm's picture
Update app.py
e758c0d verified
raw
history blame contribute delete
690 Bytes
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()