Alif737 commited on
Commit
a5ac72f
·
verified ·
1 Parent(s): 6cbceac
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pip install transformers
2
+
3
+ pip install gradio
4
+
5
+ import torch
6
+ from transformers import AutoModelForCausalLM, AutoTokenizer
7
+ import gradio as gr
8
+
9
+ model_name = "Song-extender-333" # Replace with the name of your pre-trained model
10
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
11
+ model = AutoModelForCausalLM.from_pretrained(model_name).cuda()
12
+
13
+ def extend_music(music_text):
14
+ input_ids = tokenizer.encode(music_text, return_tensors='pt').cuda()
15
+ output = model.generate(input_ids, max_length=8*60+50, pad_token_id=tokenizer.pad_token_id)
16
+ extended_music = tokenizer.decode(output[0], skip_special_tokens=True)
17
+ return extended_music
18
+
19
+ iface = gr.Interface(fn=extend_music, inputs="text", outputs="text", title="Music Extender")
20
+ iface.launch()