Spaces:
Running
on
Zero
Running
on
Zero
drscotthawley
commited on
Commit
•
867f599
1
Parent(s):
10a1c4d
switched to Blocks version from Interface
Browse files- app.py +52 -14
- pom_mask_shrunk.png +0 -0
app.py
CHANGED
@@ -172,18 +172,56 @@ def process_image(image, repaint, busyness):
|
|
172 |
|
173 |
make_dict = lambda x: {'background':x, 'composite':x, 'layers':[x]}
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
demo.queue().launch()
|
|
|
172 |
|
173 |
make_dict = lambda x: {'background':x, 'composite':x, 'layers':[x]}
|
174 |
|
175 |
+
markdown_str = gr.Markdown(
|
176 |
+
"""
|
177 |
+
# Hello World!
|
178 |
+
Start typing below to see the output.
|
179 |
+
""")
|
180 |
+
|
181 |
+
with gr.Blocks() as demo:
|
182 |
+
gr.Markdown(
|
183 |
+
"""
|
184 |
+
# Pictures of MIDI
|
185 |
+
Choose from the examples at the bottom, and/or select the 'draw' tool (pen with a squiggle on it) to draw shapes to inpaint with notes.
|
186 |
+
White denotes regions to inpaint. (In the paper we used blue.)
|
187 |
+
""")
|
188 |
+
with gr.Row():
|
189 |
+
with gr.Column():
|
190 |
+
in_img = gr.ImageEditor(sources=["upload",'clipboard'], label="Input Piano Roll Image (White = Gen Notes Here)", value=make_dict('all_black.png'), brush=gr.Brush(colors=["#FFFFFF","#000000"]))
|
191 |
+
repaint = gr.Slider(minimum=1, maximum=10, step=1, value=2, label="RePaint (Larger = More Notes, But Crazier. Also Slower.)")
|
192 |
+
busyness = gr.Slider(minimum=1, maximum=100, step=1, value=100, label="Busy-ness Percentile (Based on Notes Generated)")
|
193 |
+
with gr.Column():
|
194 |
+
out_img = gr.Image(width=512, height=128, label='Generated Piano Roll Image')
|
195 |
+
out_midi = gr.HTML(label="MIDI Player")
|
196 |
+
out_audio = gr.Audio(label="MIDI as Audio")
|
197 |
+
|
198 |
+
inp = [in_img, repaint, busyness]
|
199 |
+
out = [out_img, out_midi, out_audio]
|
200 |
+
|
201 |
+
btn = gr.Button("Submit")
|
202 |
+
btn.click(fn=process_image, inputs=inp, outputs=out)
|
203 |
+
|
204 |
+
exam = gr.Examples(
|
205 |
+
examples=#[
|
206 |
+
[[make_dict(y),1,100] for y in ['all_white.png','all_black.png','init_img_melody.png','init_img_accomp.png','init_img_cont.png',]]+
|
207 |
+
[[make_dict(x),2,100] for x in ['584_TOTAL_crop.png', '780_TOTAL_crop_bg.png', '780_TOTAL_crop_draw.png','loop_middle_2.png']]+
|
208 |
+
[[make_dict(z),3,100] for z in ['584_TOTAL_crop_draw.png','loop_middle.png']] +
|
209 |
+
[[make_dict('pom_mask_shrunk.png'),6,100]]
|
210 |
+
,#],
|
211 |
+
fn=process_image, inputs=inp, outputs=out, examples_per_page=50, run_on_click=False, cache_examples='lazy')
|
212 |
+
|
213 |
+
|
214 |
+
# old 'Interface' version
|
215 |
+
# demo = gr.Interface(fn=process_image,
|
216 |
+
# inputs=[gr.ImageEditor(sources=["upload",'clipboard'], label="Input Piano Roll Image (White = Gen Notes Here)", value=make_dict('all_black.png'), brush=gr.Brush(colors=["#FFFFFF","#000000"])),
|
217 |
+
# gr.Slider(minimum=1, maximum=10, step=1, value=2, label="RePaint (Larger = More Notes, But Crazier. Also Slower.)"),
|
218 |
+
# gr.Slider(minimum=1, maximum=100, step=1, value=100, label="Busy-ness Percentile (Based on Notes Generated)")],
|
219 |
+
# outputs=[gr.Image(width=512, height=128, label='Generated Piano Roll Image'),
|
220 |
+
# gr.HTML(label="MIDI Player"),
|
221 |
+
# gr.Audio(label="MIDI as Audio")],
|
222 |
+
# examples= [[make_dict(y),1,100] for y in ['all_white.png','all_black.png','init_img_melody.png','init_img_accomp.png','init_img_cont.png',]]+
|
223 |
+
# [[make_dict(x),2,100] for x in ['584_TOTAL_crop.png', '780_TOTAL_crop_bg.png', '780_TOTAL_crop_draw.png','loop_middle_2.png']]+
|
224 |
+
# [[make_dict(z),3,100] for z in ['584_TOTAL_crop_draw.png','loop_middle.png']] +
|
225 |
+
# [[make_dict('ismir_mask_2.png'),6,100]],
|
226 |
+
# )
|
227 |
demo.queue().launch()
|
pom_mask_shrunk.png
ADDED