Spaces:
Sleeping
Sleeping
Arghya Ghosh commited on
Update app.py
Browse files
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
|
| 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 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 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 |
|