twodottie commited on
Commit
e9d7e54
·
verified ·
1 Parent(s): 78f253b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -29
app.py CHANGED
@@ -1,29 +1,29 @@
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) #np tek bir array old için expand ediyoruz tek bir arraye dönştürüyoruz
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) #cv2 ile değil bu sefer image ile açıyoruz
22
- st.image(img,caption='yuklenen resim')
23
- image= process_image(img) #yuklenen resme diğer resimlere yaptığımız processi yapıyoruz
24
- prediction=model.predict(image)
25
- predicted_class=np.argmax(prediction) #ihtimal yüzde elliden fazlaysa argmaxla 1, azsa 0 yapıyoruz
26
-
27
- class_names=['Kanser Degil','Kanser']
28
- st.write(class_names[predicted_class]) #0sa kanser değil 1se kanser yazdırcak
29
-
 
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) #np tek bir array old için expand ediyoruz tek bir arraye dönştürüyoruz
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) #cv2 ile değil bu sefer image ile açıyoruz
22
+ st.image(img,caption='yuklenen resim')
23
+ image= process_image(img) #yuklenen resme diğer resimlere yaptığımız processi yapıyoruz
24
+ prediction=model.predict(image)
25
+ predicted_class=np.argmax(prediction) #ihtimal yüzde elliden fazlaysa argmaxla 1, azsa 0 yapıyoruz
26
+
27
+ class_names=['Kanser Degil','Kanser']
28
+ st.write(class_names[predicted_class]) #0sa kanser değil 1se kanser yazdırcak
29
+