RoAr777 commited on
Commit
0e5da45
·
1 Parent(s): 77e6cf8

Add application file

Browse files
Files changed (2) hide show
  1. Xception_skin.h5 +3 -0
  2. app.py +58 -0
Xception_skin.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:757416452aeaa4b34d52724497de724c91a11fc8ef9aa47930b813330f476566
3
+ size 275909808
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+ import matplotlib.pyplot as plt
6
+ import io
7
+ import pandas as pd
8
+
9
+ # Load the Xception model
10
+ model = tf.keras.models.load_model("Xception_skin.h5") # Replace with your model path
11
+
12
+ # Define a function for inference and confidence values
13
+ def classify_image(input_image):
14
+ # Preprocess the image
15
+ img = input_image.resize((299, 299)) # Ensure the image size matches your Xception model's input size
16
+ img = np.array(img) / 255.0 # Normalize the image
17
+ img = np.expand_dims(img, axis=0) # Add batch dimension
18
+
19
+ # Perform classification
20
+ predictions = model.predict(img)
21
+ class_index = np.argmax(predictions[0]) # Get the index of the predicted class
22
+ confidence_values = predictions[0] # Get confidence values for all classes
23
+
24
+ # Map the class index to the corresponding class name using the provided dictionary
25
+ class_names = {
26
+ 0: 'Eczema',
27
+ 1: 'Warts Molluscum and other Viral Infections',
28
+ 2: 'Melanoma',
29
+ 3: 'Atopic Dermatitis',
30
+ 4: 'Basal Cell Carcinoma (BCC)',
31
+ 5: 'Melanocytic Nevi (NV) ',
32
+ 6: 'Benign Keratosis-like Lesions (BKL)',
33
+ 7: 'Psoriasis pictures Lichen Planus and related diseases',
34
+ 8: 'Seborrheic Keratoses and other Benign Tumors',
35
+ 9: 'Tinea Ringworm Candidiasis and other Fungal Infections'
36
+ }
37
+ confidences = {class_names[i]: float(confidence_values[i]) for i in range(len(confidence_values))}
38
+ #predicted_class_name = class_names[class_index] # Get the class name based on the index
39
+
40
+ return confidences
41
+
42
+ # Define the Gradio interface
43
+ input_image = gr.inputs.Image(type="pil")
44
+ #output_class_name = gr.outputs.Label(type='text', label='Predicted Class Name')
45
+ output_confidence_values = gr.outputs.Label(type='text', label='Confidence Values')
46
+
47
+ # Create the Gradio app
48
+ app = gr.Interface(
49
+ fn=classify_image,
50
+ inputs=input_image,
51
+ outputs=output_confidence_values,
52
+ title='Skin Disease Classifier',
53
+ description='Made By Roshan Rateria',
54
+ )
55
+
56
+ # Launch the Gradio app
57
+ app.launch(share=True)
58
+