Update src/streamlit_app.py
Browse files- src/streamlit_app.py +16 -28
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,28 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
from tensorflow.keras.models import load_model
|
| 3 |
from PIL import Image
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
-
|
| 7 |
-
try:
|
| 8 |
-
model = load_model('my_cnn_model.h5')
|
| 9 |
-
except Exception as e:
|
| 10 |
-
st.error(f"Model yüklenirken bir hata oluştu: {e}")
|
| 11 |
|
| 12 |
def process_image(img):
|
| 13 |
-
img
|
| 14 |
-
img
|
| 15 |
-
img
|
| 16 |
-
img
|
| 17 |
return img
|
| 18 |
|
| 19 |
-
st.title("Kanser Resmi
|
| 20 |
-
st.write("Resim
|
| 21 |
|
| 22 |
-
file
|
| 23 |
|
| 24 |
if file is not None:
|
| 25 |
-
img
|
| 26 |
-
st.image(img,
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
# Tahmin yap
|
| 32 |
-
try:
|
| 33 |
-
prediction = model.predict(image)
|
| 34 |
-
predicted_class = np.argmax(prediction)
|
| 35 |
-
|
| 36 |
-
class_names = ['Kanser Değil', 'Kanser']
|
| 37 |
-
st.write(class_names[predicted_class])
|
| 38 |
-
except Exception as e:
|
| 39 |
-
st.error(f"Tahmin yaparken bir hata oluştu: {e}")
|
| 40 |
-
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
from tensorflow.keras.models import load_model
|
| 3 |
from PIL import Image
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
+
model=load_model('my_cnn_model.h5')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def process_image(img):
|
| 9 |
+
img=img.resize((170,170)) #boyutunu 170 x 170 pixel yaptik
|
| 10 |
+
img=np.array(img)
|
| 11 |
+
img=img/255.0 #normalize ettik
|
| 12 |
+
img=np.expand_dims(img,axis=0)
|
| 13 |
return img
|
| 14 |
|
| 15 |
+
st.title("Kanser Resmi Siniflandirma :cancer:")
|
| 16 |
+
st.write("Resim sec ve model kanser olup olmadigini tahmin etsin")
|
| 17 |
|
| 18 |
+
file=st.file_uploader('Bir Resim Sec',type=['jpg','jpeg','png'])
|
| 19 |
|
| 20 |
if file is not None:
|
| 21 |
+
img=Image.open(file)
|
| 22 |
+
st.image(img,caption='yuklenen resim')
|
| 23 |
+
image= process_image(img)
|
| 24 |
+
prediction=model.predict(image)
|
| 25 |
+
predicted_class=np.argmax(prediction)
|
| 26 |
|
| 27 |
+
class_names=['Kanser Degil','Kanser']
|
| 28 |
+
st.write(class_names[predicted_class])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|