Spaces:
Sleeping
Sleeping
| 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.") | |