Upload app.py
Browse files
app.py
CHANGED
@@ -1,39 +1,34 @@
|
|
1 |
-
import
|
2 |
-
from
|
3 |
-
from diffusers import DiffusionPipeline
|
4 |
-
from io import BytesIO
|
5 |
from PIL import Image
|
|
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
def index():
|
15 |
-
return render_template('index.html') # `templates` dizinine taşıdığınızı varsayıyoruz.
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
# Kullanıcıdan gelen prompt verisini al
|
22 |
-
prompt = request.form['prompt']
|
23 |
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
img_io = BytesIO()
|
29 |
-
image.save(img_io, 'PNG')
|
30 |
-
img_io.seek(0)
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
-
|
|
|
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('cnn_model_epoch_100.h5')
|
7 |
|
8 |
+
def process_image(img):
|
9 |
+
img = img.resize((170, 170)) # Boyutu 170x170 piksel yaptık
|
10 |
+
img = np.array(img) / 255.0 # Normalize ettik
|
11 |
+
img = np.expand_dims(img, axis=0) # 0. ortada olsun diye sayfada
|
12 |
|
13 |
+
st.title('Kanser Resmi sınıflandırma :cancer:')
|
14 |
+
img_file = st.file_uploader('Bir Resim Seç', type=['jpeg', 'png'])
|
|
|
|
|
15 |
|
16 |
+
if img_file is not None:
|
17 |
+
img = Image.open(img_file)
|
18 |
+
st.image(img, caption='Yüklenen resim')
|
19 |
+
prediction = model.predict(img)
|
|
|
|
|
20 |
|
21 |
+
st.title('Kanser Resmi Sınıflandırma :cancer:')
|
22 |
+
st.write('Resim seç ve model kanser olup olmadığını tahmin etsin.')
|
23 |
|
24 |
+
file = st.file_uploader('Bir Resim Seç', type=['jpg', 'jpeg', 'png'])
|
|
|
|
|
|
|
25 |
|
26 |
+
if file is not None:
|
27 |
+
img = Image.open(file)
|
28 |
+
st.image(img, caption='Yüklenen resim')
|
29 |
+
image = process_image(img)
|
30 |
+
prediction = model.predict(image)
|
31 |
+
predicted_class = np.argmax(prediction)
|
32 |
|
33 |
+
class_names = ['Kanser Değil', 'Kanser']
|
34 |
+
st.write(class_names[predicted_class])
|