Spaces:
Runtime error
Runtime error
File size: 941 Bytes
91f0321 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
import torch
# Load pre-trained model and tokenizer
model_name = "gpt2"
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Function to generate remix
def generate_remix(input_text):
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
output = model.generate(input_ids)
output_text = tokenizer.decode(output[0], skip_special_tokens=True)
return output_text
# Create Gradio interface
inputs = gr.inputs.Textbox(lines=5, label="Input Song Lyrics")
outputs = gr.outputs.Textbox(label="Remixed Song Lyrics")
title = "Song Remixing Tool"
description = "Enter the lyrics of a song and get a remix!"
examples = [["I'm feeling good", "Feeling happy tonight"]]
gr.Interface(generate_remix, inputs, outputs, title=title, description=description, examples=examples).launch()
|