import gradio as gr import tensorflow as tf path_to_model = "./model_2.h5" model = tf.keras.models.load_model(path_to_model) labels = ['Acne and Rosacea Photos', 'Actinic Keratosis Basal Cell Carcinoma and other Malignant Lesions', 'Atopic Dermatitis Photos', 'Bullous Disease Photos', 'Cellulitis Impetigo and other Bacterial Infections', 'Eczema Photos', 'Exanthems and Drug Eruptions', 'Hair Loss Photos Alopecia and other Hair Diseases', 'Herpes HPV and other STDs Photos', 'Light Diseases and Disorders of Pigmentation', 'Lupus and other Connective Tissue diseases', 'Melanoma Skin Cancer Nevi and Moles', 'Nail Fungus and other Nail Disease', 'Poison Ivy Photos and other Contact Dermatitis', 'Psoriasis pictures Lichen Planus and related diseases', 'Scabies Lyme Disease and other Infestations and Bites', 'Seborrheic Keratoses and other Benign Tumors', 'Systemic Disease', 'Tinea Ringworm Candidiasis and other Fungal Infections', 'Urticaria Hives', 'Vascular Tumors', 'Vasculitis Photos', 'Warts Molluscum and other Viral Infections'] def classify_image(inp): inp = inp.reshape((-1, 256, 256, 3)) prediction = model.predict(inp).flatten() confidences = {labels[i]: float(prediction[i]) for i in range(23)} return confidences title="SKIN DISEASE PREDICTION" description = "An automated system is proposed for the diagnosis of #23 common skin diseases by using data from clinical images and patient information using deep learning pre-trained ResNet50 model. we will implement a simple image classification model using Gradio and Tensorflow. The image classification model will classify images of various skin disease problems into labeled classes." article = "We used the generated Gradio UI to input an image for the trained convolutional neural network to make image classifications. The convolutional neural network was able to accurately classify the input image. Sometimes you would like to resize the image from the gradio UI for better performance" examples = [ ['./123.jpg'], ['./acne-closed-comedo-2.jpg'], ['./distal-subungual-onychomycosis-86.jpg'], ['./cherry-angioma-16.jpg'], ['./malignant-melanoma-16.jpg'], ['./tinea-primary-lesion-15.jpg'] ] gr.Interface(fn=classify_image, title = title, article = article, description = description, inputs=gr.inputs.Image(shape=(256, 256)), outputs=gr.outputs.Label(num_top_classes=4), examples=examples).launch()