AbdelrahmanHassan commited on
Commit
9188ee5
β€’
1 Parent(s): 1ded221

first commit for deploying

Browse files
Files changed (7) hide show
  1. Procfile +1 -0
  2. README.md +1 -13
  3. app.py +60 -0
  4. gitignore +1 -0
  5. movie_list.pkl +3 -0
  6. requirements.txt +7 -0
  7. setup.sh +9 -0
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web : sh setup.sh && streamlit run main.py
README.md CHANGED
@@ -1,13 +1 @@
1
- ---
2
- title: Movies Recommendation
3
- emoji: πŸƒ
4
- colorFrom: blue
5
- colorTo: gray
6
- sdk: streamlit
7
- sdk_version: 1.25.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # Movie_Recommendations
 
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+ import requests
4
+ # from sklearn.feature_extraction.text import CountVectorizer
5
+
6
+
7
+ def fetch_poster(movie_id):
8
+ url = "https://api.themoviedb.org/3/movie/{}?api_key=8265bd1679663a7ea12ac168da84d2e8&language=en-US".format(movie_id)
9
+ data = requests.get(url)
10
+ data = data.json()
11
+ poster_path = data['poster_path']
12
+ full_path = "https://image.tmdb.org/t/p/w500/" + poster_path
13
+ return full_path
14
+
15
+ def recommend(movie):
16
+ index = movies[movies['title'] == movie].index[0]
17
+ distances = sorted(list(enumerate(similarity[index])),reverse=True,key = lambda x: x[1])
18
+ recommend_Movies=[]
19
+ recommended_movie_posters = []
20
+ for i in distances[1:6]:
21
+ movie_id = movies.iloc[i[0]].movie_id
22
+ recommended_movie_posters.append(fetch_poster(movie_id))
23
+ recommend_Movies.append(movies.iloc[i[0]].title)
24
+ return recommended_movie_posters,recommend_Movies
25
+
26
+
27
+
28
+
29
+ movies=pickle.load(open('movie_list.pkl','rb'))
30
+ similarity=pickle.load(open("similarity.pkl",'rb'))
31
+ # cv = CountVectorizer(max_features=10000,stop_words='english')
32
+ # from sklearn.metrics.pairwise import cosine_similarity
33
+ # vector = cv.fit_transform(movies['tags']).toarray()
34
+ # similarity = cosine_similarity(vector)
35
+
36
+
37
+ st.title("Movie Recommandor System")
38
+ Movies_Name = st.selectbox('How would you like to recomend movies?',movies['title'].values)
39
+
40
+ if st.button('recommend'):
41
+ recommended_movie_posters,recommend_Movies=recommend(Movies_Name)
42
+ col1, col2, col3, col4, col5 = st.columns(5)
43
+ with col1:
44
+ st.text(recommend_Movies[0])
45
+ st.image(recommended_movie_posters[0])
46
+ with col2:
47
+ st.text(recommend_Movies[1])
48
+ st.image(recommended_movie_posters[1])
49
+
50
+ with col3:
51
+ st.text(recommend_Movies[2])
52
+ st.image(recommended_movie_posters[2])
53
+ with col4:
54
+ st.text(recommend_Movies[3])
55
+ st.image(recommended_movie_posters[3])
56
+ with col5:
57
+ st.text(recommend_Movies[4])
58
+ st.image(recommended_movie_posters[4])
59
+
60
+
gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ venv
movie_list.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89155305bb8377fa5b61f3d83cd728f46e6c6982971b0ee4fdca365a2b43792e
3
+ size 2514290
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ streamlit_lottie==0.0.2
2
+ pandas==1.3.5
3
+ xlrd<2.0
4
+ streamlit==1.3.0
5
+ requests==2.24.0
6
+ Pillow==8.4.0
7
+ click<8.0
setup.sh ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ mkdir -p ~/.streamlit/
2
+
3
+ echo "\
4
+ [Server]\n\
5
+ port =$port\n\
6
+ enableCORS = false\n\
7
+ headless =true \n\
8
+ \n\
9
+ " > ~/.streamlit/credentials.toml