File size: 1,522 Bytes
809906e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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.")