Spaces:
Build error
Build error
Upload 3 files
Browse files- app.py +29 -0
- my_cnn_model.h5 +3 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +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 |
+
|
my_cnn_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cc1efe35e4ee1bd847549a0377df97d858ede12e9426feec95c036f6f9ec369d
|
| 3 |
+
size 165531496
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
tensorflow
|