rajsecrets0 commited on
Commit
6ad8ab2
·
verified ·
1 Parent(s): 4520b78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -13
app.py CHANGED
@@ -1,21 +1,39 @@
1
  import streamlit as st
 
2
  import tensorflow as tf
 
3
 
4
- st.title("Skin Disease Classification App")
 
 
 
5
 
6
- # Load model
7
- model = tf.keras.models.load_model('TvachaAI.h5')
8
 
9
- # Create sidebar for uploading images
10
- st.sidebar.title("Upload Image")
11
- image = st.sidebar.file_uploader("Upload an image", type=['png', 'jpg'])
12
 
13
- if image is not None:
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- # Process & predict
16
- img = process_image(image)
17
- preds = model.predict(img)
 
 
18
 
19
- # Display image & predictions
20
- st.image(img, use_column_width=True)
21
- st.write(f"Prediction: {decode_predictions(preds)}")
 
1
  import streamlit as st
2
+ import numpy as np
3
  import tensorflow as tf
4
+ from PIL import Image
5
 
6
+ @st.cache(allow_output_mutation=True)
7
+ def load_model():
8
+ model = tf.keras.models.load_model(TvachaAI.h5')
9
+ return model
10
 
11
+ model = load_model()
 
12
 
13
+ CLASSES = ["Eczema", "Melanoma", "Atopic Dermatitis", "Basal Cell Carcinoma", "Melanocytic Nevi",
14
+ "Benign Keratosis-like Lesions", "Psoriasis", "Seborrheic Keratoses",
15
+ "Fungal Infections", "Viral Infections"]
16
 
17
+ st.title("Skin Disease Classification")
18
+
19
+ uploaded_file = st.file_uploader("Choose an image...", type="jpg")
20
+
21
+ if uploaded_file is not None:
22
+ image = Image.open(uploaded_file)
23
+ image = image.resize((224,224))
24
+ img_array = tf.keras.preprocessing.image.img_to_array(image)
25
+ img_array = np.expand_dims(img_array, axis=0)
26
+
27
+ pred = model.predict(img_array)
28
+ score = tf.nn.softmax(pred[0])
29
+
30
+ st.image(image, caption='Uploaded Image.', use_column_width=True)
31
 
32
+ st.write("")
33
+ st.write("Classifying...")
34
+ label = "{}".format(CLASSES[np.argmax(score)])
35
+ st.write(label)
36
+ st.write(f"Score: {100 * np.max(score):.2f}%")
37
 
38
+ else:
39
+ st.write("Please upload an image file")