Stanford-TH's picture
Update app.py
7335dae verified
import gradio as gr
import pandas as pd
from ScriptMatcher import ScriptMatcher
# Initialize the ScriptMatcher instance
scriptmatcher = ScriptMatcher()
def classify_movie_genre(description, genres):
"""
Given a description (synopsis) and genres, return similar series predictions.
"""
# Split the genres string into a list of keywords
genre_keywords = genres.split(",") # Assuming genres are comma-separated
# Get the predictions using the ScriptMatcher
predictions = scriptmatcher.find_similar_series(description, genre_keywords)
return pd.DataFrame(predictions)
# Create the Gradio interface
iface = gr.Interface(
fn=classify_movie_genre,
inputs=[
gr.Textbox(lines=5, label="Synopsis (Description)"),
gr.Textbox(label="Genres (Comma-separated)")
],
outputs=gr.Dataframe(label="Similar Series Predictions"),
live=False, # No need for live updates as the processing will be based on submission
title="Genre Prediction",
description="Provide a movie synopsis and genres to get predictions for similar scripts.",
)
# Launch the Gradio interface
iface.launch(inline=False)