| import gradio as gr |
| import torch |
| from lightgcn import GNN |
|
|
| |
| |
|
|
| |
| class SpotifyRecommender: |
| def __init__(self): |
| self.model = GNN(embedding_dim=64, num_nodes=100, num_playlists=50, num_layers=2) |
| |
| |
| self.model.load_state_dict(torch.load("pesos_modelo.pth")) |
|
|
| |
| |
| self.playlist_data = cargar_datos("playlist_info.json") |
| self.song_data = cargar_datos("song_info.json") |
|
|
| def recommend(self, input_text): |
| |
| |
| |
| canciones_recomendadas = self.model.recommend(playlist_id, self.song_data) |
| return canciones_recomendadas |
| return f"隆Hola, has ingresado: {input_text}! Esto es una recomendaci贸n de canciones." |
|
|
| |
| recommender_instance = SpotifyRecommender() |
|
|
| |
| def recommend(input_text): |
| return recommender_instance.recommend(input_text) |
|
|
| |
| iface = gr.Interface( |
| fn=recommend, |
| inputs="text", |
| outputs="text", |
| title="Recomendador de Canciones en Spotify", |
| description="Ingresa un texto y obt茅n una recomendaci贸n de canciones.", |
| ) |
|
|
| |
| iface.launch() |
|
|