Arghya Ghosh commited on
Commit
215eae2
·
verified ·
1 Parent(s): 1988808

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -48,7 +48,7 @@ def load_model_and_data():
48
  cache_folder='/tmp/huggingface'
49
  )
50
 
51
- # Load files from Hugging Face Hub with progress
52
  with st.spinner("Loading movie data..."):
53
  csv_path = hf_hub_download(
54
  repo_id=REPO_ID,
@@ -112,24 +112,24 @@ if query:
112
  results = semantic_search(query)
113
 
114
  if not results.empty:
115
- # Filter out movies without a release date
116
- results = results[pd.notnull(results["release_date"])].reset_index(drop=True)
117
-
118
- if results.empty:
119
- st.warning("No results with valid release dates found.")
120
- else:
121
- st.subheader(f"🔝 Top {len(results)} similar movies:")
122
-
123
- cols = st.columns(3)
124
- for idx, (_, row) in enumerate(results.iterrows()):
125
- with cols[idx % 3]:
126
- st.image(
127
- row["poster_url"],
128
- width=200,
129
- caption=f"{row['title']} ({row['release_date'][:4]})"
130
- )
131
- with st.expander(f"Similarity: {row['similarity']:.2f}"):
132
- st.write(row['overview'])
133
  else:
134
  st.warning("No results found. Try a different query.")
135
 
 
48
  cache_folder='/tmp/huggingface'
49
  )
50
 
51
+ # Load files from Hugging Face Hub
52
  with st.spinner("Loading movie data..."):
53
  csv_path = hf_hub_download(
54
  repo_id=REPO_ID,
 
112
  results = semantic_search(query)
113
 
114
  if not results.empty:
115
+ # Remove entries without release dates
116
+ results = results[pd.notnull(results["release_date"])].reset_index(drop=True)
117
+
118
+ if results.empty:
119
+ st.warning("No results with valid release dates found.")
120
+ else:
121
+ st.subheader(f"🔝 Top {len(results)} similar movies:")
122
+
123
+ cols = st.columns(3)
124
+ for idx, (_, row) in enumerate(results.iterrows()):
125
+ with cols[idx % 3]:
126
+ st.image(
127
+ row["poster_url"],
128
+ width=200,
129
+ caption=f"{row['title']} ({row['release_date'][:4]})"
130
+ )
131
+ with st.expander(f"Similarity: {row['similarity']:.2f}"):
132
+ st.write(row['overview'])
133
  else:
134
  st.warning("No results found. Try a different query.")
135