Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +31 -0
- cnn_model.h5 +3 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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('cnn_model.h5')
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def process_image(img):
|
| 11 |
+
img=img.resize((170,170))
|
| 12 |
+
img=np.array(img)
|
| 13 |
+
img=img/255.0 #normalize
|
| 14 |
+
img=np.expand_dims(img,axis=0)
|
| 15 |
+
return img
|
| 16 |
+
|
| 17 |
+
st.title("Cancer Image Classification :cancer:")
|
| 18 |
+
st.write("Select image and model predicts whether it is cancer")
|
| 19 |
+
|
| 20 |
+
file=st.file_uploader('Bir Resim Sec',type=['jpg','jpeg','png'])
|
| 21 |
+
|
| 22 |
+
if file is not None:
|
| 23 |
+
img=Image.open(file)
|
| 24 |
+
st.image(img,caption='uploaded image')
|
| 25 |
+
image= process_image(img)
|
| 26 |
+
prediction=model.predict(image)
|
| 27 |
+
predicted_class=np.argmax(prediction)
|
| 28 |
+
|
| 29 |
+
class_names=['Non Cancer','Cancer']
|
| 30 |
+
|
| 31 |
+
st.write(class_names[predicted_class])
|
cnn_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7014d594d672d43c71288b5ff4f3b798796d1e027d09c2c321fe750765512c4b
|
| 3 |
+
size 165525616
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
tensorflow
|