import streamlit as st from transformers import AutoModelForSequenceClassification import pandas as pd import numpy as np import torch import pickle import wikipedia from preprocess import Preprocess from utility import Utility st.title("Movie Genre Predictor") text = st.text_input('Enter plot of the movie') st.caption("Either enter Wiki URL or the Cast info of the movie. Cast will be fetched from the Wiki page if cast is not provided") wiki_url = st.text_input("Enter Wiki URL of the movie (Needed for fetching the cast information)") cast_input = st.text_input("Enter Wiki IDs of the cast (Should be separated by comma)") model = AutoModelForSequenceClassification.from_pretrained("./checkpoint-49092") device = 'cuda' if torch.cuda.is_available() else 'cpu' model.to(device) lr_model = pickle.load(open("models/cast_plot_lr","rb")) cast_mlb = pickle.load(open("models/cast_mlb","rb")) #column_names = pickle.load(open("models/column_names","rb")) #top_actors = list(column_names)[11:] top_actors = list(cast_mlb.classes_) meta_model = pickle.load(open("models/meta_model","rb")) utility = Utility() preprocess = Preprocess() out = [] if st.button("Predict"): cast = [] if len(wiki_url)!=0 and len(cast_input)==0: html_page = wikipedia.page(title=wiki_url.split("/")[-1].replace("_"," "), auto_suggest=False).html() cast_wiki = html_page.split(" title=\"Edit section: Cast\">edit")[-1] anchor_tags = cast_wiki.split("