File size: 1,531 Bytes
f1c9005
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# streamlit run app.py use for run this web
import streamlit as st
import pickle
import pandas as pd
import requests

def fechposter(movies_id):
    response = requests.get(f"https://api.themoviedb.org/3/movie/{movies_id}?api_key=175454cec5e81a00151981dfb22a69d4&language=en-US")
    data=response.json()
    # st.write(data)
    return 'https://image.tmdb.org/t/p/w500/'+data['poster_path']
def recommend(movie):
    m_index=movies[movies['title']==movie].index[0]
    distance=similer[m_index]
    movies_list=sorted(list(enumerate(distance)), reverse=True, key=lambda x : x[1])[1:6]
    recommended=[]
    recom_movie_post=[]
    for m in movies_list:
        recommended.append(movies.iloc[m[0]].title)
        recom_movie_post.append(fechposter(movies.iloc[m[0]].movie_id))    
    return recommended,recom_movie_post
movies_l=pickle.load(open('movie_dict.pkl','rb'))
similer=pickle.load(open('similer_m.pkl','rb'))
movies=pd.DataFrame(movies_l)
st.title("w_one_n.cm")
selected_movie = st.selectbox(
    'Select the movie',
    movies['title'].values)
if st.button('Recommend'):
    names,posters=recommend(selected_movie)
    col1,col2,col3,col4,col5 =st.columns(5)
    with col1:
        st.text(names[0])
        st.image(posters[0])
    with col2:
        st.text(names[1])
        st.image(posters[1])
    with col3:
        st.text(names[2])
        st.image(posters[2])
    with col4:
        st.text(names[3])
        st.image(posters[3])
    with col5:
        st.text(names[4])
        st.image(posters[4])