Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +32 -0
- my_cnn_model.h5 +3 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,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 |
+
import cv2
|
| 6 |
+
|
| 7 |
+
model = load_model('C:/Users/mucahit/Desktop/day13/my_cnn_model.h5')
|
| 8 |
+
|
| 9 |
+
def process_image(img):
|
| 10 |
+
img = cv2.resize(img, (170, 170))
|
| 11 |
+
img = img / 255.0
|
| 12 |
+
img = np.expand_dims(img, axis=0)
|
| 13 |
+
return img
|
| 14 |
+
|
| 15 |
+
st.title('Kanser Resmi Siniflandirma :cancer:')
|
| 16 |
+
st.write('Resim seç ve model kanser olup olmadigini tahmin etsin')
|
| 17 |
+
|
| 18 |
+
file = st.file_uploader('Bir Resim Seç', type=['jpeg', 'jpg', 'png'])
|
| 19 |
+
|
| 20 |
+
if file is not None:
|
| 21 |
+
img = Image.open(file)
|
| 22 |
+
st.image(img, caption='Yuklenen resim')
|
| 23 |
+
img = np.array(img)
|
| 24 |
+
if img.shape[2] == 4:
|
| 25 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGRA2BGR)
|
| 26 |
+
|
| 27 |
+
image = process_image(img)
|
| 28 |
+
prediction = model.predict(image)
|
| 29 |
+
prediction_class = np.argmax(prediction)
|
| 30 |
+
|
| 31 |
+
class_names = ['Kanser Değil', 'Kanser']
|
| 32 |
+
st.write(class_names[prediction_class])
|
my_cnn_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:854a96dc8d0b6b7e43b4c75e036a34a15d8998eb24663405af844c8aa2bfd467
|
| 3 |
+
size 165516528
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
tensorflow
|
| 2 |
+
streamlit
|