Harun01 commited on
Commit
62dc8b1
·
verified ·
1 Parent(s): eee1c01

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +14 -11
src/streamlit_app.py CHANGED
@@ -1,32 +1,35 @@
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]}")
29
-
30
  confidence = np.max(prediction)
31
- st.success(f"Tahmin: {class_names[predicted_class]} ({confidence:.2%} güven)")
32
 
 
 
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
+ # Modeli yükle
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, 170))
15
  img = np.array(img) / 255.0
16
  img = np.expand_dims(img, axis=0)
17
  return img
18
 
19
+ # Uygulama arayüzü
20
+ st.title("🩺 Cilt Kanseri Sınıflandırıcı")
21
+ st.write("Bir deri lezyonu resmi yükle, model tahmin etsin:")
22
 
23
+ file = st.file_uploader("Resim seç", type=["jpg", "jpeg", "png"])
24
 
25
  if file is not None:
26
  img = Image.open(file).convert("RGB")
27
+ st.image(img, caption="Yüklenen Görsel", use_container_width=True)
28
+
29
  image = process_image(img)
30
  prediction = model.predict(image)
31
+
32
  predicted_class = np.argmax(prediction)
 
 
33
  confidence = np.max(prediction)
 
34
 
35
+ st.success(f"Tahmin: {class_names[predicted_class]} ({confidence:.2%} güven)")