File size: 1,032 Bytes
3771187
 
 
f6136b5
 
900de20
 
3771187
900de20
3771187
 
 
 
 
 
f6136b5
900de20
3771187
900de20
3771187
900de20
3771187
 
 
f6136b5
900de20
d1dae66
f6136b5
 
 
3771187
900de20
d1dae66
3771187
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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()