radames commited on
Commit
1553a94
·
2 Parent(s): 681c549 e681f63

Merge branch 'main' into pr/75

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -36,8 +36,8 @@ def predict(input_image, prompt, negative_prompt, steps, num_samples, scale, see
36
  depth_image = pad_image(depth_image)
37
  depth_image = depth_image.resize((512, 512))
38
  depth = np.array(depth_image.convert("L"))
 
39
  depth = depth.astype(np.float32) / 255.0
40
- depth = depth[None, None]
41
  depth = torch.from_numpy(depth)
42
  init_image = input_image.convert("RGB")
43
  image = pad_image(init_image) # resize to integer multiple of 32
@@ -49,8 +49,8 @@ def predict(input_image, prompt, negative_prompt, steps, num_samples, scale, see
49
  image=image,
50
  prompt=prompt,
51
  negative_prompt=negative_prompt,
52
- depth_image=depth,
53
  generator=generator,
 
54
  strength=strength,
55
  num_inference_steps=steps,
56
  guidance_scale=scale,
@@ -71,12 +71,12 @@ with block:
71
  with gr.Column():
72
  input_image = gr.Image(source='upload', type="pil")
73
  depth_image = gr.Image(
74
- source='upload', type="pil", label="Depth image Optional", value=None)
75
  prompt = gr.Textbox(label="Prompt")
76
- negative_prompt = gr.Textbox(label="Negative Pompt")
77
 
78
  run_button = gr.Button(label="Run")
79
- with gr.Accordion("Advanced options", open=False):
80
  num_samples = gr.Slider(
81
  label="Images", minimum=1, maximum=4, value=1, step=1)
82
  steps = gr.Slider(label="Steps", minimum=1,
@@ -95,7 +95,7 @@ with block:
95
  randomize=True,
96
  )
97
  with gr.Column():
98
- gallery = gr.Gallery(label="Generated images", show_label=False).style(
99
  grid=[2], height="auto")
100
  gr.Examples(
101
  examples=[
 
36
  depth_image = pad_image(depth_image)
37
  depth_image = depth_image.resize((512, 512))
38
  depth = np.array(depth_image.convert("L"))
39
+ depth = np.expand_dims(depth, 0)
40
  depth = depth.astype(np.float32) / 255.0
 
41
  depth = torch.from_numpy(depth)
42
  init_image = input_image.convert("RGB")
43
  image = pad_image(init_image) # resize to integer multiple of 32
 
49
  image=image,
50
  prompt=prompt,
51
  negative_prompt=negative_prompt,
 
52
  generator=generator,
53
+ depth_map=depth,
54
  strength=strength,
55
  num_inference_steps=steps,
56
  guidance_scale=scale,
 
71
  with gr.Column():
72
  input_image = gr.Image(source='upload', type="pil")
73
  depth_image = gr.Image(
74
+ source='upload', type="pil", label="Depth Image Optional", value=None)
75
  prompt = gr.Textbox(label="Prompt")
76
+ negative_prompt = gr.Textbox(label="Negative Prompt")
77
 
78
  run_button = gr.Button(label="Run")
79
+ with gr.Accordion("Advanced Options", open=False):
80
  num_samples = gr.Slider(
81
  label="Images", minimum=1, maximum=4, value=1, step=1)
82
  steps = gr.Slider(label="Steps", minimum=1,
 
95
  randomize=True,
96
  )
97
  with gr.Column():
98
+ gallery = gr.Gallery(label="Generated Images", show_label=False).style(
99
  grid=[2], height="auto")
100
  gr.Examples(
101
  examples=[