jordandotzel commited on
Commit
737c688
·
verified ·
1 Parent(s): 2894805

Fix the image dims

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -48,12 +48,12 @@ def infer(
48
  inference_steps=25,
49
  guidance_scale=7.0,
50
  control_weight=0.7,
51
- low_threshold=100,
52
- high_threshold=200,
53
  progress=gr.Progress(track_tqdm=True)
54
  ):
55
  # Canny preprocessing
56
  control_image = load_image(image_in)
 
 
57
 
58
  # Infer
59
  image = pipe(
@@ -65,7 +65,7 @@ def infer(
65
  guidance_scale=guidance_scale,
66
  ).images[0]
67
 
68
- image_redim, w, h = resize_image(image_in, "resized_input.jpg", 1024)
69
  image = image.resize((w, h), Image.LANCZOS)
70
 
71
  return image, gr.update(value=control_image , visible=True)
@@ -100,8 +100,6 @@ with gr.Blocks(css=css) as demo:
100
  inference_steps = gr.Slider(label="Inference steps", minimum=1, maximum=100, step=1, value=50)
101
  guidance_scale = gr.Slider(label="Guidance scale", minimum=1.0, maximum=10.0, step=0.1, value=7.0)
102
  control_weight = gr.Slider(label="Control Weight", minimum=0.0, maximum=1.0, step=0.01, value=0.7)
103
- low_threshold = gr.Slider(label="Canny Low Threshold", minimum=0, maximum=2048, step=1, value=100)
104
- high_threshold = gr.Slider(label="Canny High Threshold", minimum=0, maximum=2048, step=1, value=200)
105
 
106
  submit_canny_btn = gr.Button("Submit")
107
 
@@ -112,11 +110,10 @@ with gr.Blocks(css=css) as demo:
112
 
113
  submit_canny_btn.click(
114
  fn=infer,
115
- inputs=[image_in, prompt, negative_prompt, inference_steps, guidance_scale, control_weight, low_threshold, high_threshold],
116
  outputs=[result, canny_used],
117
  api_name="predict",
118
  show_api=True
119
  )
120
 
121
  demo.queue().launch(show_api=True)
122
-
 
48
  inference_steps=25,
49
  guidance_scale=7.0,
50
  control_weight=0.7,
 
 
51
  progress=gr.Progress(track_tqdm=True)
52
  ):
53
  # Canny preprocessing
54
  control_image = load_image(image_in)
55
+ control_image = np.concatenate([control_image[:, :, None]] * 3, axis=2)
56
+ control_image = Image.fromarray(control_image)
57
 
58
  # Infer
59
  image = pipe(
 
65
  guidance_scale=guidance_scale,
66
  ).images[0]
67
 
68
+ _, w, h = resize_image(image_in, "resized_input.jpg", 1024)
69
  image = image.resize((w, h), Image.LANCZOS)
70
 
71
  return image, gr.update(value=control_image , visible=True)
 
100
  inference_steps = gr.Slider(label="Inference steps", minimum=1, maximum=100, step=1, value=50)
101
  guidance_scale = gr.Slider(label="Guidance scale", minimum=1.0, maximum=10.0, step=0.1, value=7.0)
102
  control_weight = gr.Slider(label="Control Weight", minimum=0.0, maximum=1.0, step=0.01, value=0.7)
 
 
103
 
104
  submit_canny_btn = gr.Button("Submit")
105
 
 
110
 
111
  submit_canny_btn.click(
112
  fn=infer,
113
+ inputs=[image_in, prompt, negative_prompt, inference_steps, guidance_scale, control_weight],
114
  outputs=[result, canny_used],
115
  api_name="predict",
116
  show_api=True
117
  )
118
 
119
  demo.queue().launch(show_api=True)