Spaces:
Runtime error
Runtime error
rajsecrets0
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,39 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
import tensorflow as tf
|
|
|
3 |
|
4 |
-
st.
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
model = tf.keras.models.load_model('TvachaAI.h5')
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
st.
|
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")
|
|