Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the model from Hugging Face
|
5 |
+
model_pipeline = pipeline("text-generation", model="Mar2Ding/songcomposer_sft")
|
6 |
+
|
7 |
+
# Define the function for text generation
|
8 |
+
def generate_song(prompt):
|
9 |
+
result = model_pipeline(prompt, max_length=50)
|
10 |
+
return result[0]['generated_text']
|
11 |
+
|
12 |
+
# Set up the Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=generate_song, # The function to call
|
15 |
+
inputs="text", # The input type (text box for user input)
|
16 |
+
outputs="text", # The output type (generated text)
|
17 |
+
live=True # Whether to generate live as the user types
|
18 |
+
)
|
19 |
+
|
20 |
+
# Launch the Gradio interface
|
21 |
+
iface.launch()
|