hanjian.thu123 commited on
Commit
edde186
·
1 Parent(s): 40e5b16

[update] add temperature

Browse files
Files changed (2) hide show
  1. app.py +9 -7
  2. grn_pipeline.py +2 -0
app.py CHANGED
@@ -26,7 +26,7 @@ def load_pipeline():
26
 
27
  # @spaces.GPU #[uncomment to use ZeroGPU]
28
  @spaces.GPU(duration=40)
29
- def generate(prompt, content_type="image", guidance_scale=3.0, seed=42, width=1024, height=1024):
30
  global pipe
31
  if pipe is None:
32
  try:
@@ -40,6 +40,7 @@ def generate(prompt, content_type="image", guidance_scale=3.0, seed=42, width=10
40
  result = pipe(
41
  prompt=prompt,
42
  guidance_scale=guidance_scale,
 
43
  content_type=content_type,
44
  seed=seed,
45
  width=width,
@@ -77,6 +78,7 @@ def create_demo():
77
 
78
  with gr.Accordion("Settings", open=True):
79
  guidance_scale = gr.Slider(minimum=0, maximum=10, value=3.0, label="Guidance Scale")
 
80
  seed = gr.Number(value=42, label="Seed", precision=0)
81
  width = gr.Number(value=1024, label="Width", precision=0)
82
  height = gr.Number(value=1024, label="Height", precision=0)
@@ -86,24 +88,24 @@ def create_demo():
86
  with gr.Column():
87
  output = gr.Gallery(label="Output", show_label=True, elem_id="gallery", columns=1, height="auto", preview=True, object_fit="contain")
88
 
89
- def generate_and_display(prompt, content_type, guidance_scale, seed, width, height):
90
- result = generate(prompt, content_type, guidance_scale, seed, width, height)
91
  if result:
92
  return [result]
93
  return []
94
 
95
  generate_btn.click(
96
  fn=generate_and_display,
97
- inputs=[prompt_input, content_type, guidance_scale, seed, width, height],
98
  outputs=output
99
  )
100
 
101
  gr.Examples(
102
  examples=[
103
- ["A majestic lion standing on a cliff at sunset", "image", 3.0, 42, 1024, 1024],
104
- ["A dog chasing a butterfly in a meadow", "video", 3.0, 123, 1024, 1024],
105
  ],
106
- inputs=[prompt_input, content_type, guidance_scale, seed, width, height],
107
  cache_examples=False
108
  )
109
 
 
26
 
27
  # @spaces.GPU #[uncomment to use ZeroGPU]
28
  @spaces.GPU(duration=40)
29
+ def generate(prompt, content_type="image", guidance_scale=3.0, temperature=1.0, seed=42, width=1024, height=1024):
30
  global pipe
31
  if pipe is None:
32
  try:
 
40
  result = pipe(
41
  prompt=prompt,
42
  guidance_scale=guidance_scale,
43
+ temperature=temperature,
44
  content_type=content_type,
45
  seed=seed,
46
  width=width,
 
78
 
79
  with gr.Accordion("Settings", open=True):
80
  guidance_scale = gr.Slider(minimum=0, maximum=10, value=3.0, label="Guidance Scale")
81
+ temperature = gr.Slider(minimum=0.1, maximum=1.5, value=1.0, label="Temperature")
82
  seed = gr.Number(value=42, label="Seed", precision=0)
83
  width = gr.Number(value=1024, label="Width", precision=0)
84
  height = gr.Number(value=1024, label="Height", precision=0)
 
88
  with gr.Column():
89
  output = gr.Gallery(label="Output", show_label=True, elem_id="gallery", columns=1, height="auto", preview=True, object_fit="contain")
90
 
91
+ def generate_and_display(prompt, content_type, guidance_scale, temperature, seed, width, height):
92
+ result = generate(prompt, content_type, guidance_scale, temperature, seed, width, height)
93
  if result:
94
  return [result]
95
  return []
96
 
97
  generate_btn.click(
98
  fn=generate_and_display,
99
+ inputs=[prompt_input, content_type, guidance_scale, temperature, seed, width, height],
100
  outputs=output
101
  )
102
 
103
  gr.Examples(
104
  examples=[
105
+ ["A majestic lion standing on a cliff at sunset", "image", 3.0, 1.0, 42, 1024, 1024],
106
+ ["A dog chasing a butterfly in a meadow", "video", 3.0, 1.0, 123, 1024, 1024],
107
  ],
108
+ inputs=[prompt_input, content_type, guidance_scale, temperature, seed, width, height],
109
  cache_examples=False
110
  )
111
 
grn_pipeline.py CHANGED
@@ -155,6 +155,7 @@ class GRNPipeline:
155
  prompt,
156
  negative_prompt='',
157
  guidance_scale=3.0,
 
158
  num_inference_steps=50,
159
  width=512,
160
  height=512,
@@ -169,6 +170,7 @@ class GRNPipeline:
169
  self.args.seed = np.random.randint(0, 10000)
170
 
171
  self.args.cfg_val = guidance_scale
 
172
 
173
  # Get dynamic resolution meta
174
  dynamic_resolution_h_w, h_div_w_templates = get_dynamic_resolution_meta(
 
155
  prompt,
156
  negative_prompt='',
157
  guidance_scale=3.0,
158
+ temperature=1.0,
159
  num_inference_steps=50,
160
  width=512,
161
  height=512,
 
170
  self.args.seed = np.random.randint(0, 10000)
171
 
172
  self.args.cfg_val = guidance_scale
173
+ self.args.tau = temperature
174
 
175
  # Get dynamic resolution meta
176
  dynamic_resolution_h_w, h_div_w_templates = get_dynamic_resolution_meta(