ESMATUGBA commited on
Commit
53c286f
·
verified ·
1 Parent(s): ad33872

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -25
app.py CHANGED
@@ -60,6 +60,19 @@ tum_unlu_verileri = {
60
  # --- ARAYÜZ AYARLARI ---
61
  st.set_page_config(page_title="CastMatch AI", layout="wide")
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  # --- SOL PANEL (SIDEBAR) ---
64
  st.sidebar.title("🔍 Control Panel / Kontrol Paneli")
65
  st.sidebar.markdown("---")
@@ -69,7 +82,6 @@ gender_choice = st.sidebar.radio(
69
  ["Male / Erkek", "Female / Kadın"]
70
  )
71
 
72
- # Filtreleme
73
  filtered_names = [name for name, data in tum_unlu_verileri.items() if data['c'] == gender_choice]
74
 
75
  st.sidebar.markdown(f"### 📋 Available Cast / Mevcut Oyuncular")
@@ -87,32 +99,18 @@ with col_actor:
87
  st.subheader("👤 Pick an Actor / Oyuncu Seç")
88
  selected_actor = st.selectbox("Select from list / Listeden seçin:", filtered_names if filtered_names else ["Yok"])
89
 
 
 
 
90
  if selected_actor != "Yok":
91
- # DOSYA BULUCU (HUGGING FACE ANA DİZİNİ İÇİN)
92
- ana_dizin = os.getcwd()
93
- found_path = None
94
-
95
- # Arama stratejisi: Dosya adında ismin geçip geçmediğine bakıyoruz
96
- search_term = selected_actor.lower().replace(" ", "_") # Robert_De_Niro gibi
97
- search_term_plain = selected_actor.lower() # Robert De Niro gibi
98
-
99
- for f in os.listdir(ana_dizin):
100
- f_lower = f.lower()
101
- # Eğer dosya bir resimse ve oyuncu ismini içeriyorsa
102
- if f_lower.endswith(('.jpg', '.png', '.jpeg')):
103
- if search_term in f_lower or search_term_plain in f_lower:
104
- found_path = os.path.join(ana_dizin, f)
105
- break
106
-
107
  if found_path:
108
- st.image(found_path, caption=f"Profile: {selected_actor}", use_container_width=True)
109
  else:
110
- st.warning(f"⚠️ Resim dosyası bulunamadı: {selected_actor}")
111
- st.info("İpucu: Hugging Face'e yüklediğiniz resim ismiyle listedeki isim eşleşmelidir.")
112
 
113
  with col_match:
114
  st.subheader("🎯 Best Career Matches / En İyi Kariyer Eşleşmeleri")
115
- # TÜRKÇE ÇEVİRİ EKLENDİ
116
  st.write("Comparing the star's DNA with movie roles... / Yıldızın DNA'sı film rolleriyle karşılaştırılıyor...")
117
 
118
  if st.button("🚀 Match and Recommend / Eşleştir ve Öner") and selected_actor != "Yok":
@@ -131,7 +129,4 @@ with col_match:
131
  st.write(f"Match Score / Uyum Skoru: **%{pct}**")
132
  st.progress(pct / 100)
133
  else:
134
- st.error("Model dosyası eksik! / movie_model.pkl dosyası bulunamadı!")
135
-
136
- st.markdown("---")
137
- st.info("💡 **How it works? / Nasıl çalışır?**: This AI analyzes career vectors based on available local assets. / Bu yapay zeka, mevcut yerel varlıklara (resimlere) dayanarak kariyer vektörlerini analiz eder.")
 
60
  # --- ARAYÜZ AYARLARI ---
61
  st.set_page_config(page_title="CastMatch AI", layout="wide")
62
 
63
+ # TİTREMEYİ ÖNLEYİCİ CACHE FONKSİYONU
64
+ @st.cache_data
65
+ def get_image_path(actor_name):
66
+ ana_dizin = os.getcwd()
67
+ search_term = actor_name.lower().replace(" ", "_")
68
+ search_term_plain = actor_name.lower()
69
+ for f in os.listdir(ana_dizin):
70
+ f_lower = f.lower()
71
+ if f_lower.endswith(('.jpg', '.png', '.jpeg')):
72
+ if search_term in f_lower or search_term_plain in f_lower:
73
+ return os.path.join(ana_dizin, f)
74
+ return None
75
+
76
  # --- SOL PANEL (SIDEBAR) ---
77
  st.sidebar.title("🔍 Control Panel / Kontrol Paneli")
78
  st.sidebar.markdown("---")
 
82
  ["Male / Erkek", "Female / Kadın"]
83
  )
84
 
 
85
  filtered_names = [name for name, data in tum_unlu_verileri.items() if data['c'] == gender_choice]
86
 
87
  st.sidebar.markdown(f"### 📋 Available Cast / Mevcut Oyuncular")
 
99
  st.subheader("👤 Pick an Actor / Oyuncu Seç")
100
  selected_actor = st.selectbox("Select from list / Listeden seçin:", filtered_names if filtered_names else ["Yok"])
101
 
102
+ # Resim Alanını Sabitle (Titremeyi Keser)
103
+ image_placeholder = st.empty()
104
+
105
  if selected_actor != "Yok":
106
+ found_path = get_image_path(selected_actor)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  if found_path:
108
+ image_placeholder.image(found_path, caption=f"Profile: {selected_actor}", use_container_width=True)
109
  else:
110
+ image_placeholder.warning(f"⚠️ Resim dosyası bulunamadı: {selected_actor}")
 
111
 
112
  with col_match:
113
  st.subheader("🎯 Best Career Matches / En İyi Kariyer Eşleşmeleri")
 
114
  st.write("Comparing the star's DNA with movie roles... / Yıldızın DNA'sı film rolleriyle karşılaştırılıyor...")
115
 
116
  if st.button("🚀 Match and Recommend / Eşleştir ve Öner") and selected_actor != "Yok":
 
129
  st.write(f"Match Score / Uyum Skoru: **%{pct}**")
130
  st.progress(pct / 100)
131
  else:
132
+ st.error("Model dosyası eksik!