Update src/streamlit_app.py
Browse files12345678910111213141516171819202122232425262728import streamlit as stfrom tensorflow.keras.models import load_modelfrom PIL import Imageimport numpy as npmodel=load_model('my_cnn_model.h5')def process_image(img):img=img.resize((170,170)) #boyutunu 170 x 170 pixel yaptikimg=np.array(img)img=img/255.0 #normalize ettikimg=np.expand_dims(img,axis=0)return imgst.title("Kanser Resmi Siniflandirma :cancer:")st.write("Resim sec ve model kanser olup olmadigini tahmin etsin")file=st.file_uploader('Bir Resim Sec',type=['jpg','jpeg','png'])if file is not None:img=Image.open(file)st.image(img,caption='yuklenen resim')image= process_image(img)prediction=model.predict(image)predicted_class=np.argmax(prediction)class_names=['Kanser Degil','Kanser']st.write(class_names[predicted_class])12345678910111213141516171819202122232425262728293031323334353637383940import streamlit as stfrom tensorflow.keras.models import load_modelfrom PIL import Imageimport numpy as np# Modeli yükletry:model = load_model('my_cnn_model.h5')except Exception as e:st.error(f"Model yüklenirken bir hata oluştu: {e}")def process_image(img):img = img.resize((170, 170)) # Boyutunu 170 x 170 pixel yaptıkimg = np.array(img)img = img / 255.0 # Normalize ettikimg = np.expand_dims(img, axis=0)return imgst.title("Kanser Resmi Sınıflandırma :cancer:")st.write("Resim seç ve model kanser olup olmadığını tahmin etsin.")file = st.file_uploader('Bir Resim Seç', type=['jpg', 'jpeg', 'png'])if file is not None:img = Image.open(file)st.image(img, caption='Yüklenen Resim', use_column_width=True)# Resmi işleimage = process_image(img)# Tahmin yaptry:prediction = model.predict(image)predicted_class = np.argmax(prediction)class_names = ['Kanser Değil', 'Kanser']st.write(class_names[predicted_class])except Exception as e:st.error(f"Tahmin yaparken bir hata oluştu: {e}")
src/streamlit_app.py+28-16