Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- .gitattributes +1 -0
- .gitignore +160 -0
- kino_mail_proc.csv +3 -0
- requirements.txt +101 -0
- stream_temp.py +89 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ 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 |
+
kino_mail_proc.csv filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
share/python-wheels/
|
24 |
+
*.egg-info/
|
25 |
+
.installed.cfg
|
26 |
+
*.egg
|
27 |
+
MANIFEST
|
28 |
+
|
29 |
+
# PyInstaller
|
30 |
+
# Usually these files are written by a python script from a template
|
31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32 |
+
*.manifest
|
33 |
+
*.spec
|
34 |
+
|
35 |
+
# Installer logs
|
36 |
+
pip-log.txt
|
37 |
+
pip-delete-this-directory.txt
|
38 |
+
|
39 |
+
# Unit test / coverage reports
|
40 |
+
htmlcov/
|
41 |
+
.tox/
|
42 |
+
.nox/
|
43 |
+
.coverage
|
44 |
+
.coverage.*
|
45 |
+
.cache
|
46 |
+
nosetests.xml
|
47 |
+
coverage.xml
|
48 |
+
*.cover
|
49 |
+
*.py,cover
|
50 |
+
.hypothesis/
|
51 |
+
.pytest_cache/
|
52 |
+
cover/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
.pybuilder/
|
76 |
+
target/
|
77 |
+
|
78 |
+
# Jupyter Notebook
|
79 |
+
.ipynb_checkpoints
|
80 |
+
|
81 |
+
# IPython
|
82 |
+
profile_default/
|
83 |
+
ipython_config.py
|
84 |
+
|
85 |
+
# pyenv
|
86 |
+
# For a library or package, you might want to ignore these files since the code is
|
87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
88 |
+
# .python-version
|
89 |
+
|
90 |
+
# pipenv
|
91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
94 |
+
# install all needed dependencies.
|
95 |
+
#Pipfile.lock
|
96 |
+
|
97 |
+
# poetry
|
98 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
100 |
+
# commonly ignored for libraries.
|
101 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
102 |
+
#poetry.lock
|
103 |
+
|
104 |
+
# pdm
|
105 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
106 |
+
#pdm.lock
|
107 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
108 |
+
# in version control.
|
109 |
+
# https://pdm.fming.dev/#use-with-ide
|
110 |
+
.pdm.toml
|
111 |
+
|
112 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
113 |
+
__pypackages__/
|
114 |
+
|
115 |
+
# Celery stuff
|
116 |
+
celerybeat-schedule
|
117 |
+
celerybeat.pid
|
118 |
+
|
119 |
+
# SageMath parsed files
|
120 |
+
*.sage.py
|
121 |
+
|
122 |
+
# Environments
|
123 |
+
.env
|
124 |
+
.venv
|
125 |
+
env/
|
126 |
+
venv/
|
127 |
+
ENV/
|
128 |
+
env.bak/
|
129 |
+
venv.bak/
|
130 |
+
|
131 |
+
# Spyder project settings
|
132 |
+
.spyderproject
|
133 |
+
.spyproject
|
134 |
+
|
135 |
+
# Rope project settings
|
136 |
+
.ropeproject
|
137 |
+
|
138 |
+
# mkdocs documentation
|
139 |
+
/site
|
140 |
+
|
141 |
+
# mypy
|
142 |
+
.mypy_cache/
|
143 |
+
.dmypy.json
|
144 |
+
dmypy.json
|
145 |
+
|
146 |
+
# Pyre type checker
|
147 |
+
.pyre/
|
148 |
+
|
149 |
+
# pytype static type analyzer
|
150 |
+
.pytype/
|
151 |
+
|
152 |
+
# Cython debug symbols
|
153 |
+
cython_debug/
|
154 |
+
|
155 |
+
# PyCharm
|
156 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
157 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
158 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
159 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
160 |
+
#.idea/
|
kino_mail_proc.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d6d48eb99ce42b1f541b2e3bba541738ad9c86a12de0058cf2a4354d468ab965
|
3 |
+
size 20173069
|
requirements.txt
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
altair==5.2.0
|
2 |
+
asttokens==2.4.1
|
3 |
+
attrs==23.2.0
|
4 |
+
blinker==1.7.0
|
5 |
+
cachetools==5.3.3
|
6 |
+
certifi==2024.2.2
|
7 |
+
charset-normalizer==3.3.2
|
8 |
+
click==8.1.7
|
9 |
+
comm==0.2.1
|
10 |
+
contourpy==1.2.0
|
11 |
+
cycler==0.12.1
|
12 |
+
debugpy==1.8.1
|
13 |
+
decorator==5.1.1
|
14 |
+
executing==2.0.1
|
15 |
+
filelock==3.13.1
|
16 |
+
fonttools==4.49.0
|
17 |
+
fsspec==2024.2.0
|
18 |
+
gitdb==4.0.11
|
19 |
+
GitPython==3.1.42
|
20 |
+
idna==3.6
|
21 |
+
importlib-metadata==7.0.1
|
22 |
+
ipykernel==6.29.3
|
23 |
+
jedi==0.19.1
|
24 |
+
Jinja2==3.1.3
|
25 |
+
jsonschema==4.21.1
|
26 |
+
jsonschema-specifications==2023.12.1
|
27 |
+
jupyter_client==8.6.0
|
28 |
+
jupyter_core==5.7.1
|
29 |
+
kiwisolver==1.4.5
|
30 |
+
markdown-it-py==3.0.0
|
31 |
+
MarkupSafe==2.1.5
|
32 |
+
matplotlib==3.8.3
|
33 |
+
matplotlib-inline==0.1.6
|
34 |
+
mdurl==0.1.2
|
35 |
+
mpmath==1.3.0
|
36 |
+
nest-asyncio==1.6.0
|
37 |
+
networkx==3.2.1
|
38 |
+
numpy==1.26.4
|
39 |
+
nvidia-cublas-cu12==12.1.3.1
|
40 |
+
nvidia-cuda-cupti-cu12==12.1.105
|
41 |
+
nvidia-cuda-nvrtc-cu12==12.1.105
|
42 |
+
nvidia-cuda-runtime-cu12==12.1.105
|
43 |
+
nvidia-cudnn-cu12==8.9.2.26
|
44 |
+
nvidia-cufft-cu12==11.0.2.54
|
45 |
+
nvidia-curand-cu12==10.3.2.106
|
46 |
+
nvidia-cusolver-cu12==11.4.5.107
|
47 |
+
nvidia-cusparse-cu12==12.1.0.106
|
48 |
+
nvidia-nccl-cu12==2.19.3
|
49 |
+
nvidia-nvjitlink-cu12==12.3.101
|
50 |
+
nvidia-nvtx-cu12==12.1.105
|
51 |
+
opencv-python==4.9.0.80
|
52 |
+
packaging==23.2
|
53 |
+
pandas==2.2.1
|
54 |
+
parso==0.8.3
|
55 |
+
pexpect==4.9.0
|
56 |
+
pillow==10.2.0
|
57 |
+
platformdirs==4.2.0
|
58 |
+
prompt-toolkit==3.0.43
|
59 |
+
protobuf==4.25.3
|
60 |
+
psutil==5.9.8
|
61 |
+
ptyprocess==0.7.0
|
62 |
+
pure-eval==0.2.2
|
63 |
+
py-cpuinfo==9.0.0
|
64 |
+
pyarrow==15.0.0
|
65 |
+
pydeck==0.8.1b0
|
66 |
+
Pygments==2.17.2
|
67 |
+
pyparsing==3.1.1
|
68 |
+
python-dateutil==2.8.2
|
69 |
+
pytz==2024.1
|
70 |
+
PyYAML==6.0.1
|
71 |
+
pyzmq==25.1.2
|
72 |
+
referencing==0.33.0
|
73 |
+
requests==2.31.0
|
74 |
+
rich==13.7.1
|
75 |
+
rpds-py==0.18.0
|
76 |
+
scipy==1.12.0
|
77 |
+
seaborn==0.13.2
|
78 |
+
six==1.16.0
|
79 |
+
smmap==5.0.1
|
80 |
+
stack-data==0.6.3
|
81 |
+
streamlit==1.31.1
|
82 |
+
sympy==1.12
|
83 |
+
tenacity==8.2.3
|
84 |
+
thop==0.1.1.post2209072238
|
85 |
+
toml==0.10.2
|
86 |
+
toolz==0.12.1
|
87 |
+
torch==2.2.1
|
88 |
+
torchvision==0.17.1
|
89 |
+
tornado==6.4
|
90 |
+
tqdm==4.66.2
|
91 |
+
traitlets==5.14.1
|
92 |
+
triton==2.2.0
|
93 |
+
typing_extensions==4.10.0
|
94 |
+
tzdata==2024.1
|
95 |
+
tzlocal==5.2
|
96 |
+
ultralytics==8.1.19
|
97 |
+
urllib3==2.2.1
|
98 |
+
validators==0.22.0
|
99 |
+
watchdog==4.0.0
|
100 |
+
wcwidth==0.2.13
|
101 |
+
zipp==3.17.0
|
stream_temp.py
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
|
6 |
+
from PIL import Image
|
7 |
+
import base64
|
8 |
+
from io import BytesIO
|
9 |
+
|
10 |
+
from sentence_transformers import SentenceTransformer, util
|
11 |
+
import faiss
|
12 |
+
|
13 |
+
df = pd.read_csv('/home/valera/ds_bootcamp/ds-phase-2/11-nn-ext/progect/movies.csv')
|
14 |
+
|
15 |
+
@st.cache_resource
|
16 |
+
def load_model():
|
17 |
+
return SentenceTransformer("cointegrated/rubert-tiny2")
|
18 |
+
model = load_model()
|
19 |
+
|
20 |
+
@st.cache_resource
|
21 |
+
def load_vector():
|
22 |
+
return model.encode(df["description"])
|
23 |
+
embeddings = load_vector()
|
24 |
+
|
25 |
+
index = faiss.IndexFlatIP(embeddings.shape[1])
|
26 |
+
index.add(embeddings)
|
27 |
+
|
28 |
+
# Функция для поиска фильмов по сходству
|
29 |
+
def find_similar_movies(user_input, top_n=5):
|
30 |
+
user_input = model.encode(user_input)
|
31 |
+
user_input = user_input.reshape(1,-1)
|
32 |
+
distances, indices = index.search(user_input, top_n)
|
33 |
+
return list(indices[0])
|
34 |
+
|
35 |
+
# Загрузить изображение из файла
|
36 |
+
img = Image.open('/home/valera/ds_bootcamp/ds-phase-2/11-nn-ext/progect/_-fotor.jpg')
|
37 |
+
buffered = BytesIO()
|
38 |
+
img.save(buffered, format="JPEG")
|
39 |
+
img_str = base64.b64encode(buffered.getvalue()).decode()
|
40 |
+
|
41 |
+
st.markdown(f"""
|
42 |
+
<style>
|
43 |
+
.stApp {{
|
44 |
+
background-image: url(data:image/jpg;base64,{img_str});
|
45 |
+
background-size: cover;
|
46 |
+
}}
|
47 |
+
</style>
|
48 |
+
""", unsafe_allow_html=True)
|
49 |
+
|
50 |
+
|
51 |
+
random_digits = np.random.choice(len(df), size=5, replace=False)
|
52 |
+
|
53 |
+
# Создать текстовое поле для ввода названия фильма
|
54 |
+
title = st.text_input('Что хотите посмотреть сегодня?')
|
55 |
+
if st.button('Подобрать фильм'):
|
56 |
+
# Использование функции
|
57 |
+
similar_movies = find_similar_movies(title)
|
58 |
+
for i in similar_movies:
|
59 |
+
st.title('Название фильма:')
|
60 |
+
st.header(df['movie_title'][i])
|
61 |
+
st.image('http://'+ df['img_url'][i])
|
62 |
+
st.title('Описание:')
|
63 |
+
st.write(df['description'][i])
|
64 |
+
st.title('Жанр:')
|
65 |
+
st.write("Нет данных" if pd.isna(df['genres'].iloc[i]) else df['genres'][i] )
|
66 |
+
st.title('Оценка')
|
67 |
+
imb = 'Нет оценки' if df['imdb'][i] == 0 else str(df['imdb'][i])
|
68 |
+
kinopoisk = 'Нет оценки' if df['kinopoisk'][i] == 0 else str(df['kinopoisk'][i])
|
69 |
+
st.write(f'Рейтинг imdb: {imb}')
|
70 |
+
st.write(f'Рейтинг кинопоиск: {kinopoisk}')
|
71 |
+
st.title('-'*45)
|
72 |
+
|
73 |
+
if st.button('Выбрать случайно'):
|
74 |
+
for i in random_digits:
|
75 |
+
st.title('Название фильма:')
|
76 |
+
st.header(df['movie_title'][i])
|
77 |
+
st.image('http://'+ df['img_url'][i])
|
78 |
+
st.title('Описание:')
|
79 |
+
st.write(df['description'][i])
|
80 |
+
st.title('Жанр:')
|
81 |
+
st.write("Нет данных" if pd.isna(df['genres'].iloc[i]) else df['genres'][i] )
|
82 |
+
st.title('Оценка')
|
83 |
+
imb = 'Нет оценки' if df['imdb'][i] == 0 else str(df['imdb'][i])
|
84 |
+
kinopoisk = 'Нет оценки' if df['kinopoisk'][i] == 0 else str(df['kinopoisk'][i])
|
85 |
+
st.write(f'Рейтинг imdb: {imb}')
|
86 |
+
st.write(f'Рейтинг кинопоиск: {kinopoisk}')
|
87 |
+
st.title('-'*45)
|
88 |
+
|
89 |
+
|