| import streamlit as st |
| from tensorflow.keras.models import load_model |
| from PIL import Image |
| import numpy as np |
|
|
| |
| model = load_model('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.set_page_config(page_title="Cilt Kanseri Sınıflandırıcı") |
| st.title("🔬 Cilt Kanseri Sınıflandırma") |
| st.write("Bir cilt görseli yükleyin, model kanser olup olmadığını tahmin etsin.") |
|
|
| |
| file = st.file_uploader('📷 Resim Seç', type=['jpg', 'jpeg', 'png']) |
|
|
| if file is not None: |
| try: |
| img = Image.open(file).convert("RGB") |
| st.image(img, caption='Yüklenen Resim', use_container_width=True) |
| |
| |
| processed = process_image(img) |
| prediction = model.predict(processed) |
| predicted_class = int(np.argmax(prediction)) |
|
|
| |
| if predicted_class < len(class_names): |
| st.success(f"Tahmin: **{class_names[predicted_class]}**") |
| else: |
| st.warning("⚠️ Tahmin edilen sınıf geçersiz. Model veya sınıf isimleri uyuşmuyor.") |
| except Exception as e: |
| st.error(f"Bir hata oluştu: {e}") |
| confidence = float(np.max(prediction)) * 100 |
| st.write(f"🧠 Güven: %{confidence:.2f}") |
|
|