Upload 2 files
Browse files- app.py +34 -0
- cnn_model_epoch_100.h5 +3 -0
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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('cnn_model_epoch_100.h5')
|
7 |
+
|
8 |
+
def process_image(img):
|
9 |
+
img = img.resize((170, 170)) # Boyutu 170x170 piksel yaptık
|
10 |
+
img = np.array(img) / 255.0 # Normalize ettik
|
11 |
+
img = np.expand_dims(img, axis=0) # 0. ortada olsun diye sayfada
|
12 |
+
|
13 |
+
st.title('Kanser Resmi sınıflandırma :cancer:')
|
14 |
+
img_file = st.file_uploader('Bir Resim Seç', type=['jpeg', 'png'])
|
15 |
+
|
16 |
+
if img_file is not None:
|
17 |
+
img = Image.open(img_file)
|
18 |
+
st.image(img, caption='Yüklenen resim')
|
19 |
+
prediction = model.predict(img)
|
20 |
+
|
21 |
+
st.title('Kanser Resmi Sınıflandırma :cancer:')
|
22 |
+
st.write('Resim seç ve model kanser olup olmadığını tahmin etsin.')
|
23 |
+
|
24 |
+
file = st.file_uploader('Bir Resim Seç', type=['jpg', 'jpeg', 'png'])
|
25 |
+
|
26 |
+
if file is not None:
|
27 |
+
img = Image.open(file)
|
28 |
+
st.image(img, caption='Yüklenen resim')
|
29 |
+
image = process_image(img)
|
30 |
+
prediction = model.predict(image)
|
31 |
+
predicted_class = np.argmax(prediction)
|
32 |
+
|
33 |
+
class_names = ['Kanser Değil', 'Kanser']
|
34 |
+
st.write(class_names[predicted_class])
|
cnn_model_epoch_100.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:622e2efba6863dc1a74859fa63afc2b020466b5c7f31ce28c3515f9e4ed458f8
|
3 |
+
size 28204312
|