Update app.py
Browse files
app.py
CHANGED
|
@@ -124,7 +124,14 @@ def process(text):
|
|
| 124 |
return SAMPLE_RATE, int16_data
|
| 125 |
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
title = "Music gen with GPT-2"
|
|
|
|
| 128 |
|
| 129 |
iface = gr.Interface(
|
| 130 |
fn=process,
|
|
@@ -135,4 +142,12 @@ iface = gr.Interface(
|
|
| 135 |
article="This demo is inspired in the notebook from https://huggingface.co/TristanBehrens/js-fakes-4bars."
|
| 136 |
)
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
iface.launch(debug=True)
|
|
|
|
| 124 |
return SAMPLE_RATE, int16_data
|
| 125 |
|
| 126 |
|
| 127 |
+
def generation(text):
|
| 128 |
+
input_ids = tokenizer.encode(text, return_tensors="pt")
|
| 129 |
+
generated_ids = model.generate(input_ids, max_length=500)
|
| 130 |
+
generated_sequence = tokenizer.decode(generated_ids[0])
|
| 131 |
+
return generated_sequence
|
| 132 |
+
|
| 133 |
title = "Music gen with GPT-2"
|
| 134 |
+
title2 = "Midi token generation"
|
| 135 |
|
| 136 |
iface = gr.Interface(
|
| 137 |
fn=process,
|
|
|
|
| 142 |
article="This demo is inspired in the notebook from https://huggingface.co/TristanBehrens/js-fakes-4bars."
|
| 143 |
)
|
| 144 |
|
| 145 |
+
iface = gr.Interface(
|
| 146 |
+
fn=generation
|
| 147 |
+
inputs=["text"],
|
| 148 |
+
outputs=["text"],
|
| 149 |
+
title=title2,
|
| 150 |
+
article="This will generate the encoded text that represents Midi language."
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
iface.launch(debug=True)
|