Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -85,4 +85,49 @@ def generate_beatles(input_prompt, temperature, top_p, given_input_style):
|
|
85 |
|
86 |
# Generate the image
|
87 |
image = get_image(image_input)
|
88 |
-
return (title, generated_lyrics, image, image_style)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
# Generate the image
|
87 |
image = get_image(image_input)
|
88 |
+
return (title, generated_lyrics, image, image_style)
|
89 |
+
|
90 |
+
# Create textboxes for input and output
|
91 |
+
input_box = gr.Textbox(label="Write the start of a song here", placeholder="Write the start of a new song here", value="Looking out of my window", lines=2, max_lines=5)
|
92 |
+
gen_lyrics = gr.Textbox(label="Song lyrics", lines=15)
|
93 |
+
gen_title = gr.Textbox(label="Proposed songtitle", lines=1)
|
94 |
+
gen_image = gr.Gallery(label="Proposed song cover").style(grid=1, height="auto")
|
95 |
+
gen_image_style = gr.Textbox(label="Image style", lines=1)
|
96 |
+
|
97 |
+
# Layout and text around the app
|
98 |
+
title='Beatles lyrics generator'
|
99 |
+
description="<p style='text-align: center'>We've fine-tuned multiple language models on lyrics from The Beatles to generate Beatles-like text. Below are the results we obtained fine-tuning a GPT Neo model. After generation a title is generated using <a href='https://huggingface.co/czearing/story-to-title' target='_blank'>this model</a>. On top we use the generated title to suggest an album cover using <a href='https://huggingface.co/CompVis/stable-diffusion-v1-4' target='_blank'>Stable Diffusion 1.4</a>. Give it a try!</p>"
|
100 |
+
article="""<p style='text-align: left'>These text generation models that output Beatles-like text were created by data scientists working for <a href='https://cmotions.nl/' target="_blank">Cmotions.</a>
|
101 |
+
We tried several text generation models that we were able to load in Colab: a general <a href='https://huggingface.co/gpt2-medium' target='_blank'>GPT2-medium</a> model, the Eleuther AI small-sized GPT model <a href='https://huggingface.co/EleutherAI/gpt-neo-125M' target='_blank'>GPT-Neo</a> and the new kid on the block build by the <a href='https://bigscience.notion.site/BLOOM-BigScience-176B-Model-ad073ca07cdf479398d5f95d88e218c4' target='_blank'>Bigscience</a> initiative <a href='https://huggingface.co/bigscience/bloom-560m' target='_blank'>BLOOM 560m</a>.
|
102 |
+
Further we've put together a <a href='https://huggingface.co/datasets/cmotions/Beatles_lyrics' target='_blank'> Huggingface dataset</a> containing all known lyrics created by The Beatles. Currently we are fine-tuning models and are evaluating the results. Once finished we will publish a blog at this <a href='https://www.theanalyticslab.nl/blogs/' target='_blank'>location </a> with all the steps we took including a Python notebook using Huggingface.
|
103 |
+
The default output contains 100 tokens and has a repetition penalty of 1.0.
|
104 |
+
</p>"""
|
105 |
+
css = """
|
106 |
+
.gr-button-primary {
|
107 |
+
text-indent: -9999px;
|
108 |
+
line-height: 0;
|
109 |
+
}
|
110 |
+
.gr-button-primary:after {
|
111 |
+
content: "Beatlify!";
|
112 |
+
text-indent: 0;
|
113 |
+
display: block;
|
114 |
+
line-height: initial;
|
115 |
+
}
|
116 |
+
"""
|
117 |
+
|
118 |
+
# Let users select their own temperature and top-p
|
119 |
+
temperature = gr.Slider(minimum=0.1, maximum=1.0, step=0.1, label="Change the temperature \r\n (higher temperature = more creative in lyrics generation, but posibbly less Beatly)", value=0.7, show_label=True) #high = sensitive for low probability tokens
|
120 |
+
top_p = gr.Slider(minimum=0.1, maximum=1.0, step=0.1, label="Change top probability of the next word \n (higher top probability = more words to choose from for the next word, but possibly less Beatly)", value=0.5, show_label=True)
|
121 |
+
given_input_style = gr.Dropdown(choices=image_input_styles, value="Random", label="Choose the art style for the lyrics cover", show_label=True)
|
122 |
+
#checkpoint = gr.Radio(checkpoint_choices, value='wvangils/GPT-Medium-Beatles-Lyrics-finetuned-newlyrics', interactive=True, label = 'Select fine-tuned model', show_label=True)
|
123 |
+
|
124 |
+
# Use generate Beatles function in demo-app Gradio
|
125 |
+
gr.Interface(fn=generate_beatles
|
126 |
+
, inputs=[input_box, temperature, top_p, given_input_style]
|
127 |
+
, outputs=[gen_title, gen_lyrics, gen_image, gen_image_style]
|
128 |
+
, title=title
|
129 |
+
, css=css
|
130 |
+
, description=description
|
131 |
+
, article=article
|
132 |
+
, allow_flagging='never'
|
133 |
+
).launch()
|