Update src/streamlit_app.py
Browse files- src/streamlit_app.py +9 -16
src/streamlit_app.py
CHANGED
|
@@ -1,35 +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 |
-
model = load_model('my_cnn_model.h5')
|
| 8 |
|
| 9 |
-
# Sınıf isimleri
|
| 10 |
class_names = ['Kanser Değil', 'Kanser']
|
| 11 |
|
| 12 |
-
# Resmi işle
|
| 13 |
def process_image(img):
|
| 14 |
-
img = img.resize((170,
|
| 15 |
img = np.array(img) / 255.0
|
| 16 |
img = np.expand_dims(img, axis=0)
|
| 17 |
return img
|
| 18 |
|
| 19 |
-
|
| 20 |
-
st.
|
| 21 |
-
st.write("Bir deri lezyonu resmi yükle, model tahmin etsin:")
|
| 22 |
|
| 23 |
-
file = st.file_uploader(
|
| 24 |
|
| 25 |
if file is not None:
|
| 26 |
img = Image.open(file).convert("RGB")
|
| 27 |
-
st.image(img, caption=
|
| 28 |
-
|
| 29 |
image = process_image(img)
|
| 30 |
prediction = model.predict(image)
|
| 31 |
-
|
| 32 |
predicted_class = np.argmax(prediction)
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
st.success(f"Tahmin: {class_names[predicted_class]} ({confidence:.2%} güven)")
|
|
|
|
| 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 |
+
# ✅ Doğru dosya yolu
|
| 7 |
+
model = load_model('src/my_cnn_model.h5')
|
| 8 |
|
|
|
|
| 9 |
class_names = ['Kanser Değil', 'Kanser']
|
| 10 |
|
|
|
|
| 11 |
def process_image(img):
|
| 12 |
+
img = img.resize((170,170))
|
| 13 |
img = np.array(img) / 255.0
|
| 14 |
img = np.expand_dims(img, axis=0)
|
| 15 |
return img
|
| 16 |
|
| 17 |
+
st.title("🧬 Cilt Kanseri Sınıflandırıcı")
|
| 18 |
+
st.write("Bir cilt görseli yükleyin, model kanser olup olmadığını tahmin etsin.")
|
|
|
|
| 19 |
|
| 20 |
+
file = st.file_uploader('Bir resim seç', type=['jpg','jpeg','png'])
|
| 21 |
|
| 22 |
if file is not None:
|
| 23 |
img = Image.open(file).convert("RGB")
|
| 24 |
+
st.image(img, caption='Yüklenen Resim', use_container_width=True)
|
|
|
|
| 25 |
image = process_image(img)
|
| 26 |
prediction = model.predict(image)
|
|
|
|
| 27 |
predicted_class = np.argmax(prediction)
|
| 28 |
+
st.success(f"Tahmin: {class_names[predicted_class]}")
|
|
|
|
|
|