Spaces:
Sleeping
Sleeping
File size: 1,271 Bytes
c81843f 525ca80 df8ab40 4442f21 700c6dd 742616f 525ca80 4442f21 525ca80 700c6dd 4442f21 700c6dd df8ab40 700c6dd 4442f21 bba6430 4442f21 525ca80 4442f21 700c6dd df8ab40 700c6dd df8ab40 742616f 700c6dd df8ab40 742616f 60b2898 700c6dd 742616f 700c6dd 4442f21 742616f | 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 import keras
from PIL import Image
import numpy as np
from pathlib import Path
# Model dosyası ana klasörde olduğu için:
# /app/skin_cancer_model.keras
MODEL_PATH = Path(__file__).resolve().parent.parent / "skin_cancer_model.keras"
@st.cache_resource
def load_skin_model():
return keras.models.load_model(str(MODEL_PATH), compile=False)
model = load_skin_model()
def process_image(img):
img = img.convert("RGB")
img = img.resize((170, 170))
img = np.array(img)
img = img / 255.0
img = np.expand_dims(img, axis=0)
return img
st.title("Deri Kanser Resmi Sınıflandırma")
st.write("Resim seç, model kanser olup olmadığını tahmin etsin.")
file = st.file_uploader(
"Bir resim yükle",
type=["jpg", "jpeg", "png", "JPG", "JPEG", "PNG"]
)
if file is not None:
img = Image.open(file)
st.image(img, caption="Yüklenen Resim", use_container_width=True)
image = process_image(img)
prediction = model.predict(image)
probability = float(prediction[0][0])
predicted_class = 1 if probability > 0.5 else 0
class_names = ["Kanser değil", "Kanser"]
st.write("Tahmin:", class_names[predicted_class])
st.write("Olasılık:", round(probability, 4)) |