Spaces:
Runtime error
Runtime error
Download app.py from Alif737/Deep-Remix: direct link, hf CLI and curl.
- Browser
- Download file 941 Bytes
-
https://huggingface.co/spaces/Alif737/Deep-Remix/resolve/main/app.py
- Command line
-
hf download hf://spaces/Alif737/Deep-Remix/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Alif737/Deep-Remix/resolve/main/app.py
941 Bytes
| 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() | |