JanaAlbader commited on
Commit
2dab5c7
·
verified ·
1 Parent(s): a06c696

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -81
app.py CHANGED
@@ -1,92 +1,28 @@
1
  import gradio as gr
2
 
3
- # Movie recommendations by genre
4
  movie_recommendations = {
5
- "Animated": {
6
- "title": "Soul (2020)",
7
- "image_url": "https://image-url.com/soul.jpg"
8
- },
9
- "Fantasy": {
10
- "title": "The Boy and the Heron (2023)",
11
- "image_url": "https://image-url.com/the-boy-and-the-heron.jpg"
12
- },
13
- "Superhero": {
14
- "title": "Spider-Man: No Way Home (2021)",
15
- "image_url": "https://image-url.com/spider-man-no-way-home.jpg"
16
- },
17
- "Action": {
18
- "title": "John Wick: Chapter 4 (2023)",
19
- "image_url": "https://image-url.com/john-wick-4.jpg"
20
- },
21
- "Adventure": {
22
- "title": "Dune (2021)",
23
- "image_url": "https://image-url.com/dune.jpg"
24
- },
25
- "Drama": {
26
- "title": "Nomadland (2020)",
27
- "image_url": "https://image-url.com/nomadland.jpg"
28
- },
29
- "Comedy": {
30
- "title": "Free Guy (2021)",
31
- "image_url": "https://image-url.com/free-guy.jpg"
32
- },
33
- "Horror": {
34
- "title": "A Quiet Place Part II (2021)",
35
- "image_url": "https://image-url.com/a-quiet-place-2.jpg"
36
- },
37
- "Thriller": {
38
- "title": "Tenet (2020)",
39
- "image_url": "https://image-url.com/tenet.jpg"
40
- },
41
- "Sci-Fi": {
42
- "title": "Blade Runner 2049 (2017)",
43
- "image_url": "https://image-url.com/blade-runner-2049.jpg"
44
- },
45
- "Romance": {
46
- "title": "The Last Letter from Your Lover (2021)",
47
- "image_url": "https://image-url.com/the-last-letter.jpg"
48
- },
49
- "Mystery": {
50
- "title": "Knives Out (2019)",
51
- "image_url": "https://image-url.com/knives-out.jpg"
52
- },
53
- "Musical": {
54
- "title": "West Side Story (2021)",
55
- "image_url": "https://image-url.com/west-side-story.jpg"
56
- },
57
- "Biography": {
58
- "title": "Bohemian Rhapsody (2018)",
59
- "image_url": "https://image-url.com/bohemian-rhapsody.jpg"
60
- },
61
- "Documentary": {
62
- "title": "The Social Dilemma (2020)",
63
- "image_url": "https://image-url.com/social-dilemma.jpg"
64
- },
65
- "War": {
66
- "title": "1917 (2019)",
67
- "image_url": "https://image-url.com/1917.jpg"
68
- },
69
- "Western": {
70
- "title": "The Power of the Dog (2021)",
71
- "image_url": "https://image-url.com/power-of-the-dog.jpg"
72
- }
73
  }
74
 
75
- # Function to recommend a movie based on the selected genre
76
  def recommend_movie(genre):
77
- movie = movie_recommendations.get(genre)
78
- if movie:
79
- return movie['title'], movie['image_url']
80
  else:
81
- return "No recommendation available", ""
82
 
83
- # Gradio Interface
84
- demo = gr.Interface(
85
- fn=recommend_movie,
86
- inputs=gr.inputs.Dropdown(choices=list(movie_recommendations.keys()), label="Select Genre"),
87
- outputs=[gr.outputs.Textbox(label="Movie Title"), gr.outputs.Image(label="Movie Poster")],
88
- title="Movie Recommendation"
89
- )
90
 
 
91
  demo.launch()
92
 
 
 
1
  import gradio as gr
2
 
3
+ # Define a dictionary with movie genres and recommendations
4
  movie_recommendations = {
5
+ "action": ["Mad Max: Fury Road", "John Wick", "Die Hard", "Spider-Man: No Way Home"],
6
+ "comedy": ["Superbad", "The Hangover", "Step Brothers"],
7
+ "drama": ["The Shawshank Redemption", "Forrest Gump", "The Godfather"],
8
+ "sci-fi": ["Inception", "The Matrix", "Interstellar"],
9
+ "horror": ["The Conjuring", "Get Out", "A Nightmare on Elm Street"],
10
+ "romance": ["Pride and Prejudice", "La La Land", "The Notebook"],
11
+ "animation": ["Toy Story", "Finding Nemo", "Shrek", "Inside Out", "The Boy and the Heron"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
 
14
+ # Function to recommend a movie based on the genre
15
  def recommend_movie(genre):
16
+ genre = genre.lower()
17
+ if genre in movie_recommendations:
18
+ return f"Here are some {genre.capitalize()} movie recommendations:\n" + "\n".join(movie_recommendations[genre])
19
  else:
20
+ return "Sorry, we don't have recommendations for that genre. Please try another genre."
21
 
22
+ # Create a Gradio interface
23
+ demo = gr.Interface(fn=recommend_movie, inputs="text", outputs="text", title="Movie Recommendation System", description="Enter a movie genre to get recommendations.")
 
 
 
 
 
24
 
25
+ # Launch the Gradio app
26
  demo.launch()
27
 
28
+