Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
import pandas as pd
|
4 |
+
import tensorflow as tf
|
5 |
+
from tensorflow.keras.models import load_model
|
6 |
+
from PIL import Image
|
7 |
+
import os
|
8 |
+
from pathlib import Path
|
9 |
+
|
10 |
+
|
11 |
+
# Dosya yolu
|
12 |
+
file_path = Path('..') / 'model.h5'
|
13 |
+
|
14 |
+
# Dosyanın varlığını kontrol et
|
15 |
+
if file_path.exists():
|
16 |
+
print("File exists")
|
17 |
+
|
18 |
+
# Modeli yükle
|
19 |
+
model = load_model(file_path, compile=False)
|
20 |
+
else:
|
21 |
+
print("File not found")
|
22 |
+
|
23 |
+
# Uygulamanın başlığı
|
24 |
+
st.title("TGS Tuz Tanımlama Uygulaması")
|
25 |
+
|
26 |
+
# Görüntü yükleme
|
27 |
+
uploaded_file = st.file_uploader("Bir görüntü yükleyin", type=["png", "jpg", "jpeg"])
|
28 |
+
|
29 |
+
if uploaded_file is not None:
|
30 |
+
# Yüklenen görüntüyü oku
|
31 |
+
image = Image.open(uploaded_file).convert("L") # Gri tonlamaya çevir
|
32 |
+
st.image(image, caption='Yüklenen Görüntü', use_column_width=True)
|
33 |
+
|
34 |
+
# Görüntüyü modelin beklediği boyutlara getir
|
35 |
+
image = image.resize((128, 128)) # Hedef boyut
|
36 |
+
image_array = np.array(image) / 255.0 # Normalize et
|
37 |
+
image_array = np.expand_dims(image_array, axis=0) # Boyutunu genişlet
|
38 |
+
|
39 |
+
# Tahmin yap
|
40 |
+
if st.button("Tahmin Et"):
|
41 |
+
prediction = model.predict(image_array)
|
42 |
+
prediction = (prediction > 0.5).astype(np.uint8) # Eşikleme
|
43 |
+
st.image(prediction[0].squeeze(), caption='Tahmin Sonucu', use_column_width=True)
|
44 |
+
|
45 |
+
# Kullanıcı için bilgi
|
46 |
+
st.write("Bu uygulama, yeraltı hedefinin tuz olup olmadığını belirlemek için eğitilmiş bir model kullanır.")
|