Spaces:
Sleeping
Sleeping
File size: 1,375 Bytes
eed5f5d 640cd56 eed5f5d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import streamlit as st
import faiss
import pandas as pd
from functions.loader import data, index
from functions.logic import load_image, find_similar_shows
st.title('TV Show Recommender')
# User input for the show description
user_description = st.text_area("Describe the TV show you're looking for:")
# Slider for the number of recommendations
num_recommendations = st.slider('Number of recommendations:', min_value=1, max_value=10, value=5)
# Button to get recommendations
if st.button('Recommend') and user_description:
try:
recommended_shows = find_similar_shows(user_description, index, num_recommendations)
for idx in recommended_shows.index:
with st.container():
link = data.loc[idx, 'url']
poster_url = data.loc[idx, 'img']
title = data.loc[idx, 'title']
description = data.loc[idx, 'description']
img = load_image(poster_url) # Use the load_image function
col1, col2 = st.columns([1, 2])
with col1:
st.image(img, caption=title, use_column_width='always')
with col2:
st.write(description)
st.markdown(f"[More Info]({link})", unsafe_allow_html=True)
except Exception as e:
st.error(f"An error occurred: {e}")
|