Update app.py
Browse files
app.py
CHANGED
|
@@ -78,69 +78,69 @@ def get_image_path(actor_name):
|
|
| 78 |
# --- SOL PANEL ---
|
| 79 |
st.sidebar.title("🔍 Control Panel / Kontrol Paneli")
|
| 80 |
st.sidebar.markdown("---")
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
filtered_names = [name for name, data in tum_unlu_verileri.items() if data['c'] == gender_choice]
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
# --- ANA EKRAN ---
|
| 85 |
st.title("🎬 CastMatch AI: Talent Matching System / Yetenek Eşleştirme Sistemi")
|
| 86 |
-
st.markdown("#### Discover the perfect roles for global stars!")
|
| 87 |
st.markdown("---")
|
| 88 |
|
| 89 |
col_actor, col_match = st.columns([1, 2])
|
| 90 |
|
| 91 |
with col_actor:
|
| 92 |
st.subheader("👤 Pick an Actor / Oyuncu Seç")
|
|
|
|
|
|
|
| 93 |
options = ["Choose... / Seçiniz..."] + filtered_names
|
| 94 |
-
selected_actor = st.selectbox("Select from list:", options)
|
|
|
|
| 95 |
image_placeholder = st.empty()
|
| 96 |
|
|
|
|
| 97 |
if selected_actor != "Choose... / Seçiniz...":
|
| 98 |
found_path = get_image_path(selected_actor)
|
| 99 |
if found_path:
|
| 100 |
image_placeholder.image(found_path, caption=f"Profile: {selected_actor}", use_container_width=True)
|
| 101 |
else:
|
| 102 |
-
image_placeholder.warning(f"⚠️
|
| 103 |
else:
|
| 104 |
-
|
|
|
|
| 105 |
|
| 106 |
with col_match:
|
| 107 |
-
st.subheader("🎯 Best Career Matches")
|
| 108 |
st.write("Comparing the star's DNA with movie roles... / Yıldızın DNA'sı film rolleriyle karşılaştırılıyor...")
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
| 112 |
actor_v = tum_unlu_verileri[selected_actor]['v']
|
| 113 |
results = []
|
| 114 |
-
|
| 115 |
for i in movie_dict:
|
| 116 |
-
movie_name = movie_dict[i][0]
|
| 117 |
-
movie_vector = movie_dict[i][1][:6]
|
| 118 |
-
|
| 119 |
-
# Standart mesafe
|
| 120 |
-
dist = spatial.distance.cosine(actor_v, movie_vector)
|
| 121 |
-
|
| 122 |
-
# --- STALLONE İÇİN ÖZEL AYAR ---
|
| 123 |
-
if selected_actor == "Sylvester Stallone":
|
| 124 |
-
if "terminator" in movie_name.lower():
|
| 125 |
-
dist = 0.05 # Terminator'ü çok yakın yap (%95 uyum gibi)
|
| 126 |
-
elif "titanic" in movie_name.lower():
|
| 127 |
-
dist = 0.85 # Titanic'i çok uzak yap (%15 uyum gibi)
|
| 128 |
-
|
| 129 |
-
# Titreme olmasın diye minik bir gürültü
|
| 130 |
noise = random.uniform(0, 0.0001)
|
| 131 |
-
|
|
|
|
| 132 |
|
| 133 |
-
# Mesafeye göre sırala (en düşük mesafe en iyi uyumdur)
|
| 134 |
top_matches = sorted(results, key=lambda x: x[1])[:5]
|
| 135 |
-
|
| 136 |
for i, (film, score) in enumerate(top_matches, 1):
|
| 137 |
-
# Skoru %'ye çevir: (1 - mesafe) * 100
|
| 138 |
pct = round((1 - score) * 100, 1)
|
| 139 |
-
# %100'ü geçmesin veya %0'ın altına inmesin
|
| 140 |
-
pct = max(0, min(100, pct))
|
| 141 |
-
|
| 142 |
st.success(f"**{i}. {film}**")
|
| 143 |
st.write(f"Match Score / Uyum Skoru: **%{pct}**")
|
| 144 |
st.progress(pct / 100)
|
| 145 |
else:
|
| 146 |
-
st.error("Model
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
# --- SOL PANEL ---
|
| 79 |
st.sidebar.title("🔍 Control Panel / Kontrol Paneli")
|
| 80 |
st.sidebar.markdown("---")
|
| 81 |
+
|
| 82 |
+
gender_choice = st.sidebar.radio(
|
| 83 |
+
"1. Select Category / Kategori Seçin:",
|
| 84 |
+
["Male / Erkek", "Female / Kadın"]
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
# Sidebar'daki oyuncu listesi (Bilgilendirme amaçlı)
|
| 88 |
filtered_names = [name for name, data in tum_unlu_verileri.items() if data['c'] == gender_choice]
|
| 89 |
+
st.sidebar.markdown(f"### 📋 Available Cast / Mevcut Oyuncular")
|
| 90 |
+
for n in filtered_names:
|
| 91 |
+
st.sidebar.write(f"• {n}")
|
| 92 |
|
| 93 |
# --- ANA EKRAN ---
|
| 94 |
st.title("🎬 CastMatch AI: Talent Matching System / Yetenek Eşleştirme Sistemi")
|
| 95 |
+
st.markdown("#### Discover the perfect roles for global stars! / Dünya yıldızları için en ideal rolleri keşfedin!")
|
| 96 |
st.markdown("---")
|
| 97 |
|
| 98 |
col_actor, col_match = st.columns([1, 2])
|
| 99 |
|
| 100 |
with col_actor:
|
| 101 |
st.subheader("👤 Pick an Actor / Oyuncu Seç")
|
| 102 |
+
|
| 103 |
+
# Seçeneklerin en başına boş bir seçenek ekliyoruz (index=0 varsayılan olur)
|
| 104 |
options = ["Choose... / Seçiniz..."] + filtered_names
|
| 105 |
+
selected_actor = st.selectbox("Select from list / Listeden seçin:", options)
|
| 106 |
+
|
| 107 |
image_placeholder = st.empty()
|
| 108 |
|
| 109 |
+
# Eğer bir oyuncu seçilmişse (Seçiniz... değilse)
|
| 110 |
if selected_actor != "Choose... / Seçiniz...":
|
| 111 |
found_path = get_image_path(selected_actor)
|
| 112 |
if found_path:
|
| 113 |
image_placeholder.image(found_path, caption=f"Profile: {selected_actor}", use_container_width=True)
|
| 114 |
else:
|
| 115 |
+
image_placeholder.warning(f"⚠️ Resim bulunamadı: {selected_actor}")
|
| 116 |
else:
|
| 117 |
+
# Seçim yapılmadıysa açıklama göster
|
| 118 |
+
image_placeholder.info("Please select an actor to see the profile. / Profili görmek için bir oyuncu seçin.")
|
| 119 |
|
| 120 |
with col_match:
|
| 121 |
+
st.subheader("🎯 Best Career Matches / En İyi Kariyer Eşleşmeleri")
|
| 122 |
st.write("Comparing the star's DNA with movie roles... / Yıldızın DNA'sı film rolleriyle karşılaştırılıyor...")
|
| 123 |
|
| 124 |
+
# Sadece seçim yapıldığında buton çalışsın
|
| 125 |
+
if st.button("🚀 Match and Recommend / Eşleştir ve Öner"):
|
| 126 |
+
if selected_actor == "Choose... / Seçiniz...":
|
| 127 |
+
st.warning("Please pick an actor first! / Lütfen önce bir oyuncu seçin!")
|
| 128 |
+
elif movie_dict:
|
| 129 |
actor_v = tum_unlu_verileri[selected_actor]['v']
|
| 130 |
results = []
|
|
|
|
| 131 |
for i in movie_dict:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
noise = random.uniform(0, 0.0001)
|
| 133 |
+
dist = spatial.distance.cosine(actor_v, movie_dict[i][1][:6]) + noise
|
| 134 |
+
results.append((movie_dict[i][0], dist))
|
| 135 |
|
|
|
|
| 136 |
top_matches = sorted(results, key=lambda x: x[1])[:5]
|
|
|
|
| 137 |
for i, (film, score) in enumerate(top_matches, 1):
|
|
|
|
| 138 |
pct = round((1 - score) * 100, 1)
|
|
|
|
|
|
|
|
|
|
| 139 |
st.success(f"**{i}. {film}**")
|
| 140 |
st.write(f"Match Score / Uyum Skoru: **%{pct}**")
|
| 141 |
st.progress(pct / 100)
|
| 142 |
else:
|
| 143 |
+
st.error("Model dosyası eksik!")
|
| 144 |
+
|
| 145 |
+
st.markdown("---")
|
| 146 |
+
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.")
|