ESMATUGBA commited on
Commit
e411c54
·
verified ·
1 Parent(s): e2ae4c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -17
app.py CHANGED
@@ -69,16 +69,12 @@ gender_choice = st.sidebar.radio(
69
  ["Male / Erkek", "Female / Kadın"]
70
  )
71
 
72
- # CRITICAL FIX: Filtrelemeyi klasörden değil, doğrudan ana veritabanından yapıyoruz.
73
- # Böylece resim klasörü okunmasa bile isimler kaybolmaz.
74
  filtered_names = [name for name, data in tum_unlu_verileri.items() if data['c'] == gender_choice]
75
 
76
  st.sidebar.markdown(f"### 📋 Available Cast / Mevcut Oyuncular")
77
- if not filtered_names:
78
- st.sidebar.warning("No players found.")
79
- else:
80
- for n in filtered_names:
81
- st.sidebar.write(f"• {n}")
82
 
83
  # --- ANA EKRAN ---
84
  st.title("🎬 CastMatch AI: Talent Matching System / Yetenek Eşleştirme Sistemi")
@@ -92,30 +88,37 @@ with col_actor:
92
  selected_actor = st.selectbox("Select from list / Listeden seçin:", filtered_names if filtered_names else ["Yok"])
93
 
94
  if selected_actor != "Yok":
95
- resim_klasoru = os.path.join(os.getcwd(), "40 resim")
96
- found_path = None
 
 
97
 
98
- # Resim arama mantığını esnettik
99
  if os.path.exists(resim_klasoru):
100
- search_target = selected_actor.replace(" ", "_").lower()
101
- for f in os.listdir(resim_klasoru):
102
- if f.lower().startswith(search_target) or selected_actor.lower() in f.lower():
 
 
 
 
 
103
  found_path = os.path.join(resim_klasoru, f)
104
  break
105
 
106
  if found_path:
107
  st.image(found_path, caption=f"Profile: {selected_actor}", use_container_width=True)
108
  else:
109
- # Resim yoksa isim kaybolmasın, sadece hata mesajı verilsin
110
- st.info(f"Resim dosyası '40 resim' klasöründe 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...")
 
115
 
116
  if st.button("🚀 Match and Recommend / Eşleştir ve Öner") and selected_actor != "Yok":
117
  if movie_dict:
118
- # Veriyi 'tum_unlu_verileri' üzerinden çekiyoruz (Daha güvenli)
119
  actor_v = tum_unlu_verileri[selected_actor]['v']
120
  results = []
121
  for i in movie_dict:
 
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")
76
+ for n in filtered_names:
77
+ st.sidebar.write(f" {n}")
 
 
 
78
 
79
  # --- ANA EKRAN ---
80
  st.title("🎬 CastMatch AI: Talent Matching System / Yetenek Eşleştirme Sistemi")
 
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
+ # RESİM BULMA MOTORU (GELİŞMİŞ)
92
+ # Klasör adını ve yolunu daha sağlam tanımlıyoruz
93
+ base_path = os.path.dirname(__file__) if "__file__" in locals() else os.getcwd()
94
+ resim_klasoru = os.path.join(base_path, "40 resim")
95
 
96
+ found_path = None
97
  if os.path.exists(resim_klasoru):
98
+ dosyalar = os.listdir(resim_klasoru)
99
+ # Arama stratejisi: Küçük harf yap, boşlukları alt tire yap veya olduğu gibi ara
100
+ search_name = selected_actor.lower()
101
+ search_underscore = selected_actor.lower().replace(" ", "_")
102
+
103
+ for f in dosyalar:
104
+ f_lower = f.lower()
105
+ if search_underscore in f_lower or search_name in f_lower:
106
  found_path = os.path.join(resim_klasoru, f)
107
  break
108
 
109
  if found_path:
110
  st.image(found_path, caption=f"Profile: {selected_actor}", use_container_width=True)
111
  else:
112
+ st.warning(f"⚠️ Resim dosyası '40 resim' klasöründe bulunamadı: {selected_actor}")
113
+ st.info("İpucu: Dosya adının oyuncu ismiyle (Örn: sylvester_stallone.jpg) aynı olduğundan emin olun.")
114
 
115
  with col_match:
116
  st.subheader("🎯 Best Career Matches / En İyi Kariyer Eşleşmeleri")
117
+ # TÜRKÇE ÇEVİRİ EKLENDİ
118
+ st.write("Comparing the star's DNA with movie roles... / Yıldızın DNA'sı film rolleriyle karşılaştırılıyor...")
119
 
120
  if st.button("🚀 Match and Recommend / Eşleştir ve Öner") and selected_actor != "Yok":
121
  if movie_dict:
 
122
  actor_v = tum_unlu_verileri[selected_actor]['v']
123
  results = []
124
  for i in movie_dict: