Fucius commited on
Commit
cb848fa
1 Parent(s): 88aa242

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -71
app.py CHANGED
@@ -496,87 +496,87 @@ def main(device, segment_type):
496
  def get_local_value_woman(input):
497
  return character_woman[input][0]
498
 
499
- @spaces.GPU
500
- def generate(prompt):
501
- res = (os.system(prompt))
502
- return res
503
-
504
- gr.Interface(
505
- fn=generate,
506
- inputs=gr.Text(),
507
- outputs=gr.Text(),
508
- ).launch()
509
-
510
- # with gr.Blocks(css=css) as demo:
511
- # # description
512
- # gr.Markdown(title)
513
- # gr.Markdown(description)
514
 
515
- # with gr.Row():
516
- # gallery = gr.Image(label="Generated Images", height=512, width=512)
517
- # gen_condition = gr.Image(label="Spatial Condition", height=512, width=512)
518
- # usage_tips = gr.Markdown(label="Usage tips of OMG", value=tips, visible=False)
519
 
520
- # with gr.Row():
521
- # condition_img1 = gr.Image(label="Input an RGB image for condition", height=128, width=128)
522
 
523
- # # character choose
524
- # with gr.Row():
525
- # man = gr.Dropdown(label="Character 1 selection", choices=CHARACTER_MAN_NAMES, value="Chris Evans (identifier: Chris Evans)")
526
- # woman = gr.Dropdown(label="Character 2 selection", choices=CHARACTER_WOMAN_NAMES, value="Taylor Swift (identifier: TaylorSwift)")
527
- # resolution = gr.Dropdown(label="Image Resolution (width*height)", choices=resolution_list, value="1024*1024")
528
- # condition = gr.Dropdown(label="Input condition type", choices=condition_list, value="None")
529
- # style = gr.Dropdown(label="style", choices=STYLE_NAMES, value="None")
530
 
531
- # with gr.Row():
532
- # local_prompt1 = gr.Textbox(label="Character1_prompt",
533
- # info="Describe the Character 1, this prompt should include the identifier of character 1",
534
- # value="Close-up photo of the Chris Evans, 35mm photograph, film, professional, 4k, highly detailed.")
535
- # local_prompt2 = gr.Textbox(label="Character2_prompt",
536
- # info="Describe the Character 2, this prompt should include the identifier of character2",
537
- # value="Close-up photo of the TaylorSwift, 35mm photograph, film, professional, 4k, highly detailed.")
538
 
539
- # man.change(get_local_value_man, man, local_prompt1)
540
- # woman.change(get_local_value_woman, woman, local_prompt2)
541
 
542
- # # prompt
543
- # with gr.Column():
544
- # prompt = gr.Textbox(label="Prompt 1",
545
- # info="Give a simple prompt to describe the first image content",
546
- # placeholder="Required",
547
- # value="close-up shot, photography, a man and a woman on the street, facing the camera smiling")
548
 
549
 
550
- # with gr.Accordion(open=False, label="Advanced Options"):
551
- # seed = gr.Slider(
552
- # label="Seed",
553
- # minimum=0,
554
- # maximum=MAX_SEED,
555
- # step=1,
556
- # value=42,
557
- # )
558
- # negative_prompt = gr.Textbox(label="Negative Prompt",
559
- # placeholder="noisy, blurry, soft, deformed, ugly",
560
- # value="noisy, blurry, soft, deformed, ugly")
561
- # randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
562
 
563
- # submit = gr.Button("Submit", variant="primary")
564
 
565
- # submit.click(
566
- # fn=remove_tips,
567
- # outputs=usage_tips,
568
- # ).then(
569
- # fn=randomize_seed_fn,
570
- # inputs=[seed, randomize_seed],
571
- # outputs=seed,
572
- # queue=False,
573
- # api_name=False,
574
- # ).then(
575
- # fn=generate_image,
576
- # inputs=[prompt, negative_prompt, man, woman, resolution, local_prompt1, local_prompt2, seed, condition, condition_img1, style],
577
- # outputs=[gallery, gen_condition]
578
- # )
579
- # demo.launch(share=True)
580
 
581
  def parse_args():
582
  parser = argparse.ArgumentParser('', add_help=False)
 
496
  def get_local_value_woman(input):
497
  return character_woman[input][0]
498
 
499
+ # @spaces.GPU
500
+ # def generate(prompt):
501
+ # res = (os.system(prompt))
502
+ # return res
503
+
504
+ # gr.Interface(
505
+ # fn=generate,
506
+ # inputs=gr.Text(),
507
+ # outputs=gr.Text(),
508
+ # ).launch()
509
+
510
+ with gr.Blocks(css=css) as demo:
511
+ # description
512
+ gr.Markdown(title)
513
+ gr.Markdown(description)
514
 
515
+ with gr.Row():
516
+ gallery = gr.Image(label="Generated Images", height=512, width=512)
517
+ gen_condition = gr.Image(label="Spatial Condition", height=512, width=512)
518
+ usage_tips = gr.Markdown(label="Usage tips of OMG", value=tips, visible=False)
519
 
520
+ with gr.Row():
521
+ condition_img1 = gr.Image(label="Input an RGB image for condition", height=128, width=128)
522
 
523
+ # character choose
524
+ with gr.Row():
525
+ man = gr.Dropdown(label="Character 1 selection", choices=CHARACTER_MAN_NAMES, value="Chris Evans (identifier: Chris Evans)")
526
+ woman = gr.Dropdown(label="Character 2 selection", choices=CHARACTER_WOMAN_NAMES, value="Taylor Swift (identifier: TaylorSwift)")
527
+ resolution = gr.Dropdown(label="Image Resolution (width*height)", choices=resolution_list, value="1024*1024")
528
+ condition = gr.Dropdown(label="Input condition type", choices=condition_list, value="None")
529
+ style = gr.Dropdown(label="style", choices=STYLE_NAMES, value="None")
530
 
531
+ with gr.Row():
532
+ local_prompt1 = gr.Textbox(label="Character1_prompt",
533
+ info="Describe the Character 1, this prompt should include the identifier of character 1",
534
+ value="Close-up photo of the Chris Evans, 35mm photograph, film, professional, 4k, highly detailed.")
535
+ local_prompt2 = gr.Textbox(label="Character2_prompt",
536
+ info="Describe the Character 2, this prompt should include the identifier of character2",
537
+ value="Close-up photo of the TaylorSwift, 35mm photograph, film, professional, 4k, highly detailed.")
538
 
539
+ man.change(get_local_value_man, man, local_prompt1)
540
+ woman.change(get_local_value_woman, woman, local_prompt2)
541
 
542
+ # prompt
543
+ with gr.Column():
544
+ prompt = gr.Textbox(label="Prompt 1",
545
+ info="Give a simple prompt to describe the first image content",
546
+ placeholder="Required",
547
+ value="close-up shot, photography, a man and a woman on the street, facing the camera smiling")
548
 
549
 
550
+ with gr.Accordion(open=False, label="Advanced Options"):
551
+ seed = gr.Slider(
552
+ label="Seed",
553
+ minimum=0,
554
+ maximum=MAX_SEED,
555
+ step=1,
556
+ value=42,
557
+ )
558
+ negative_prompt = gr.Textbox(label="Negative Prompt",
559
+ placeholder="noisy, blurry, soft, deformed, ugly",
560
+ value="noisy, blurry, soft, deformed, ugly")
561
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
562
 
563
+ submit = gr.Button("Submit", variant="primary")
564
 
565
+ submit.click(
566
+ fn=remove_tips,
567
+ outputs=usage_tips,
568
+ ).then(
569
+ fn=randomize_seed_fn,
570
+ inputs=[seed, randomize_seed],
571
+ outputs=seed,
572
+ queue=False,
573
+ api_name=False,
574
+ ).then(
575
+ fn=generate_image,
576
+ inputs=[prompt, negative_prompt, man, woman, resolution, local_prompt1, local_prompt2, seed, condition, condition_img1, style],
577
+ outputs=[gallery, gen_condition]
578
+ )
579
+ demo.launch(share=True)
580
 
581
  def parse_args():
582
  parser = argparse.ArgumentParser('', add_help=False)