| import streamlit as st |
| from tensorflow.keras.models import load_model |
| from PIL import Image |
| import numpy as np |
|
|
| |
| model = load_model('src/my_cnn_model.h5') |
|
|
| class_names = ['Kanser Değil', 'Kanser'] |
|
|
| def process_image(img): |
| img = img.resize((170,170)) |
| img = np.array(img) / 255.0 |
| img = np.expand_dims(img, axis=0) |
| return img |
|
|
| st.title("🧬 Cilt Kanseri Sınıflandırıcı") |
| st.write("Bir cilt görseli yükleyin, model kanser olup olmadığını tahmin etsin.") |
|
|
| file = st.file_uploader('Bir resim seç', type=['jpg','jpeg','png']) |
|
|
| if file is not None: |
| img = Image.open(file).convert("RGB") |
| st.image(img, caption='Yüklenen Resim', use_container_width=True) |
| image = process_image(img) |
| prediction = model.predict(image) |
| predicted_class = np.argmax(prediction) |
| st.success(f"Tahmin: {class_names[predicted_class]}") |
|
|
| confidence = np.max(prediction) |
| st.success(f"Tahmin: {class_names[predicted_class]} ({confidence:.2%} güven)") |
|
|
|
|