Spaces:
Runtime error
Runtime error
Commit
•
3754fb6
1
Parent(s):
8eb2168
Upload 3 files
Browse files- app.py +30 -0
- my_cnn_model.h5 +3 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import tensorflow as tf
|
3 |
+
from tensorflow.keras.models import load_model
|
4 |
+
from PIL import Image
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
model = load_model("./my_cnn_model.h5")
|
8 |
+
|
9 |
+
def process_image(img):
|
10 |
+
img = img.resize((170,170))
|
11 |
+
img = np.array(img)
|
12 |
+
img = img / 255.0 # normalize etme resmi 0 1 yapma
|
13 |
+
img = np.expand_dims(img, axis=0)
|
14 |
+
return img
|
15 |
+
|
16 |
+
st.title("Kanser Resmi Sınıflandırma :cancer:")
|
17 |
+
st.write("Resim seç ve model kanser olup olmadığını tahmin etsin")
|
18 |
+
|
19 |
+
file= st.file_uploader("Bir Resim Seç", type=["jpg", "jpeg", "png"])
|
20 |
+
|
21 |
+
if file is not None:
|
22 |
+
img = Image.open(file)
|
23 |
+
st.image(img, caption="yüklenen resim")
|
24 |
+
image = process_image(img)
|
25 |
+
prediction = model.predict(image)
|
26 |
+
predicted_class = np.argmax(prediction)
|
27 |
+
|
28 |
+
class_names = ["Kanser Değil", "Kanser"]
|
29 |
+
st.write(class_names[predicted_class])
|
30 |
+
|
my_cnn_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:368a0951488c6af67bc976cb1f0fc623d3378929227a8582fba0047285842c41
|
3 |
+
size 165525616
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
tensorflow
|