Spaces:
Runtime error
Runtime error
import streamlit as st | |
import numpy as np | |
import tensorflow as tf | |
from PIL import Image | |
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") |