|
|
import numpy as np |
|
|
from keras.models import load_model |
|
|
from keras.preprocessing import image |
|
|
import gradio as gr |
|
|
|
|
|
|
|
|
model = load_model("VGG16-Final-hf.h5") |
|
|
|
|
|
|
|
|
class_names = [ |
|
|
'Alopecia Areata', 'Contact Dermatitis', 'Folliculitis', |
|
|
'Head Lice', 'Lichen Planus', 'Male Pattern Baldness', |
|
|
'Psoriasis', 'Seborrheic Dermatitis', 'Telogen Effluvium', |
|
|
'Tinea Capitis' |
|
|
] |
|
|
|
|
|
|
|
|
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}" |
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|