Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,14 +4,14 @@ import numpy as np
|
|
| 4 |
import os
|
| 5 |
import warnings
|
| 6 |
|
| 7 |
-
# --- 1. SİNSİ HATALARI SUSTUR / SILENCE ERRORS
|
| 8 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
| 9 |
warnings.filterwarnings('ignore')
|
| 10 |
|
| 11 |
# --- 2. SAYFA AYARLARI / PAGE CONFIG ---
|
| 12 |
st.set_page_config(page_title="Car Logo AI Pro 2026", layout="wide", page_icon="🚗")
|
| 13 |
|
| 14 |
-
# --- 3. VERİ SETİNİ BELLEĞE YÜKLE / LOAD DATASET
|
| 15 |
@st.cache_resource
|
| 16 |
def load_car_dataset(base_path):
|
| 17 |
dataset = []
|
|
@@ -47,33 +47,34 @@ def process_uploaded_image(file_bytes):
|
|
| 47 |
st.title("🚗 Araba Logosu Tanıma Sistemi / Car Logo Recognition")
|
| 48 |
st.markdown("---")
|
| 49 |
|
| 50 |
-
# İki ana sütun oluşturuyoruz
|
| 51 |
col_left, col_right = st.columns([1, 1], gap="large")
|
| 52 |
|
| 53 |
with col_left:
|
| 54 |
st.subheader("📤 Yükleme Alanı / Upload Area")
|
| 55 |
|
| 56 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
uploaded_file = st.file_uploader(
|
| 58 |
"Yeni bir logo seçin / Select a new logo",
|
| 59 |
type=['jpg', 'png', 'jpeg'],
|
| 60 |
-
key="main_uploader"
|
|
|
|
| 61 |
)
|
| 62 |
|
| 63 |
-
st.markdown("---")
|
| 64 |
|
| 65 |
if uploaded_file:
|
| 66 |
-
# Resmi işle (Önbellekten gelir, titreme yapmaz)
|
| 67 |
raw_img, gray_img, edge_img = process_uploaded_image(uploaded_file.getvalue())
|
| 68 |
-
|
| 69 |
-
# Seçilen resmin önizlemesi (Yükleme kutusunun altında)
|
| 70 |
st.write("🖼️ **Seçilen Logo / Selected Logo:**")
|
| 71 |
st.image(raw_img, channels="BGR", width=400)
|
| 72 |
|
| 73 |
with col_right:
|
| 74 |
st.subheader("🎯 Analiz ve Sonuç / Analysis & Result")
|
| 75 |
-
|
| 76 |
-
# Hassasiyet Ayarı (Yan panel yerine burada daha erişilebilir)
|
| 77 |
threshold = st.slider("Hassasiyet / Sensitivity", 0.0, 1.0, 0.20)
|
| 78 |
|
| 79 |
if uploaded_file:
|
|
@@ -90,11 +91,8 @@ with col_right:
|
|
| 90 |
best_score = max_val
|
| 91 |
best_path = path
|
| 92 |
|
| 93 |
-
# SONUÇLARI GÖSTER
|
| 94 |
if best_path and best_score >= threshold:
|
| 95 |
st.balloons()
|
| 96 |
-
|
| 97 |
-
# Dosya yolundan marka adını ayıkla
|
| 98 |
folder_name = os.path.basename(os.path.dirname(best_path))
|
| 99 |
if not folder_name or folder_name == '.':
|
| 100 |
folder_name = os.path.basename(best_path).split('.')[0]
|
|
@@ -107,32 +105,20 @@ with col_right:
|
|
| 107 |
else:
|
| 108 |
st.error("❌ Eşleşme Bulunamadı / Match Not Found")
|
| 109 |
else:
|
| 110 |
-
st.info("Lütfen soldaki panelden bir logo yükleyerek başlayın.
|
| 111 |
|
| 112 |
-
# --- 6. TEKNİK ANALİZ
|
| 113 |
if uploaded_file:
|
| 114 |
st.markdown("---")
|
| 115 |
with st.expander("🔍 Teknik Detaylar / Technical Details"):
|
| 116 |
tab_tr, tab_en = st.tabs(["🇹🇷 Türkçe", "🇺🇸 English"])
|
| 117 |
-
|
| 118 |
with tab_tr:
|
| 119 |
st.write("### Görüntü İşleme Aşamaları")
|
| 120 |
c1, c2 = st.columns(2)
|
| 121 |
c1.image(edge_img, width=300, caption="Canny Kenar Analizi")
|
| 122 |
c2.image(cv2.resize(gray_img, (100, 100)), caption="Sistemin Gördüğü (100x100)")
|
| 123 |
-
st.info(f"Sistem şu an {len(dataset)} farklı referans resim üzerinden karşılaştırma yapıyor.")
|
| 124 |
-
|
| 125 |
with tab_en:
|
| 126 |
st.write("### Image Processing Stages")
|
| 127 |
ce1, ce2 = st.columns(2)
|
| 128 |
ce1.image(edge_img, width=300, caption="Canny Edge Detection")
|
| 129 |
-
ce2.image(cv2.resize(gray_img, (100, 100)), caption="AI View (100x100)")
|
| 130 |
-
st.info(f"The system is currently comparing through {len(dataset)} different reference images.")
|
| 131 |
-
|
| 132 |
-
# Stil Ayarları
|
| 133 |
-
st.markdown("""
|
| 134 |
-
<style>
|
| 135 |
-
.stButton>button { font-weight: bold; margin-top: 10px; }
|
| 136 |
-
.stMetric { background: #f8f9fa; border-radius: 10px; padding: 10px; border: 1px solid #ddd; }
|
| 137 |
-
</style>
|
| 138 |
-
""", unsafe_allow_html=True)
|
|
|
|
| 4 |
import os
|
| 5 |
import warnings
|
| 6 |
|
| 7 |
+
# --- 1. SİNSİ HATALARI SUSTUR / SILENCE ERRORS ---
|
| 8 |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
| 9 |
warnings.filterwarnings('ignore')
|
| 10 |
|
| 11 |
# --- 2. SAYFA AYARLARI / PAGE CONFIG ---
|
| 12 |
st.set_page_config(page_title="Car Logo AI Pro 2026", layout="wide", page_icon="🚗")
|
| 13 |
|
| 14 |
+
# --- 3. VERİ SETİNİ BELLEĞE YÜKLE / LOAD DATASET ---
|
| 15 |
@st.cache_resource
|
| 16 |
def load_car_dataset(base_path):
|
| 17 |
dataset = []
|
|
|
|
| 47 |
st.title("🚗 Araba Logosu Tanıma Sistemi / Car Logo Recognition")
|
| 48 |
st.markdown("---")
|
| 49 |
|
|
|
|
| 50 |
col_left, col_right = st.columns([1, 1], gap="large")
|
| 51 |
|
| 52 |
with col_left:
|
| 53 |
st.subheader("📤 Yükleme Alanı / Upload Area")
|
| 54 |
|
| 55 |
+
# İSTEDİĞİN ÖZEL YAZIYI BURAYA EKLEDİK
|
| 56 |
+
st.markdown("""
|
| 57 |
+
<div style="color: #555; font-size: 0.9em; margin-bottom: -15px;">
|
| 58 |
+
200MB per file • JPG, PNG, JPEG
|
| 59 |
+
</div>
|
| 60 |
+
""", unsafe_allow_html=True)
|
| 61 |
+
|
| 62 |
uploaded_file = st.file_uploader(
|
| 63 |
"Yeni bir logo seçin / Select a new logo",
|
| 64 |
type=['jpg', 'png', 'jpeg'],
|
| 65 |
+
key="main_uploader",
|
| 66 |
+
label_visibility="visible"
|
| 67 |
)
|
| 68 |
|
| 69 |
+
st.markdown("---")
|
| 70 |
|
| 71 |
if uploaded_file:
|
|
|
|
| 72 |
raw_img, gray_img, edge_img = process_uploaded_image(uploaded_file.getvalue())
|
|
|
|
|
|
|
| 73 |
st.write("🖼️ **Seçilen Logo / Selected Logo:**")
|
| 74 |
st.image(raw_img, channels="BGR", width=400)
|
| 75 |
|
| 76 |
with col_right:
|
| 77 |
st.subheader("🎯 Analiz ve Sonuç / Analysis & Result")
|
|
|
|
|
|
|
| 78 |
threshold = st.slider("Hassasiyet / Sensitivity", 0.0, 1.0, 0.20)
|
| 79 |
|
| 80 |
if uploaded_file:
|
|
|
|
| 91 |
best_score = max_val
|
| 92 |
best_path = path
|
| 93 |
|
|
|
|
| 94 |
if best_path and best_score >= threshold:
|
| 95 |
st.balloons()
|
|
|
|
|
|
|
| 96 |
folder_name = os.path.basename(os.path.dirname(best_path))
|
| 97 |
if not folder_name or folder_name == '.':
|
| 98 |
folder_name = os.path.basename(best_path).split('.')[0]
|
|
|
|
| 105 |
else:
|
| 106 |
st.error("❌ Eşleşme Bulunamadı / Match Not Found")
|
| 107 |
else:
|
| 108 |
+
st.info("Lütfen soldaki panelden bir logo yükleyerek başlayın.")
|
| 109 |
|
| 110 |
+
# --- 6. TEKNİK ANALİZ ---
|
| 111 |
if uploaded_file:
|
| 112 |
st.markdown("---")
|
| 113 |
with st.expander("🔍 Teknik Detaylar / Technical Details"):
|
| 114 |
tab_tr, tab_en = st.tabs(["🇹🇷 Türkçe", "🇺🇸 English"])
|
|
|
|
| 115 |
with tab_tr:
|
| 116 |
st.write("### Görüntü İşleme Aşamaları")
|
| 117 |
c1, c2 = st.columns(2)
|
| 118 |
c1.image(edge_img, width=300, caption="Canny Kenar Analizi")
|
| 119 |
c2.image(cv2.resize(gray_img, (100, 100)), caption="Sistemin Gördüğü (100x100)")
|
|
|
|
|
|
|
| 120 |
with tab_en:
|
| 121 |
st.write("### Image Processing Stages")
|
| 122 |
ce1, ce2 = st.columns(2)
|
| 123 |
ce1.image(edge_img, width=300, caption="Canny Edge Detection")
|
| 124 |
+
ce2.image(cv2.resize(gray_img, (100, 100)), caption="AI View (100x100)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|