Spaces:
Sleeping
Sleeping
Upload 6 files
Browse files- .gitattributes +1 -0
- app.py +87 -0
- data/credits.csv +3 -0
- data/movies.csv +0 -0
- movies.pkl +3 -0
- notebook.ipynb +0 -0
- similarity.pkl +3 -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 |
+
data/credits.csv filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pickle
|
3 |
+
import requests
|
4 |
+
|
5 |
+
movies = pickle.load(open('movies.pkl','rb'))
|
6 |
+
similarity = pickle.load(open('similarity.pkl','rb'))
|
7 |
+
movie_list = movies['title'].values
|
8 |
+
|
9 |
+
|
10 |
+
def poster_fetcher(id):
|
11 |
+
url = "https://api.themoviedb.org/3/movie/{}?api_key=d78186cbfc9e401bc620780d7148872d".format(id)
|
12 |
+
response = requests.get(url)
|
13 |
+
obj = response.json()
|
14 |
+
return "https://image.tmdb.org/t/p/w500/" + obj['poster_path']
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
def recommend(movie):
|
19 |
+
movie_names = []
|
20 |
+
posters = []
|
21 |
+
movie_index = movies[movies['title']==movie].index[0]
|
22 |
+
distance = similarity[movie_index]
|
23 |
+
movie_list = sorted((list(enumerate(distance))),reverse=True,key=lambda x : x[1])[1:6]
|
24 |
+
for i in movie_list:
|
25 |
+
# movie_id = i[0]
|
26 |
+
movie_names.append(movies.iloc[i[0]].title)
|
27 |
+
posters.append(poster_fetcher(movies.iloc[i[0]].movie_id))
|
28 |
+
return movie_names,posters
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
st.title("movie recommendation system")
|
34 |
+
|
35 |
+
selected_movie_name = st.selectbox("select any movie that you like",movie_list)
|
36 |
+
|
37 |
+
if st.button('recommend'):
|
38 |
+
names,posters = recommend(selected_movie_name)
|
39 |
+
st.title("recommendations:")
|
40 |
+
# for (i,j) in zip(names,posters):
|
41 |
+
# st.write(i)
|
42 |
+
# st.image(j)
|
43 |
+
|
44 |
+
|
45 |
+
# col1, col2, col3, col4, col5 = st.columns(5)
|
46 |
+
|
47 |
+
# with col1:
|
48 |
+
# st.text(names[0])
|
49 |
+
# st.image(posters[0])
|
50 |
+
|
51 |
+
# with col1:
|
52 |
+
# st.text(names[1])
|
53 |
+
# st.image(posters[1])
|
54 |
+
|
55 |
+
# with col1:
|
56 |
+
# st.text(names[2])
|
57 |
+
# st.image(posters[2])
|
58 |
+
|
59 |
+
# with col1:
|
60 |
+
# st.text(names[3])
|
61 |
+
# st.image(posters[3])
|
62 |
+
|
63 |
+
# with col1:
|
64 |
+
# st.text(names[4])
|
65 |
+
# st.image(posters[4])
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
+
col = st.columns(len(names))[0]
|
70 |
+
|
71 |
+
# Use a loop to add images horizontally
|
72 |
+
for (i,j) in zip(names,posters):
|
73 |
+
with col:
|
74 |
+
st.divider()
|
75 |
+
st.text(i)
|
76 |
+
st.image(j)
|
77 |
+
|
78 |
+
|
79 |
+
st.divider()
|
80 |
+
st.text('source - TMDB')
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
+
|
87 |
+
|
data/credits.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9d0050599ff88d40366c4841204b1489862bca346bfa46c20b05a65d14508435
|
3 |
+
size 40044293
|
data/movies.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
movies.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c3fc166544e9502de834797fe2f9c80d0bf94bb44afa63d552e1cebffda30ca1
|
3 |
+
size 2231780
|
notebook.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
similarity.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25e554f995f92f81b903eb1232e33d355382800dfeacfcec3d1c923c560c2025
|
3 |
+
size 184320163
|