Spaces:
Runtime error
Runtime error
Download app.py from Alif737/Song-Expander: direct link, hf CLI and curl.
- Browser
- Download file 753 Bytes
-
https://huggingface.co/spaces/Alif737/Song-Expander/resolve/main/app.py
- Command line
-
hf download hf://spaces/Alif737/Song-Expander/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Alif737/Song-Expander/resolve/main/app.py
753 Bytes
| pip install transformers | |
| pip install gradio | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import gradio as gr | |
| model_name = "Song-extender-333" # Replace with the name of your pre-trained model | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForCausalLM.from_pretrained(model_name).cuda() | |
| def extend_music(music_text): | |
| input_ids = tokenizer.encode(music_text, return_tensors='pt').cuda() | |
| output = model.generate(input_ids, max_length=8*60+50, pad_token_id=tokenizer.pad_token_id) | |
| extended_music = tokenizer.decode(output[0], skip_special_tokens=True) | |
| return extended_music | |
| iface = gr.Interface(fn=extend_music, inputs="text", outputs="text", title="Music Extender") | |
| iface.launch() | |