File size: 2,431 Bytes
6a44cf0
 
 
09ade37
6a44cf0
 
 
 
 
 
 
 
 
 
6c9851e
6a44cf0
 
 
6c9851e
6a44cf0
 
 
 
 
 
 
 
 
6c9851e
 
6a44cf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71fe120
6a44cf0
 
 
 
 
 
 
6c9851e
 
 
6a44cf0
6c9851e
6a44cf0
 
 
6c9851e
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import streamlit as st
import pandas as pd
import numpy as np
from PIL import Image
from SVD_Model import Recommender_Model


@st.cache_resource
def load_model():
    return Recommender_Model()

model = load_model()


def view_suggestions(movies_array: list, number_of_suggestions):
    movie1 = model.find_nearest_movie(movies_array[0])[0]
    movie2 = model.find_nearest_movie(movies_array[1])[0]
    movie3 = model.find_nearest_movie(movies_array[2])[0]
    suggestions = model.suggest([movie1, movie2, movie3], number_of_suggestions=number_of_suggestions)
    for movie in [movie1, movie2, movie3]:
        suggestions = suggestions[suggestions['title'] != movie]
    suggestions = suggestions.to_numpy()
    suggested_movies = []
    for row in suggestions:
        name = row[0]
        suggested_movies.append(model.get_movie_info(name))
    
    for idx, info in enumerate(suggested_movies):
        if idx >= number_of_suggestions:
            break
        st.subheader(info['title'])
        st.markdown(f"__Overview:__ {info['overview']}")
        st.markdown(f"__Genres:__")
        st.write(info['genres'], value='genre')
        st.markdown(f"__Language:__ {info['language']}")
        st.divider()
        



with st.sidebar:
    logo = Image.open("MM Logo.jpeg")
    st.image(logo, caption='MM Movie Recommender')
    st.title("MM Movie Recommender")
    st.subheader("Development Team:")
    st.markdown("<a href='https://www.linkedin.com/in/mobin-nesari/'>Mobin Nesari</a>", unsafe_allow_html=True)
    st.markdown("<a href='https://www.linkedin.com/in/m0hsnn/'>Seyed Mohsen Sadeghi</a>", unsafe_allow_html=True)
    st.markdown("Huge shout-out to __Mohammad Reza Saheb__ & __Mirhossein Adnani Oskoui__ for reviewing and testing beta version!")
    
    
st.title("MM Movie Recommender")
st.header("Movie Names:")
st.subheader("Please specify three movies which you like them")

with st.form("input_form"):
    movie1 = st.text_input('Movie 1', placeholder="Like Ironman 1")
    movie2 = st.text_input('Movie 2', placeholder='Like Ironman 2')
    movie3 = st.text_input('Movie 3', placeholder="Like Ironman 3")
    
    number_of_suggestions = st.slider(label = 'How many movies do you want to be suggested?', min_value=1, max_value=10, step=1)
    
    submitted = st.form_submit_button("Submit")
    if submitted:
        view_suggestions([movie1, movie2, movie3], number_of_suggestions=number_of_suggestions)