stevengrove commited on
Commit
b183480
Β·
verified Β·
1 Parent(s): c120097

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -31,7 +31,7 @@ def understand_func(
31
 
32
  @spaces.GPU
33
  def generate_func(
34
- text, use_cot, height, width, guidance_scale, inference_steps, seed, separate_cfg_infer, offload_model, max_input_image_size, randomize_seed, save_images, do_sample, temperature, max_new_tokens, input_llm_images, only_understand):
35
  if input_llm_images is not None and not isinstance(input_llm_images, list):
36
  input_llm_images = [input_llm_images]
37
 
@@ -41,7 +41,8 @@ def generate_func(
41
  print(f'Generate image prompt: {text}')
42
  output, prompt_ = MindOmni_model.generate_image(
43
  height, width, guidance_scale, inference_steps, separate_cfg_infer, offload_model, seed, max_input_image_size,
44
- text, NEGATIVE_PROMPT, input_llm_images, do_sample, temperature, max_new_tokens, only_understand, use_cot=use_cot)
 
45
  print('Generation finished.')
46
 
47
  img = output[0]
@@ -74,8 +75,9 @@ def build_gradio():
74
  g_btn = gr.Button("πŸš€ Generate Image")
75
 
76
  with gr.Accordion("πŸ“š Image Generation Args"):
77
- g_use_cot = gr.Checkbox(label="With thinking", value=False)
78
- g_do_sample = gr.Checkbox(label="Do sample", value=False)
 
79
  g_temperature = gr.Slider(0, 10, value=1, label="Temperature")
80
  g_max_new_tok = gr.Slider(32, 8192, value=512, label="Max new tokens")
81
 
@@ -99,25 +101,25 @@ def build_gradio():
99
  with gr.Accordion("πŸ–ΌοΈ Prompt Examples: Text-only"):
100
  gr.Examples(
101
  examples=[
102
- ["Futuristic city skyline at sunset, digital art", 42, False, False, False, 1024, 1024, "assets/example_outputs/case_1.png"],
103
- ["An image of China's national treasure animal.", 42, False, True, False, 1024, 1024, "assets/example_outputs/case_2.png"],
104
- ["Scene in the Sydney Opera House when New York is at noon.", 42, False, True, False, 1024, 1024, "assets/example_outputs/case_3.png"],
105
- ["Generate an image of an animal with (3 + 6) lives", 7393438, False, True, False, 1024, 1024, "assets/example_outputs/case_4.png"],
106
  ],
107
- inputs=[g_prompt, g_seed, g_rand, g_use_cot, g_do_sample, g_height, g_width, g_out_img],
108
  )
109
  with gr.Accordion("πŸ–ΌοΈ Prompt Examples: With reference image"):
110
  gr.Examples(
111
  examples=[
112
- ["An image of the animal growing up", "assets/tapdole.jpeg", 42, False, True, True, 1024, 1024, "assets/example_outputs/case_5.png"]
113
  ],
114
- inputs=[g_prompt, g_image, g_seed, g_rand, g_use_cot, g_do_sample, g_height, g_width, g_out_img],
115
  )
116
 
117
  g_btn.click(
118
  generate_func,
119
- inputs=[g_prompt, g_use_cot, g_height, g_width, g_scale, g_steps,
120
- g_seed, g_sep_cfg, g_offload, g_max_img, g_rand, g_save,
121
  g_do_sample, g_temperature, g_max_new_tok,
122
  g_image, gr.State(False)], # only_understand=False
123
  outputs=[g_out_img, g_prompt_out, g_seed_out])
 
31
 
32
  @spaces.GPU
33
  def generate_func(
34
+ MindOmni_model, text, use_cot, cascade_thinking, height, width, guidance_scale, inference_steps, seed, separate_cfg_infer, offload_model, max_input_image_size, randomize_seed, save_images, do_sample, temperature, max_new_tokens, input_llm_images, only_understand):
35
  if input_llm_images is not None and not isinstance(input_llm_images, list):
36
  input_llm_images = [input_llm_images]
37
 
 
41
  print(f'Generate image prompt: {text}')
42
  output, prompt_ = MindOmni_model.generate_image(
43
  height, width, guidance_scale, inference_steps, separate_cfg_infer, offload_model, seed, max_input_image_size,
44
+ text, NEGATIVE_PROMPT, input_llm_images, do_sample, temperature, max_new_tokens, only_understand, use_cot=use_cot,
45
+ cascade_thinking=cascade_thinking)
46
  print('Generation finished.')
47
 
48
  img = output[0]
 
75
  g_btn = gr.Button("πŸš€ Generate Image")
76
 
77
  with gr.Accordion("πŸ“š Image Generation Args"):
78
+ g_use_cot = gr.Checkbox(label="Use thinking", value=False)
79
+ g_cascade_thinking = gr.Checkbox(label="Cascade thinking (experimental for better quality)", value=False)
80
+ g_do_sample = gr.Checkbox(label="Do sample (for more diversity)", value=False)
81
  g_temperature = gr.Slider(0, 10, value=1, label="Temperature")
82
  g_max_new_tok = gr.Slider(32, 8192, value=512, label="Max new tokens")
83
 
 
101
  with gr.Accordion("πŸ–ΌοΈ Prompt Examples: Text-only"):
102
  gr.Examples(
103
  examples=[
104
+ ["Futuristic city skyline at sunset, digital art", 42, False, False, False, False, 1024, 1024, "assets/example_outputs/case_1.png"],
105
+ ["An image of China's national treasure animal.", 42, False, True, False, False, 1024, 1024, "assets/example_outputs/case_2.png"],
106
+ ["Scene in the Sydney Opera House when New York is at noon.", 42, False, True, False, False, 1024, 1024, "assets/example_outputs/case_3.png"],
107
+ ["Generate an image of an animal with (3 + 6) lives", 7393438, False, True, False, False, 1024, 1024, "assets/example_outputs/case_4.png"],
108
  ],
109
+ inputs=[g_prompt, g_seed, g_rand, g_use_cot, g_cascade_thinking, g_do_sample, g_height, g_width, g_out_img],
110
  )
111
  with gr.Accordion("πŸ–ΌοΈ Prompt Examples: With reference image"):
112
  gr.Examples(
113
  examples=[
114
+ ["An image of the animal growing up", "assets/tapdole.jpeg", 42, False, True, False, True, 1024, 1024, "assets/example_outputs/case_5.png"]
115
  ],
116
+ inputs=[g_prompt, g_image, g_seed, g_rand, g_use_cot, g_cascade_thinking, g_do_sample, g_height, g_width, g_out_img],
117
  )
118
 
119
  g_btn.click(
120
  generate_func,
121
+ inputs=[g_prompt, g_use_cot, g_cascade_thinking, g_height, g_width, g_scale,
122
+ g_steps, g_seed, g_sep_cfg, g_offload, g_max_img, g_rand, g_save,
123
  g_do_sample, g_temperature, g_max_new_tok,
124
  g_image, gr.State(False)], # only_understand=False
125
  outputs=[g_out_img, g_prompt_out, g_seed_out])