File size: 1,114 Bytes
c4dd110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dc9b109
 
c4dd110
 
 
 
 
 
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
36
37
38
39
40
41
import gradio as gr
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
import numpy as np

# Load the trained model
model = load_model("best_model.keras")

# Define disease labels
disease_labels = [
    "Cellulitis", "Impetigo", "Athlete's Foot", "Nail Fungus", 
    "Ringworm", "Cutaneous Larva Migrans", "Chickenpox", "Shingles"
]

# Define the prediction function
def predict_disease(img):
    # Preprocess the image
    img = img.resize((224, 224))
    img_array = image.img_to_array(img)
    img_array = np.expand_dims(img_array, axis=0)
    img_array /= 255.0  # Normalize to [0, 1] range

    # Make prediction
    predictions = model.predict(img_array)
    predicted_index = np.argmax(predictions)
    
    # Return the predicted disease
    return disease_labels[predicted_index]

# Create Gradio interface
iface = gr.Interface(
    fn=predict_disease,
    inputs=gr.Image(type="pil"),
    outputs=gr.Textbox(),
    title="Skin Disease Classification",
    description="Upload an image of skin disease to classify it."
)

# Launch the interface
iface.launch()