File size: 1,930 Bytes
64dde49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import streamlit as st
from tensorflow.keras.models import load_model
from PIL import Image
import numpy as np

# Modeli yükleme
model = load_model('my_skin_cancer_model.h5')

def process_img(img):
    img = img.resize((170, 170), Image.LANCZOS)  # 170x170 piksel boyutuna dönüştürme, LANCZOS filtresi kullanılıyor
    img = np.array(img) / 255.0  # Normalize etme
    img = np.expand_dims(img, axis=0)  # Resme boyut ekleme
    return img

# Sayfa başlığı ve stili
st.markdown("""
    <style>
    .main {
        background-color: #f5f5f5;
    }
    .title {
        font-size: 36px;
        font-weight: bold;
        color: #4CAF50;
    }
    .subtitle {
        font-size: 18px;
        color: #555555;
    }
    .result {
        font-size: 24px;
        font-weight: bold;
        color: #FF5722;
    }
    </style>
""", unsafe_allow_html=True)

st.markdown('<div class="title">Cilt Kanseri Resmini Sınıflandırılması</div>', unsafe_allow_html=True)
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)

file = st.file_uploader("Resim Yükle & Upload Image", type=['png', 'jpg', 'jpeg'])

if file is not None:  # Resim boş değilse
    img = Image.open(file)  # Resmi açma
    st.image(img, caption="Yüklenen Resim", use_column_width=True)  # Seçilen resmi gösterme

    result = process_img(img)  # Fonksiyonla resim işleme, yani boyut değişecek ve işlenebilir hale getirilecek
    prediction = model.predict(result)
    prediction_class = np.argmax(prediction)  # 0 veya 1 olarak tahmin edilen sınıf

    class_names = ['Kanser Değil', 'Kanser!']

    st.markdown(f'<div class="result">Sonuç: {class_names[prediction_class]}</div>', unsafe_allow_html=True)
else:
    st.info("Lütfen bir resim yükleyin. / Please upload an image.")