HDVIT / app.py
Sazzz02's picture
Update app.py
900de20 verified
import numpy as np
from keras.models import load_model
from keras.preprocessing import image
import gradio as gr
# Load the re-saved model
model = load_model("VGG16-Final-hf.h5")
# Class names (update if different)
class_names = [
'Alopecia Areata', 'Contact Dermatitis', 'Folliculitis',
'Head Lice', 'Lichen Planus', 'Male Pattern Baldness',
'Psoriasis', 'Seborrheic Dermatitis', 'Telogen Effluvium',
'Tinea Capitis'
]
# Define prediction function
def predict(img):
img = img.resize((224, 224))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0) / 255.0
prediction = model.predict(img_array)
predicted_class = class_names[np.argmax(prediction)]
return f"Prediction: {predicted_class}"
# Create Gradio interface
gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs="text",
title="Hair/Scalp Disease Classifier",
description="Upload a scalp image to classify the hair/scalp condition using a VGG16-based CNN model."
).launch()