Yaron Koresh commited on
Commit
17a8d48
·
verified ·
1 Parent(s): 187f4bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -39
app.py CHANGED
@@ -781,6 +781,7 @@ def pipe_generate_image(p1,p2,h,w):
781
  negative_prompt=p2,
782
  height=h,
783
  width=w,
 
784
  guidance_scale=img_accu,
785
  num_images_per_prompt=1,
786
  num_inference_steps=image_steps,
@@ -815,26 +816,6 @@ def add_song_cover_text(img,artist,song,h,w):
815
 
816
  return img
817
 
818
- def upscale_image(img,factor=2):
819
-
820
- global working
821
-
822
- if working:
823
- return
824
-
825
- working = True
826
-
827
- ret = upscaler(img,upscale_factor=factor)
828
-
829
- working = False
830
-
831
- return ret
832
-
833
- def all_pipes(pos,neg,h,w):
834
-
835
- img = pipe_generate_image(pos,neg,h,w)[0]
836
- return img
837
-
838
  google_translate_endpoint = "https://translate.google.com/m"
839
  language_codes = {
840
  "afrikaans": "af",
@@ -1453,13 +1434,6 @@ def translate(txt,to_lang="en",from_lang="auto"):
1453
  def handle_generation(artist,song,lyrics,h,w):
1454
 
1455
  log(f'CALL handle_generate')
1456
-
1457
- global working
1458
-
1459
- if working:
1460
- return
1461
-
1462
- working = True
1463
 
1464
  pos_artist = re.sub(r"([ \t]){1,}", " ", artist).upper().strip()
1465
 
@@ -1489,16 +1463,7 @@ def handle_generation(artist,song,lyrics,h,w):
1489
  Negative: {neg}
1490
  """)
1491
 
1492
- img = all_pipes(pos,neg,h,w)
1493
-
1494
- labeled_img = add_song_cover_text(img,pos_artist,pos_song,h,w)
1495
- name = f'{generate_random_string(16)}.png'
1496
- labeled_img.save(name)
1497
-
1498
- working = False
1499
-
1500
- # return names
1501
- return name
1502
 
1503
  # entry
1504
 
@@ -1552,7 +1517,7 @@ if __name__ == "__main__":
1552
  )
1553
 
1554
  with gr.Column():
1555
- cover = gr.Image(interactive=False,container=False,elem_classes="image-container", label="Result", show_label=True, type='filepath', show_share_button=False)
1556
  upscale_now = gr.Button("Upscale",elem_classes="btn")
1557
 
1558
  run.click(
@@ -1561,7 +1526,7 @@ if __name__ == "__main__":
1561
  outputs=[cover]
1562
  )
1563
  upscale_now.click(
1564
- fn=upscale_image,
1565
  inputs=[cover],
1566
  outputs=[cover]
1567
  )
 
781
  negative_prompt=p2,
782
  height=h,
783
  width=w,
784
+ output_type="pil",
785
  guidance_scale=img_accu,
786
  num_images_per_prompt=1,
787
  num_inference_steps=image_steps,
 
816
 
817
  return img
818
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
819
  google_translate_endpoint = "https://translate.google.com/m"
820
  language_codes = {
821
  "afrikaans": "af",
 
1434
  def handle_generation(artist,song,lyrics,h,w):
1435
 
1436
  log(f'CALL handle_generate')
 
 
 
 
 
 
 
1437
 
1438
  pos_artist = re.sub(r"([ \t]){1,}", " ", artist).upper().strip()
1439
 
 
1463
  Negative: {neg}
1464
  """)
1465
 
1466
+ return add_song_cover_text(pipe_generate_image(pos,neg,h,w),pos_artist,pos_song,h,w)
 
 
 
 
 
 
 
 
 
1467
 
1468
  # entry
1469
 
 
1517
  )
1518
 
1519
  with gr.Column():
1520
+ cover = gr.Image(interactive=False,container=False,elem_classes="image-container", label="Result", show_label=True, type='pil', show_share_button=False)
1521
  upscale_now = gr.Button("Upscale",elem_classes="btn")
1522
 
1523
  run.click(
 
1526
  outputs=[cover]
1527
  )
1528
  upscale_now.click(
1529
+ fn=upscaler,
1530
  inputs=[cover],
1531
  outputs=[cover]
1532
  )