Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files- .gitattributes +2 -0
- app.py +71 -0
- cat.jpg +0 -0
- datasetf.csv +3 -0
- faiss_index.index +3 -0
- requirements.txt +105 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
datasetf.csv filter=lfs diff=lfs merge=lfs -text
|
37 |
+
faiss_index.index filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
import requests
|
4 |
+
from io import BytesIO
|
5 |
+
from sentence_transformers import SentenceTransformer
|
6 |
+
import faiss
|
7 |
+
import pandas as pd
|
8 |
+
|
9 |
+
# import sys
|
10 |
+
# import subprocess
|
11 |
+
# import streamlit as st
|
12 |
+
|
13 |
+
# # Debug: Print Python executable and installed packages
|
14 |
+
# st.write(f"Python executable: {sys.executable}")
|
15 |
+
# installed_packages = subprocess.run([sys.executable, "-m", "pip", "list"], capture_output=True, text=True).stdout
|
16 |
+
# st.text(installed_packages)
|
17 |
+
|
18 |
+
model = SentenceTransformer('cointegrated/rubert-tiny2')
|
19 |
+
index = faiss.read_index('faiss_index.index')
|
20 |
+
data = pd.read_csv('datasetf.csv')
|
21 |
+
|
22 |
+
def vectorize(descriptions):
|
23 |
+
embeddings = model.encode(descriptions)
|
24 |
+
return embeddings
|
25 |
+
|
26 |
+
|
27 |
+
def find_similar_shows(user_description, index, k=5):
|
28 |
+
query_vector = vectorize([user_description])
|
29 |
+
_, indices = index.search(query_vector, k)
|
30 |
+
return data.iloc[indices.flatten()]
|
31 |
+
|
32 |
+
def load_image(url):
|
33 |
+
try:
|
34 |
+
response = requests.get(url)
|
35 |
+
img = Image.open(BytesIO(response.content))
|
36 |
+
except Exception:
|
37 |
+
# If an error occurs, load the dummy image
|
38 |
+
img = Image.open("cat.jpg") # Update the path to your dummy image
|
39 |
+
return img
|
40 |
+
|
41 |
+
st.title('TV Show Recommender')
|
42 |
+
|
43 |
+
# User input for the show description
|
44 |
+
user_description = st.text_area("Describe the TV show you're looking for:")
|
45 |
+
|
46 |
+
# Slider for the number of recommendations
|
47 |
+
num_recommendations = st.slider('Number of recommendations:', min_value=1, max_value=10, value=5)
|
48 |
+
|
49 |
+
# Button to get recommendations
|
50 |
+
if st.button('Recommend') and user_description:
|
51 |
+
try:
|
52 |
+
recommended_shows = find_similar_shows(user_description, index, num_recommendations)
|
53 |
+
|
54 |
+
for idx in recommended_shows.index:
|
55 |
+
with st.container():
|
56 |
+
link = data.loc[idx, 'url']
|
57 |
+
poster_url = data.loc[idx, 'poster']
|
58 |
+
title = data.loc[idx, 'title']
|
59 |
+
description = data.loc[idx, 'description']
|
60 |
+
|
61 |
+
img = load_image(poster_url) # Use the load_image function
|
62 |
+
|
63 |
+
col1, col2 = st.columns([1, 2])
|
64 |
+
with col1:
|
65 |
+
st.image(img, caption=title, use_column_width='always')
|
66 |
+
with col2:
|
67 |
+
st.write(description)
|
68 |
+
st.markdown(f"[More Info]({link})", unsafe_allow_html=True)
|
69 |
+
|
70 |
+
except Exception as e:
|
71 |
+
st.error(f"An error occurred: {e}")
|
cat.jpg
ADDED
![]() |
datasetf.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9baa1443870901e093cb11d655254adee1317f0684a5021bbc3db7f05ccb1a1b
|
3 |
+
size 19263072
|
faiss_index.index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7e9c90a44a23ff326c88c295bbd23f1615b405a52c57b659306866b71564bdaa
|
3 |
+
size 18632685
|
requirements.txt
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
altair==5.2.0
|
2 |
+
asttokens==2.4.1
|
3 |
+
attrs==23.2.0
|
4 |
+
beautifulsoup4==4.12.3
|
5 |
+
blinker==1.7.0
|
6 |
+
cachetools==5.3.2
|
7 |
+
certifi==2024.2.2
|
8 |
+
charset-normalizer==3.3.2
|
9 |
+
click==8.1.7
|
10 |
+
comm==0.2.1
|
11 |
+
debugpy==1.8.0
|
12 |
+
decorator==5.1.1
|
13 |
+
exceptiongroup==1.2.0
|
14 |
+
executing==2.0.1
|
15 |
+
faiss-cpu==1.7.4
|
16 |
+
filelock==3.13.1
|
17 |
+
fsspec==2024.2.0
|
18 |
+
gitdb==4.0.11
|
19 |
+
GitPython==3.1.41
|
20 |
+
huggingface-hub==0.20.3
|
21 |
+
idna==3.6
|
22 |
+
importlib-metadata==7.0.1
|
23 |
+
ipykernel==6.29.1
|
24 |
+
ipython==8.21.0
|
25 |
+
jedi==0.19.1
|
26 |
+
Jinja2==3.1.3
|
27 |
+
joblib==1.3.2
|
28 |
+
jsonschema==4.21.1
|
29 |
+
jsonschema-specifications==2023.12.1
|
30 |
+
jupyter_client==8.6.0
|
31 |
+
jupyter_core==5.7.1
|
32 |
+
markdown-it-py==3.0.0
|
33 |
+
MarkupSafe==2.1.5
|
34 |
+
matplotlib-inline==0.1.6
|
35 |
+
mdurl==0.1.2
|
36 |
+
mpmath==1.3.0
|
37 |
+
nest-asyncio==1.6.0
|
38 |
+
networkx==3.2.1
|
39 |
+
nltk==3.8.1
|
40 |
+
numpy==1.26.4
|
41 |
+
nvidia-cublas-cu12==12.1.3.1
|
42 |
+
nvidia-cuda-cupti-cu12==12.1.105
|
43 |
+
nvidia-cuda-nvrtc-cu12==12.1.105
|
44 |
+
nvidia-cuda-runtime-cu12==12.1.105
|
45 |
+
nvidia-cudnn-cu12==8.9.2.26
|
46 |
+
nvidia-cufft-cu12==11.0.2.54
|
47 |
+
nvidia-curand-cu12==10.3.2.106
|
48 |
+
nvidia-cusolver-cu12==11.4.5.107
|
49 |
+
nvidia-cusparse-cu12==12.1.0.106
|
50 |
+
nvidia-nccl-cu12==2.19.3
|
51 |
+
nvidia-nvjitlink-cu12==12.3.101
|
52 |
+
nvidia-nvtx-cu12==12.1.105
|
53 |
+
packaging==23.2
|
54 |
+
pandas==2.2.0
|
55 |
+
parso==0.8.3
|
56 |
+
pexpect==4.9.0
|
57 |
+
pillow==10.2.0
|
58 |
+
platformdirs==4.2.0
|
59 |
+
prompt-toolkit==3.0.43
|
60 |
+
protobuf==4.25.2
|
61 |
+
psutil==5.9.8
|
62 |
+
ptyprocess==0.7.0
|
63 |
+
pure-eval==0.2.2
|
64 |
+
pyarrow==15.0.0
|
65 |
+
pydeck==0.8.1b0
|
66 |
+
Pygments==2.17.2
|
67 |
+
python-dateutil==2.8.2
|
68 |
+
pytz==2024.1
|
69 |
+
PyYAML==6.0.1
|
70 |
+
pyzmq==25.1.2
|
71 |
+
referencing==0.33.0
|
72 |
+
regex==2023.12.25
|
73 |
+
requests==2.31.0
|
74 |
+
rich==13.7.0
|
75 |
+
rpds-py==0.17.1
|
76 |
+
safetensors==0.4.2
|
77 |
+
scikit-learn==1.4.0
|
78 |
+
scipy==1.12.0
|
79 |
+
sentence-transformers==2.3.1
|
80 |
+
sentencepiece==0.1.99
|
81 |
+
six==1.16.0
|
82 |
+
smmap==5.0.1
|
83 |
+
soupsieve==2.5
|
84 |
+
stack-data==0.6.3
|
85 |
+
streamlit==1.31.0
|
86 |
+
sympy==1.12
|
87 |
+
tenacity==8.2.3
|
88 |
+
threadpoolctl==3.2.0
|
89 |
+
tokenizers==0.15.1
|
90 |
+
toml==0.10.2
|
91 |
+
toolz==0.12.1
|
92 |
+
torch==2.2.0
|
93 |
+
tornado==6.4
|
94 |
+
tqdm==4.66.1
|
95 |
+
traitlets==5.14.1
|
96 |
+
transformers==4.37.2
|
97 |
+
triton==2.2.0
|
98 |
+
typing_extensions==4.9.0
|
99 |
+
tzdata==2023.4
|
100 |
+
tzlocal==5.2
|
101 |
+
urllib3==2.2.0
|
102 |
+
validators==0.22.0
|
103 |
+
watchdog==4.0.0
|
104 |
+
wcwidth==0.2.13
|
105 |
+
zipp==3.17.0
|