ayushsinha's picture
Upload 2 files
4cc5afe verified
import gradio as gr
from transformers import pipeline
# Load the movie recommendation model
model_name = "AventIQ-AI/all-MiniLM-L6-v2-movie-recommendation-system"
retriever = pipeline("feature-extraction", model=model_name)
def recommend_movies(movie_description):
"""Generates movie recommendations based on user input."""
if not movie_description.strip():
return "⚠️ Please enter a movie description or genre."
# Dummy output (replace with actual model inference logic)
recommendations = [
"Inception (2010)",
"Interstellar (2014)",
"The Matrix (1999)",
"Blade Runner 2049 (2017)",
"The Dark Knight (2008)"
]
return "\n".join(recommendations[:3]) # Return top 3 recommendations
# Example Inputs
example_descriptions = [
"A mind-bending sci-fi thriller about dreams within dreams.",
"A group of superheroes saves the world from an alien invasion.",
"A gripping crime drama featuring a brilliant detective.",
"A heartwarming animated movie about friendship and adventure."
]
# Create Gradio UI
with gr.Blocks() as demo:
gr.Markdown("## 🎬 AI-Powered Movie Recommendation System")
gr.Markdown("Enter a movie description or genre, and the model will suggest similar movies!")
with gr.Row():
input_text = gr.Textbox(label="πŸŽ₯ Enter a movie description or genre:",
placeholder="Example: A sci-fi adventure through space and time.")
recommend_button = gr.Button("πŸ” Get Recommendations")
output_text = gr.Textbox(label="🍿 Recommended Movies:")
gr.Markdown("### 🎭 Example Inputs")
example_buttons = [gr.Button(example) for example in example_descriptions]
for btn in example_buttons:
btn.click(fn=lambda text=btn.value: text, outputs=input_text)
recommend_button.click(recommend_movies, inputs=input_text, outputs=output_text)
# Launch the Gradio app
demo.launch()