Spaces:
Runtime error
Runtime error
| import numpy as np | |
| from keras.models import load_model | |
| from keras.preprocessing import image | |
| import gradio as gr | |
| # Load the HDF5 model | |
| model = load_model("VGG16-Final.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 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 condition using a VGG16-based model." | |
| ).launch() | |