Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,14 @@ st.markdown("""
|
|
| 12 |
max-height: 400px;
|
| 13 |
object-fit: contain;
|
| 14 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
</style>
|
| 16 |
""", unsafe_allow_html=True)
|
| 17 |
|
|
@@ -84,6 +92,10 @@ def klasordeki_unluleri_getir():
|
|
| 84 |
|
| 85 |
unlu_verileri = klasordeki_unluleri_getir()
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
# --- SOL PANEL (SIDEBAR) ---
|
| 88 |
st.sidebar.title("🔍 Control Panel / Kontrol Paneli")
|
| 89 |
st.sidebar.markdown("---")
|
|
@@ -97,10 +109,12 @@ gender_choice = st.sidebar.radio(
|
|
| 97 |
filtered_names = [name for name, data in unlu_verileri.items() if data['c'] == gender_choice]
|
| 98 |
|
| 99 |
st.sidebar.markdown(f"### 📋 Available Cast / Mevcut Oyuncular")
|
| 100 |
-
|
| 101 |
-
|
|
|
|
| 102 |
for n in filtered_names:
|
| 103 |
-
st.sidebar.
|
|
|
|
| 104 |
|
| 105 |
# --- ANA EKRAN ---
|
| 106 |
st.title("🎬 CastMatch AI: Talent Matching System / Yetenek Eşleştirme Sistemi")
|
|
@@ -111,26 +125,33 @@ col_actor, col_match = st.columns([1, 2])
|
|
| 111 |
|
| 112 |
with col_actor:
|
| 113 |
st.subheader("👤 Pick an Actor / Oyuncu Seç")
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
selected_actor = st.selectbox(
|
| 116 |
"Select from list / Listeden seçin:",
|
| 117 |
filtered_names if filtered_names else [],
|
| 118 |
-
index=None,
|
| 119 |
placeholder="Choose an actor... / Bir oyuncu seçin...",
|
| 120 |
-
key="
|
| 121 |
)
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
with st.container():
|
| 124 |
-
|
|
|
|
| 125 |
found_path = None
|
| 126 |
-
search_target =
|
| 127 |
for f in os.listdir(resim_klasoru):
|
| 128 |
-
if f.lower().startswith(search_target) or
|
| 129 |
found_path = os.path.join(resim_klasoru, f)
|
| 130 |
break
|
| 131 |
|
| 132 |
if found_path:
|
| 133 |
-
st.image(found_path, caption=f"Profile / Profil: {
|
| 134 |
else:
|
| 135 |
st.error("Image could not be loaded. / Resim yüklenemedi.")
|
| 136 |
else:
|
|
@@ -139,12 +160,13 @@ with col_actor:
|
|
| 139 |
with col_match:
|
| 140 |
st.subheader("🎯 Best Career Matches / En İyi Kariyer Eşleşmeleri")
|
| 141 |
|
| 142 |
-
if selected_actor:
|
| 143 |
-
|
|
|
|
| 144 |
|
| 145 |
if st.button("🚀 Match and Recommend / Eşleştir ve Öner", key="match_button"):
|
| 146 |
if movie_dict:
|
| 147 |
-
actor_v = unlu_verileri[
|
| 148 |
results = []
|
| 149 |
for i in movie_dict:
|
| 150 |
noise = random.uniform(0, 0.0001)
|
|
|
|
| 12 |
max-height: 400px;
|
| 13 |
object-fit: contain;
|
| 14 |
}
|
| 15 |
+
/* Sidebar butonlarını daha şık yapalım */
|
| 16 |
+
.stButton button {
|
| 17 |
+
width: 100%;
|
| 18 |
+
text-align: left;
|
| 19 |
+
border: none;
|
| 20 |
+
background-color: transparent;
|
| 21 |
+
padding: 5px;
|
| 22 |
+
}
|
| 23 |
</style>
|
| 24 |
""", unsafe_allow_html=True)
|
| 25 |
|
|
|
|
| 92 |
|
| 93 |
unlu_verileri = klasordeki_unluleri_getir()
|
| 94 |
|
| 95 |
+
# --- SESSION STATE (Seçimi Takip Etmek İçin) ---
|
| 96 |
+
if 'selected_actor' not in st.session_state:
|
| 97 |
+
st.session_state.selected_actor = None
|
| 98 |
+
|
| 99 |
# --- SOL PANEL (SIDEBAR) ---
|
| 100 |
st.sidebar.title("🔍 Control Panel / Kontrol Paneli")
|
| 101 |
st.sidebar.markdown("---")
|
|
|
|
| 109 |
filtered_names = [name for name, data in unlu_verileri.items() if data['c'] == gender_choice]
|
| 110 |
|
| 111 |
st.sidebar.markdown(f"### 📋 Available Cast / Mevcut Oyuncular")
|
| 112 |
+
st.sidebar.caption("Click a name to select / Seçmek için isme tıklayın")
|
| 113 |
+
|
| 114 |
+
# Sol taraftaki isimleri tıklanabilir butonlar yapıyoruz
|
| 115 |
for n in filtered_names:
|
| 116 |
+
if st.sidebar.button(f"👤 {n}", key=f"btn_{n}"):
|
| 117 |
+
st.session_state.selected_actor = n
|
| 118 |
|
| 119 |
# --- ANA EKRAN ---
|
| 120 |
st.title("🎬 CastMatch AI: Talent Matching System / Yetenek Eşleştirme Sistemi")
|
|
|
|
| 125 |
|
| 126 |
with col_actor:
|
| 127 |
st.subheader("👤 Pick an Actor / Oyuncu Seç")
|
| 128 |
+
|
| 129 |
+
# Seçim kutusu artık session_state ile senkronize çalışıyor
|
| 130 |
+
# Eğer sidebar'dan tıklanırsa bu kutu da güncellenir
|
| 131 |
selected_actor = st.selectbox(
|
| 132 |
"Select from list / Listeden seçin:",
|
| 133 |
filtered_names if filtered_names else [],
|
| 134 |
+
index=filtered_names.index(st.session_state.selected_actor) if st.session_state.selected_actor in filtered_names else None,
|
| 135 |
placeholder="Choose an actor... / Bir oyuncu seçin...",
|
| 136 |
+
key="actor_select_box"
|
| 137 |
)
|
| 138 |
|
| 139 |
+
# Kutu üzerinden manuel seçim yapılırsa state'i güncelle
|
| 140 |
+
if selected_actor != st.session_state.selected_actor:
|
| 141 |
+
st.session_state.selected_actor = selected_actor
|
| 142 |
+
|
| 143 |
with st.container():
|
| 144 |
+
current_actor = st.session_state.selected_actor
|
| 145 |
+
if current_actor:
|
| 146 |
found_path = None
|
| 147 |
+
search_target = current_actor.replace(" ", "_").lower()
|
| 148 |
for f in os.listdir(resim_klasoru):
|
| 149 |
+
if f.lower().startswith(search_target) or current_actor.lower() in f.lower():
|
| 150 |
found_path = os.path.join(resim_klasoru, f)
|
| 151 |
break
|
| 152 |
|
| 153 |
if found_path:
|
| 154 |
+
st.image(found_path, caption=f"Profile / Profil: {current_actor}", use_container_width=True)
|
| 155 |
else:
|
| 156 |
st.error("Image could not be loaded. / Resim yüklenemedi.")
|
| 157 |
else:
|
|
|
|
| 160 |
with col_match:
|
| 161 |
st.subheader("🎯 Best Career Matches / En İyi Kariyer Eşleşmeleri")
|
| 162 |
|
| 163 |
+
if st.session_state.selected_actor:
|
| 164 |
+
current_actor = st.session_state.selected_actor
|
| 165 |
+
st.write(f"Comparing {current_actor}'s DNA with roles... / {current_actor} için DNA rolleriyle karşılaştırılıyor...")
|
| 166 |
|
| 167 |
if st.button("🚀 Match and Recommend / Eşleştir ve Öner", key="match_button"):
|
| 168 |
if movie_dict:
|
| 169 |
+
actor_v = unlu_verileri[current_actor]['v']
|
| 170 |
results = []
|
| 171 |
for i in movie_dict:
|
| 172 |
noise = random.uniform(0, 0.0001)
|