Spaces:
Running
Running
File size: 1,253 Bytes
07d35f9 1aefc4e 07d35f9 1aefc4e 07d35f9 |
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 |
import streamlit as st
from tensorflow.keras.models import load_model
from PIL import Image
import numpy as np
# Load the model
model = load_model('my_cnn_model.h5')
#yeni gelen resmi modelin girdi boyutuna uygun hale getirelim
def process_image(image):
image = image.resize((170,170))
image = np.array(image)
image = image / 255.0
image = np.expand_dims(image, axis=0) # burada modelin beklediği gibi bir girdi oluşturduk
return image
st.title("Skin Cancer Classification - Metehan Ayhan")
st.write("This is a simple image classification web app to predict the type of skin cancer.")
st.write("Please upload a skin image for the prediction.")
file = st.file_uploader("Please upload an image file", type=["jpg", "png", "jpeg"])
if file is None:
st.text("You haven't uploaded an image file")
else:
image = Image.open(file) # resmi aç
st.image(image, use_column_width=True, caption='Image:') # resmi gösterelim
predictions = model.predict(process_image(image))
predicted_class = np.argmax(predictions) # en yüksek olasılığa sahip sınıfı al
class_names = ['Cancer', 'Not Cancer']
st.write(class_names[predicted_class], "with", round(100*np.max(predictions), 2), "% probability")
|