Kruthii commited on
Commit
e5bb506
·
verified ·
1 Parent(s): 559536b

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+
4
+ movies = pd.read_csv('100_niche_movies.csv')
5
+
6
+ def recommend(query):
7
+ query = query.lower()
8
+ if "sci-fi" in query: genre = "Sci-Fi"
9
+ elif "horror" in query: genre = "Horror"
10
+ elif "comedy" in query: genre = "Comedy"
11
+ else: return movies.sample(3)
12
+
13
+ return movies[movies['genres'].str.contains(genre)].sample(3)
14
+
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown("# 🎬 Your Personal Movie Assistant")
17
+ query = gr.Textbox(label="What kind of movies?")
18
+ output = gr.JSON(label="Recommendations")
19
+ query.submit(
20
+ fn=lambda q: recommend(q).to_dict('records'),
21
+ inputs=query,
22
+ outputs=output
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ demo.launch()