Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -36,18 +36,21 @@ 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
44
  image = image.resize((512, 512))
 
 
 
45
  result = dept2img(
46
  image=image,
47
  prompt=prompt,
48
  negative_prompt=negative_prompt,
49
- depth_image=depth,
50
- seed=seed,
51
  strength=strength,
52
  num_inference_steps=steps,
53
  guidance_scale=scale,
@@ -68,12 +71,12 @@ with block:
68
  with gr.Column():
69
  input_image = gr.Image(source='upload', type="pil")
70
  depth_image = gr.Image(
71
- source='upload', type="pil", label="Depth image Optional", value=None)
72
  prompt = gr.Textbox(label="Prompt")
73
- negative_prompt = gr.Textbox(label="Negative Pompt")
74
 
75
  run_button = gr.Button(label="Run")
76
- with gr.Accordion("Advanced options", open=False):
77
  num_samples = gr.Slider(
78
  label="Images", minimum=1, maximum=4, value=1, step=1)
79
  steps = gr.Slider(label="Steps", minimum=1,
@@ -92,7 +95,7 @@ with block:
92
  randomize=True,
93
  )
94
  with gr.Column():
95
- gallery = gr.Gallery(label="Generated images", show_label=False).style(
96
  grid=[2], height="auto")
97
  gr.Examples(
98
  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
44
  image = image.resize((512, 512))
45
+ generator = None
46
+ if seed is not None:
47
+ generator = torch.Generator(device=device).manual_seed(seed)
48
  result = dept2img(
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=[