File size: 1,186 Bytes
31ec0da
6ad8ab2
31ec0da
6ad8ab2
31ec0da
6ad8ab2
 
71b433b
6ad8ab2
31ec0da
6ad8ab2
31ec0da
6ad8ab2
 
 
31ec0da
6ad8ab2
 
 
 
 
 
 
 
 
 
 
 
 
 
31ec0da
6ad8ab2
 
 
 
 
31ec0da
6ad8ab2
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import streamlit as st
import numpy as np 
import tensorflow as tf
from PIL import Image

@st.cache(allow_output_mutation=True)
def load_model():
    model = tf.keras.models.load_model('TvachaAI.h5') 
    return model

model = load_model()

CLASSES = ["Eczema", "Melanoma", "Atopic Dermatitis", "Basal Cell Carcinoma", "Melanocytic Nevi", 
           "Benign Keratosis-like Lesions", "Psoriasis", "Seborrheic Keratoses", 
           "Fungal Infections", "Viral Infections"]

st.title("Skin Disease Classification")

uploaded_file = st.file_uploader("Choose an image...", type="jpg")

if uploaded_file is not None:
    image = Image.open(uploaded_file)  
    image = image.resize((224,224))
    img_array = tf.keras.preprocessing.image.img_to_array(image)
    img_array = np.expand_dims(img_array, axis=0) 
    
    pred = model.predict(img_array)
    score = tf.nn.softmax(pred[0])
    
    st.image(image, caption='Uploaded Image.', use_column_width=True)
    
    st.write("")
    st.write("Classifying...")
    label = "{}".format(CLASSES[np.argmax(score)])
    st.write(label)
    st.write(f"Score: {100 * np.max(score):.2f}%")
    
else:
    st.write("Please upload an image file")