ESMATUGBA commited on
Commit
9dea6af
·
verified ·
1 Parent(s): b36da3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -16,7 +16,7 @@ def load_data():
16
  model_data = load_data()
17
  movie_dict = model_data['movie_dict'] if model_data else {}
18
 
19
- # --- 2. OYUNCU DNA VERİTABANI (Hugging Face Listenle Tam Uyumlu) ---
20
  tum_unlu_verileri = {
21
  "Sylvester Stallone": {"c": "Male / Erkek", "v": [0.9, 0.2, 0.1, 0.1, 0.1, 0.8]},
22
  "Robert De Niro": {"c": "Male / Erkek", "v": [0.2, 0.1, 0.1, 0.9, 0.1, 0.8]},
@@ -54,7 +54,7 @@ tum_unlu_verileri = {
54
  # --- ARAYÜZ AYARLARI ---
55
  st.set_page_config(page_title="CastMatch AI", layout="wide")
56
 
57
- # CSS: Resim alanını sabitleyip titremeyi kesen stil
58
  st.markdown("""
59
  <style>
60
  [data-testid="stImage"] {
@@ -77,7 +77,6 @@ st.sidebar.title("🔍 Control Panel / Kontrol Paneli")
77
  st.sidebar.markdown("---")
78
  gender_choice = st.sidebar.radio("1. Select Category / Kategori Seçin:", ["Male / Erkek", "Female / Kadın"])
79
 
80
- # Hugging Face ana dizindeki gerçek dosyaları çek
81
  hf_files = os.listdir(".")
82
  filtered_names = [name for name in tum_unlu_verileri.keys() if tum_unlu_verileri[name]['c'] == gender_choice]
83
 
@@ -86,41 +85,40 @@ for n in filtered_names:
86
  st.sidebar.write(f"• {n}")
87
 
88
  # --- ANA EKRAN ---
89
- st.title("🎬 CastMatch AI: Talent Matching System")
90
  st.markdown("---")
91
 
92
  col_actor, col_match = st.columns([1, 2])
93
 
94
  with col_actor:
95
  st.subheader("👤 Pick an Actor / Oyuncu Seç")
96
- selected_actor = st.selectbox("Select from list:", ["Choose..."] + filtered_names)
 
97
 
98
- if selected_actor != "Choose...":
99
  found_path = None
100
- # Hugging Face'deki isimlendirme varyasyonlarını kontrol et
101
- search_underscore = selected_actor.replace(" ", "_").lower()
102
- search_plain = selected_actor.lower()
103
 
104
  for f in hf_files:
105
- f_lower = f.lower()
106
- if f_lower.endswith(('.jpg', '.png', '.jpeg')):
107
- # Sylvester Stallone.png veya Brad_Pitt.png gibi her durumu yakala
108
- if search_underscore in f_lower or search_plain in f_lower:
109
  found_path = f
110
  break
111
 
112
  if found_path:
113
  st.image(found_path, use_container_width=False)
114
  else:
115
- st.warning(f"Resim dosyası eşleşmedi: {selected_actor}")
116
  st.markdown('<div style="height: 300px;"></div>', unsafe_allow_html=True)
117
  else:
118
- st.markdown('<div style="height: 400px; display: flex; align-items: center; justify-content: center; color: #999; font-style: italic;">Select an actor to view profile</div>', unsafe_allow_html=True)
119
 
120
  with col_match:
121
- st.subheader("🎯 Best Career Matches")
 
122
 
123
- if st.button("🚀 Match and Recommend") and selected_actor != "Choose...":
124
  if movie_dict:
125
  actor_v = tum_unlu_verileri[selected_actor]['v']
126
  results = []
@@ -132,10 +130,12 @@ with col_match:
132
  top_matches = sorted(results, key=lambda x: x[1])[:5]
133
  for i, (film, score) in enumerate(top_matches, 1):
134
  pct = max(0, min(100, round((1 - score) * 100, 1)))
135
- st.success(f"**{i}. {film}** (%{pct})")
 
136
  st.progress(pct / 100)
137
  else:
138
- st.error("Model file missing!")
139
 
 
140
  st.markdown("---")
141
  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.")
 
16
  model_data = load_data()
17
  movie_dict = model_data['movie_dict'] if model_data else {}
18
 
19
+ # --- 2. OYUNCU DNA VERİTABANI ---
20
  tum_unlu_verileri = {
21
  "Sylvester Stallone": {"c": "Male / Erkek", "v": [0.9, 0.2, 0.1, 0.1, 0.1, 0.8]},
22
  "Robert De Niro": {"c": "Male / Erkek", "v": [0.2, 0.1, 0.1, 0.9, 0.1, 0.8]},
 
54
  # --- ARAYÜZ AYARLARI ---
55
  st.set_page_config(page_title="CastMatch AI", layout="wide")
56
 
57
+ # CSS: Resim alanı sabitleme
58
  st.markdown("""
59
  <style>
60
  [data-testid="stImage"] {
 
77
  st.sidebar.markdown("---")
78
  gender_choice = st.sidebar.radio("1. Select Category / Kategori Seçin:", ["Male / Erkek", "Female / Kadın"])
79
 
 
80
  hf_files = os.listdir(".")
81
  filtered_names = [name for name in tum_unlu_verileri.keys() if tum_unlu_verileri[name]['c'] == gender_choice]
82
 
 
85
  st.sidebar.write(f"• {n}")
86
 
87
  # --- ANA EKRAN ---
88
+ st.title("🎬 CastMatch AI: Talent Matching System / Yetenek Eşleştirme Sistemi")
89
  st.markdown("---")
90
 
91
  col_actor, col_match = st.columns([1, 2])
92
 
93
  with col_actor:
94
  st.subheader("👤 Pick an Actor / Oyuncu Seç")
95
+ # SEÇİM KUTUSU GÜNCELLENDİ
96
+ selected_actor = st.selectbox("Select from list / Listeden seçin:", ["Choose... / Seçiniz..."] + filtered_names)
97
 
98
+ if selected_actor != "Choose... / Seçiniz...":
99
  found_path = None
100
+ search_target = selected_actor.lower()
 
 
101
 
102
  for f in hf_files:
103
+ if f.lower().endswith(('.jpg', '.png', '.jpeg')):
104
+ # Akıllı isim eşleştirme (Boşlukları ve alt tireleri denetler)
105
+ if selected_actor.replace(" ", "_").lower() in f.lower() or selected_actor.replace(" ", " ").lower() in f.lower():
 
106
  found_path = f
107
  break
108
 
109
  if found_path:
110
  st.image(found_path, use_container_width=False)
111
  else:
112
+ st.warning(f"Image not found / Resim bulunamadı: {selected_actor}")
113
  st.markdown('<div style="height: 300px;"></div>', unsafe_allow_html=True)
114
  else:
115
+ st.markdown('<div style="height: 400px; display: flex; align-items: center; justify-content: center; color: #999; font-style: italic;">Select an actor to view profile / Profil görmek için oyuncu seçin</div>', unsafe_allow_html=True)
116
 
117
  with col_match:
118
+ # BAŞLIK GÜNCELLENDİ
119
+ st.subheader("🎯 Best Career Matches / En İyi Kariyer Eşleşmeleri")
120
 
121
+ if st.button("🚀 Match and Recommend / Eşleştir ve Öner") and selected_actor != "Choose... / Seçiniz...":
122
  if movie_dict:
123
  actor_v = tum_unlu_verileri[selected_actor]['v']
124
  results = []
 
130
  top_matches = sorted(results, key=lambda x: x[1])[:5]
131
  for i, (film, score) in enumerate(top_matches, 1):
132
  pct = max(0, min(100, round((1 - score) * 100, 1)))
133
+ st.success(f"**{i}. {film}**")
134
+ st.write(f"Match Score / Uyum Skoru: **%{pct}**")
135
  st.progress(pct / 100)
136
  else:
137
+ st.error("Model file missing! / Model dosyası eksik!")
138
 
139
+ # --- ALT BİLGİ ---
140
  st.markdown("---")
141
  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.")