Spaces:
Build error
Build error
Upload 4 files
#1
by
vidyakothavale
- opened
- .gitattributes +2 -0
- app.py +54 -8
- movie_list.pkl +3 -0
- requirements.txt +1 -1
- similarity.pkl +3 -0
.gitattributes
CHANGED
@@ -26,3 +26,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
26 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
27 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
28 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
26 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
27 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
28 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
29 |
+
movie_list.pkl filter=lfs diff=lfs merge=lfs -text
|
30 |
+
similarity.pkl filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -1,14 +1,60 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
st.title("A Simple Streamlit Web App")
|
5 |
|
6 |
-
name = st.text_input("Enter your name", '')
|
7 |
|
8 |
-
st.write(f"Hello {name}!")
|
9 |
|
10 |
-
x = st.slider("Select an integer x", 0, 10, 1)
|
11 |
-
y = st.slider("Select an integer y", 0, 10, 1)
|
12 |
|
13 |
-
df = pd.DataFrame({"x": [x], "y": [y] , "x + y": [x + y]}, index = ["addition row"])
|
14 |
-
st.write(df)
|
|
|
1 |
+
import pickle
|
2 |
import streamlit as st
|
3 |
+
import requests
|
4 |
+
|
5 |
+
def fetch_poster(movie_id):
|
6 |
+
url = "https://api.themoviedb.org/3/movie/{}?api_key=8265bd1679663a7ea12ac168da84d2e8&language=en-US".format(movie_id)
|
7 |
+
data = requests.get(url)
|
8 |
+
data = data.json()
|
9 |
+
poster_path = data['poster_path']
|
10 |
+
full_path = "https://image.tmdb.org/t/p/w500/" + poster_path
|
11 |
+
return full_path
|
12 |
+
|
13 |
+
def recommend(movie):
|
14 |
+
index = movies[movies['title'] == movie].index[0]
|
15 |
+
distances = sorted(list(enumerate(similarity[index])), reverse=True, key=lambda x: x[1])
|
16 |
+
recommended_movie_names = []
|
17 |
+
recommended_movie_posters = []
|
18 |
+
for i in distances[1:6]:
|
19 |
+
# fetch the movie poster
|
20 |
+
movie_id = movies.iloc[i[0]].movie_id
|
21 |
+
recommended_movie_posters.append(fetch_poster(movie_id))
|
22 |
+
recommended_movie_names.append(movies.iloc[i[0]].title)
|
23 |
+
|
24 |
+
return recommended_movie_names,recommended_movie_posters
|
25 |
+
|
26 |
+
|
27 |
+
st.header('Movie Recommender System')
|
28 |
+
movies = pickle.load(open('movie_list.pkl','rb'))
|
29 |
+
similarity = pickle.load(open('similarity.pkl','rb'))
|
30 |
+
|
31 |
+
movie_list = movies['title'].values
|
32 |
+
selected_movie = st.selectbox(
|
33 |
+
"Type or select a movie from the dropdown",
|
34 |
+
movie_list
|
35 |
+
)
|
36 |
+
|
37 |
+
if st.button('Show Recommendation'):
|
38 |
+
recommended_movie_names,recommended_movie_posters = recommend(selected_movie)
|
39 |
+
col1, col2, col3, col4, col5 = st.columns(5)
|
40 |
+
with col1:
|
41 |
+
st.text(recommended_movie_names[0])
|
42 |
+
st.image(recommended_movie_posters[0])
|
43 |
+
with col2:
|
44 |
+
st.text(recommended_movie_names[1])
|
45 |
+
st.image(recommended_movie_posters[1])
|
46 |
+
|
47 |
+
with col3:
|
48 |
+
st.text(recommended_movie_names[2])
|
49 |
+
st.image(recommended_movie_posters[2])
|
50 |
+
with col4:
|
51 |
+
st.text(recommended_movie_names[3])
|
52 |
+
st.image(recommended_movie_posters[3])
|
53 |
+
with col5:
|
54 |
+
st.text(recommended_movie_names[4])
|
55 |
+
st.image(recommended_movie_posters[4])
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
|
|
60 |
|
|
|
|
movie_list.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:58d379d5cf1d989f7da913398e7666a760acd0c15d47a959096ea78454aa90e6
|
3 |
+
size 2396328
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
streamlit
|
2 |
-
|
|
|
1 |
streamlit
|
2 |
+
requests
|
similarity.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:68067b69939937d822dc88f29ebd7d08240541a875b652b19c7e0bc050a433a8
|
3 |
+
size 184781251
|