mischeiwiller commited on
Commit
5709043
1 Parent(s): 8b82a8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -8,9 +8,9 @@ from scipy.cluster.vq import kmeans
8
 
9
  # ... (previous functions remain the same)
10
 
11
- def infer(image_input, mask_input, dst_height: str, dst_width: str):
12
- image_in = image_input
13
- mask_in = mask_input
14
  torch_img = K.utils.image_to_tensor(image_in).float() / 255.0
15
 
16
  centroids = get_coordinates_from_mask(mask_in)
@@ -55,14 +55,14 @@ description = """In this space you can warp an image using perspective transform
55
 
56
  example_mask = np.zeros((327, 600, 4), dtype=np.uint8)
57
  example_mask[:, :, 3] = 255
 
58
 
59
  with gr.Blocks() as demo:
60
  gr.Markdown("# Homography Warping")
61
  gr.Markdown(description)
62
 
63
  with gr.Row():
64
- image_input = gr.Image(label="Input Image", type="numpy")
65
- mask_input = gr.Image(label="Mask", source="canvas", shape=(600, 327), tool="sketch", interactive=True)
66
  output_plot = gr.Plot(label="Output")
67
 
68
  with gr.Row():
@@ -72,13 +72,13 @@ with gr.Blocks() as demo:
72
  submit_button = gr.Button("Submit")
73
  submit_button.click(
74
  fn=infer,
75
- inputs=[image_input, mask_input, dst_height, dst_width],
76
  outputs=output_plot
77
  )
78
 
79
  gr.Examples(
80
- examples=[["bruce.png", example_mask, "64", "128"]],
81
- inputs=[image_input, mask_input, dst_height, dst_width],
82
  outputs=output_plot,
83
  fn=infer,
84
  cache_examples=True
 
8
 
9
  # ... (previous functions remain the same)
10
 
11
+ def infer(image_input, dst_height: str, dst_width: str):
12
+ image_in = image_input["image"]
13
+ mask_in = image_input["mask"]
14
  torch_img = K.utils.image_to_tensor(image_in).float() / 255.0
15
 
16
  centroids = get_coordinates_from_mask(mask_in)
 
55
 
56
  example_mask = np.zeros((327, 600, 4), dtype=np.uint8)
57
  example_mask[:, :, 3] = 255
58
+ example_image_dict = {"image": "bruce.png", "mask": example_mask}
59
 
60
  with gr.Blocks() as demo:
61
  gr.Markdown("# Homography Warping")
62
  gr.Markdown(description)
63
 
64
  with gr.Row():
65
+ image_input = gr.Image(type="numpy", label="Input Image", tool="sketch")
 
66
  output_plot = gr.Plot(label="Output")
67
 
68
  with gr.Row():
 
72
  submit_button = gr.Button("Submit")
73
  submit_button.click(
74
  fn=infer,
75
+ inputs=[image_input, dst_height, dst_width],
76
  outputs=output_plot
77
  )
78
 
79
  gr.Examples(
80
+ examples=[[example_image_dict, "64", "128"]],
81
+ inputs=[image_input, dst_height, dst_width],
82
  outputs=output_plot,
83
  fn=infer,
84
  cache_examples=True