Spaces:
Sleeping
Sleeping
datalarımı yükledim
Browse files- app2.py +55 -0
- my_skin_cancer_model2.h5 +3 -0
- requirements.txt +4 -0
app2.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
# Modeli yükleme
|
7 |
+
model = load_model('my_skin_cancer_model.h5')
|
8 |
+
|
9 |
+
def process_img(img):
|
10 |
+
img = img.resize((170, 170), Image.LANCZOS) # 170x170 piksel boyutuna dönüştürme, LANCZOS filtresi kullanılıyor
|
11 |
+
img = np.array(img) / 255.0 # Normalize etme
|
12 |
+
img = np.expand_dims(img, axis=0) # Resme boyut ekleme
|
13 |
+
return img
|
14 |
+
|
15 |
+
# Sayfa başlığı ve stili
|
16 |
+
st.markdown("""
|
17 |
+
<style>
|
18 |
+
.main {
|
19 |
+
background-color: #f5f5f5;
|
20 |
+
}
|
21 |
+
.title {
|
22 |
+
font-size: 36px;
|
23 |
+
font-weight: bold;
|
24 |
+
color: #4CAF50;
|
25 |
+
}
|
26 |
+
.subtitle {
|
27 |
+
font-size: 18px;
|
28 |
+
color: #555555;
|
29 |
+
}
|
30 |
+
.result {
|
31 |
+
font-size: 24px;
|
32 |
+
font-weight: bold;
|
33 |
+
color: #FF5722;
|
34 |
+
}
|
35 |
+
</style>
|
36 |
+
""", unsafe_allow_html=True)
|
37 |
+
|
38 |
+
st.markdown('<div class="title">Cilt Kanseri Resmini Sınıflandırılması</div>', unsafe_allow_html=True)
|
39 |
+
st.markdown('<div class="subtitle">Resim seç ve modelimiz kanser olup olmadığını kontrol etsin.<br>Upload an image and the model will predict if your image shows cancer or not.</div>', unsafe_allow_html=True)
|
40 |
+
|
41 |
+
file = st.file_uploader("Resim Yükle & Upload Image", type=['png', 'jpg', 'jpeg'])
|
42 |
+
|
43 |
+
if file is not None: # Resim boş değilse
|
44 |
+
img = Image.open(file) # Resmi açma
|
45 |
+
st.image(img, caption="Yüklenen Resim", use_column_width=True) # Seçilen resmi gösterme
|
46 |
+
|
47 |
+
result = process_img(img) # Fonksiyonla resim işleme, yani boyut değişecek ve işlenebilir hale getirilecek
|
48 |
+
prediction = model.predict(result)
|
49 |
+
prediction_class = np.argmax(prediction) # 0 veya 1 olarak tahmin edilen sınıf
|
50 |
+
|
51 |
+
class_names = ['Kanser Değil', 'Kanser!']
|
52 |
+
|
53 |
+
st.markdown(f'<div class="result">Sonuç: {class_names[prediction_class]}</div>', unsafe_allow_html=True)
|
54 |
+
else:
|
55 |
+
st.info("Lütfen bir resim yükleyin. / Please upload an image.")
|
my_skin_cancer_model2.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:44ece764fd5ad8cd34cb6522ae5652ed87d8bebcc25840b3841cc159b7df4876
|
3 |
+
size 72151864
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tensorflow
|
2 |
+
streamlit
|
3 |
+
PIL
|
4 |
+
numpy
|