Update app.py
Browse files68 unmodified lines697071727374757677787980818283847 unmodified lines929394959697989910010110210310410510610710810911011111211311411511611711811912012168 unmodified lines["Male / Erkek", "Female / Kadın"])# CRITICAL FIX: Filtrelemeyi klasörden değil, doğrudan ana veritabanından yapıyoruz.# Böylece resim klasörü okunmasa bile isimler kaybolmaz.filtered_names = [name for name, data in tum_unlu_verileri.items() if data['c'] == gender_choice]st.sidebar.markdown(f"### 📋 Available Cast / Mevcut Oyuncular")if not filtered_names:st.sidebar.warning("No players found.")else:for n in filtered_names:st.sidebar.write(f"• {n}")# --- ANA EKRAN ---st.title("🎬 CastMatch AI: Talent Matching System / Yetenek Eşleştirme Sistemi")7 unmodified linesselected_actor = st.selectbox("Select from list / Listeden seçin:", filtered_names if filtered_names else ["Yok"])if selected_actor != "Yok":resim_klasoru = os.path.join(os.getcwd(), "40 resim")found_path = None# Resim arama mantığını esnettikif os.path.exists(resim_klasoru):search_target = selected_actor.replace(" ", "_").lower()for f in os.listdir(resim_klasoru):if f.lower().startswith(search_target) or selected_actor.lower() in f.lower():found_path = os.path.join(resim_klasoru, f)breakif found_path:st.image(found_path, caption=f"Profile: {selected_actor}", use_container_width=True)else:# Resim yoksa isim kaybolmasın, sadece hata mesajı verilsinst.info(f"Resim dosyası '40 resim' klasöründe bulunamadı: {selected_actor}")with col_match:st.subheader("🎯 Best Career Matches / En İyi Kariyer Eşleşmeleri")st.write("Comparing the star's DNA with movie roles...")if st.button("🚀 Match and Recommend / Eşleştir ve Öner") and selected_actor != "Yok":if movie_dict:# Veriyi 'tum_unlu_verileri' üzerinden çekiyoruz (Daha güvenli)actor_v = tum_unlu_verileri[selected_actor]['v']results = []for i in movie_dict:68 unmodified lines6970717273747576777879807 unmodified lines88899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312468 unmodified lines["Male / Erkek", "Female / Kadın"])# Filtrelemefiltered_names = [name for name, data in tum_unlu_verileri.items() if data['c'] == gender_choice]st.sidebar.markdown(f"### 📋 Available Cast / Mevcut Oyuncular")for n in filtered_names:st.sidebar.write(f"• {n}")# --- ANA EKRAN ---st.title("🎬 CastMatch AI: Talent Matching System / Yetenek Eşleştirme Sistemi")7 unmodified linesselected_actor = st.selectbox("Select from list / Listeden seçin:", filtered_names if filtered_names else ["Yok"])if selected_actor != "Yok":# RESİM BULMA MOTORU (GELİŞMİŞ)# Klasör adını ve yolunu daha sağlam tanımlıyoruzbase_path = os.path.dirname(__file__) if "__file__" in locals() else os.getcwd()resim_klasoru = os.path.join(base_path, "40 resim")found_path = Noneif os.path.exists(resim_klasoru):dosyalar = os.listdir(resim_klasoru)# Arama stratejisi: Küçük harf yap, boşlukları alt tire yap veya olduğu gibi arasearch_name = selected_actor.lower()search_underscore = selected_actor.lower().replace(" ", "_")for f in dosyalar:f_lower = f.lower()if search_underscore in f_lower or search_name in f_lower:found_path = os.path.join(resim_klasoru, f)breakif found_path:st.image(found_path, caption=f"Profile: {selected_actor}", use_container_width=True)else:st.warning(f"⚠️ Resim dosyası '40 resim' klasöründe bulunamadı: {selected_actor}")st.info("İpucu: Dosya adının oyuncu ismiyle (Örn: sylvester_stallone.jpg) aynı olduğundan emin olun.")with col_match:st.subheader("🎯 Best Career Matches / En İyi Kariyer Eşleşmeleri")# TÜRKÇE ÇEVİRİ EKLENDİst.write("Comparing the star's DNA with movie roles... / Yıldızın DNA'sı film rolleriyle karşılaştırılıyor...")if st.button("🚀 Match and Recommend / Eşleştir ve Öner") and selected_actor != "Yok":if movie_dict:actor_v = tum_unlu_verileri[selected_actor]['v']results = []for i in movie_dict:
app.py+20-17