Daniel
cambios en la interfaz
74385db
from sentence_transformers import SentenceTransformer
from pinecone_client import PineconeClient
import streamlit as st
import pandas as pd
from PIL import Image
im = Image.open('video.png')
st.set_page_config(page_title="Movie Recommender System App",page_icon = im)
import base64
def add_bg_from_local(image_file):
with open(image_file, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
st.markdown(
f"""
<style>
.stApp {{
background-image: url(data:image/{"gif"};base64,{encoded_string.decode()});
background-size: cover
}}
</style>
""",
unsafe_allow_html=True
)
add_bg_from_local('wallpaper_home.jpg')
text_search = st.text_input('Provide a movie description',
placeholder='E.g. A thrilling adventure in space')
genre = st.selectbox('Select movie genre',
options = ['All', 'Action', 'Drama', 'Adventure', 'Sci-Fi', 'Animation', 'Crime',
'Comedy', 'Thriller', 'Fantasy', 'Horror', 'History', 'Mystery',
'Biography', 'War', 'Western', 'Sport', 'Family', 'Romance',
'Music', 'Musical', 'Film-Noir', 'Game-Show', 'Adult',
'Reality-TV']
)
genre = [] if genre is "All" else [genre]
ratting = st.slider('Movie Rating (IMDb)', 0.0, 10.0, 0.0, 0.1, format = "%f")
top_k = st.slider('Select Movie Limit', 0, 10, 3)
model = SentenceTransformer('all-MiniLM-L6-v2')
def model_embedder(text):
embedding = model.encode(text)
return embedding.tolist()
vector_search = model_embedder(text_search)
index_name = "movies-embeddings"
p_client = PineconeClient(index_name)
results = p_client.query_similarity(vector_search, top_k=top_k, genre=genre, filter_rating=ratting)
df = pd.DataFrame([result['metadata'] for result in results])
df