import streamlit as st import numpy as np import pandas as pd import tensorflow as tf from tensorflow.keras.models import load_model from PIL import Image import os from pathlib import Path # Dosya yolu file_path = Path('..') / 'model.h5' # Dosyanın varlığını kontrol et if file_path.exists(): print("File exists") # Modeli yükle model = load_model(file_path, compile=False) else: print("File not found") # Uygulamanın başlığı st.title("TGS Tuz Tanımlama Uygulaması") # Görüntü yükleme uploaded_file = st.file_uploader("Bir görüntü yükleyin", type=["png", "jpg", "jpeg"]) if uploaded_file is not None: # Yüklenen görüntüyü oku image = Image.open(uploaded_file).convert("L") # Gri tonlamaya çevir st.image(image, caption='Yüklenen Görüntü', use_column_width=True) # Görüntüyü modelin beklediği boyutlara getir image = image.resize((128, 128)) # Hedef boyut image_array = np.array(image) / 255.0 # Normalize et image_array = np.expand_dims(image_array, axis=0) # Boyutunu genişlet # Tahmin yap if st.button("Tahmin Et"): prediction = model.predict(image_array) prediction = (prediction > 0.5).astype(np.uint8) # Eşikleme st.image(prediction[0].squeeze(), caption='Tahmin Sonucu', use_column_width=True) # Kullanıcı için bilgi st.write("Bu uygulama, yeraltı hedefinin tuz olup olmadığını belirlemek için eğitilmiş bir model kullanır.")