|
import gradio as gr
|
|
from transformers import pipeline
|
|
|
|
|
|
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."
|
|
|
|
|
|
recommendations = [
|
|
"Inception (2010)",
|
|
"Interstellar (2014)",
|
|
"The Matrix (1999)",
|
|
"Blade Runner 2049 (2017)",
|
|
"The Dark Knight (2008)"
|
|
]
|
|
|
|
return "\n".join(recommendations[:3])
|
|
|
|
|
|
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."
|
|
]
|
|
|
|
|
|
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)
|
|
|
|
|
|
demo.launch() |