asigalov61 commited on
Commit
2c8f67f
1 Parent(s): dad27b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -12
app.py CHANGED
@@ -25,14 +25,9 @@ import TPLOTS
25
  from midi_to_colab_audio import midi_to_colab_audio
26
 
27
  # =================================================================================================
28
-
29
  @spaces.GPU
30
- def Generate_POP_Medley(input_num_medley_comps):
31
-
32
- print('=' * 70)
33
- print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
34
- start_time = reqtime.time()
35
- print('=' * 70)
36
 
37
  print('Loading model...')
38
 
@@ -72,13 +67,16 @@ def Generate_POP_Medley(input_num_medley_comps):
72
  print('=' * 70)
73
  print('Done!')
74
  print('=' * 70)
75
-
76
- print('Req number of medley compositions:', input_num_medley_comps)
 
 
77
 
78
  print('=' * 70)
79
- print('Generating...')
 
80
 
81
- images = trainer.sample(batch_size = input_num_medley_comps, return_pil_images = True)
82
 
83
  threshold = 128
84
 
@@ -90,13 +88,30 @@ def Generate_POP_Medley(input_num_medley_comps):
90
  imgs_array.append(farr)
91
 
92
  print('Done!')
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  print('=' * 70)
94
 
95
  #===============================================================================
96
 
 
 
 
 
 
97
  print('Converting images to scores...')
98
 
99
-
100
  medley_compositions_escores = []
101
 
102
  for i in imgs_array:
@@ -193,6 +208,8 @@ if __name__ == "__main__":
193
  "This is a demo for MIDI Images dataset\n\n"
194
  "Please see [MIDI Images](https://huggingface.co/datasets/asigalov61/MIDI-Images) Hugging Face repo for more information\n\n"
195
  )
 
 
196
 
197
  input_num_medley_comps = gr.Slider(1, 12, value=8, step=1, label="Number of medley compositions")
198
 
 
25
  from midi_to_colab_audio import midi_to_colab_audio
26
 
27
  # =================================================================================================
28
+
29
  @spaces.GPU
30
+ def generate_MIDI_images(num_images):
 
 
 
 
 
31
 
32
  print('Loading model...')
33
 
 
67
  print('=' * 70)
68
  print('Done!')
69
  print('=' * 70)
70
+ print('Generating...')
71
+ print('=' * 70)
72
+
73
+ images = trainer.sample(batch_size = input_num_medley_comps, return_pil_images = True)
74
 
75
  print('=' * 70)
76
+ print('Done!')
77
+ print('=' * 70)
78
 
79
+ print('Processing...')
80
 
81
  threshold = 128
82
 
 
88
  imgs_array.append(farr)
89
 
90
  print('Done!')
91
+
92
+ return imgs_array
93
+
94
+ # =================================================================================================
95
+
96
+ def Generate_POP_Medley(input_num_medley_comps):
97
+
98
+ print('=' * 70)
99
+ print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
100
+ start_time = reqtime.time()
101
+ print('=' * 70)
102
+
103
+ print('Req number of medley compositions:', input_num_medley_comps)
104
  print('=' * 70)
105
 
106
  #===============================================================================
107
 
108
+ imgs_array = generate_MIDI_images(input_num_medley_comps)
109
+
110
+ #===============================================================================
111
+
112
+ print('=' * 70)
113
  print('Converting images to scores...')
114
 
 
115
  medley_compositions_escores = []
116
 
117
  for i in imgs_array:
 
208
  "This is a demo for MIDI Images dataset\n\n"
209
  "Please see [MIDI Images](https://huggingface.co/datasets/asigalov61/MIDI-Images) Hugging Face repo for more information\n\n"
210
  )
211
+
212
+ gr.Markdown("Choose medley settings")
213
 
214
  input_num_medley_comps = gr.Slider(1, 12, value=8, step=1, label="Number of medley compositions")
215