Stanford-TH commited on
Commit
2da3ad3
1 Parent(s): d862c41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -30
app.py CHANGED
@@ -1,31 +1,31 @@
1
- import gradio as gr
2
- from ScriptMatcher import ScriptMatcher
3
- # Initialize the ScriptMatcher instance
4
- scriptmatcher = ScriptMatcher()
5
-
6
- def classify_movie_genre(description, genres):
7
- """
8
- Given a description (synopsis) and genres, return similar series predictions.
9
- """
10
- # Split the genres string into a list of keywords
11
- genre_keywords = genres.split(",") # Assuming genres are comma-separated
12
- # Get the predictions using the ScriptMatcher
13
- predictions = scriptmatcher.find_similar_series(description, genre_keywords)
14
-
15
- return predictions
16
-
17
- # Create the Gradio interface
18
- iface = gr.Interface(
19
- fn=classify_movie_genre,
20
- inputs=[
21
- gr.Textbox(lines=5, label="Synopsis (Description)"),
22
- gr.Textbox(label="Genres (Comma-separated)")
23
- ],
24
- outputs=gr.Dataframe(label="Similar Series Predictions"),
25
- live=False, # No need for live updates as the processing will be based on submission
26
- title="Genre Prediction",
27
- description="Provide a movie synopsis and genres to get predictions for similar scripts.",
28
- )
29
-
30
- # Launch the Gradio interface
31
  iface.launch(inline=False)
 
1
+ import gradio as gr
2
+ from ScriptMatcher import ScriptMatcher
3
+ # Initialize the ScriptMatcher instance
4
+ scriptmatcher = ScriptMatcher()
5
+
6
+ def classify_movie_genre(description, genres):
7
+ """
8
+ Given a description (synopsis) and genres, return similar series predictions.
9
+ """
10
+ # Split the genres string into a list of keywords
11
+ genre_keywords = genres.split(",") # Assuming genres are comma-separated
12
+ # Get the predictions using the ScriptMatcher
13
+ predictions = scriptmatcher.find_similar_series(description, genre_keywords)
14
+
15
+ return pd.DataFrame(predictions)
16
+
17
+ # Create the Gradio interface
18
+ iface = gr.Interface(
19
+ fn=classify_movie_genre,
20
+ inputs=[
21
+ gr.Textbox(lines=5, label="Synopsis (Description)"),
22
+ gr.Textbox(label="Genres (Comma-separated)")
23
+ ],
24
+ outputs=gr.Dataframe(label="Similar Series Predictions"),
25
+ live=False, # No need for live updates as the processing will be based on submission
26
+ title="Genre Prediction",
27
+ description="Provide a movie synopsis and genres to get predictions for similar scripts.",
28
+ )
29
+
30
+ # Launch the Gradio interface
31
  iface.launch(inline=False)