qubvel-hf HF staff commited on
Commit
1c5bb05
1 Parent(s): 981b1d1

Prefill annotated images

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -25,9 +25,10 @@ HEADER = f"""
25
 
26
  DEFAULT_TRANSFORM = "Rotate"
27
 
28
- DEFAULT_IMAGE = "images/doctor.webp"
29
- DEFAULT_IMAGE_HEIGHT = 400
30
- DEFAULT_IMAGE_WIDTH = 600
 
31
  DEFAULT_BOXES = [
32
  [265, 121, 326, 177], # Mask
33
  [192, 169, 401, 395], # Coverall
@@ -144,7 +145,7 @@ def draw_not_implemented_image(image: np.ndarray, annotation_type: str):
144
  pil_image = Image.fromarray(image)
145
  draw = ImageDraw.Draw(pil_image)
146
  # align in the centerm, and make bigger font
147
- text = f'Transform NOT working with "{annotation_type.upper()}" annotaions.'
148
  length = draw.textlength(text)
149
  draw.text(
150
  (DEFAULT_IMAGE_WIDTH // 2 - length // 2, DEFAULT_IMAGE_HEIGHT // 2),
@@ -296,14 +297,19 @@ with gr.Blocks() as demo:
296
  )
297
  button = gr.Button("Apply!")
298
  image = gr.Image(
299
- value=DEFAULT_IMAGE,
300
  type="numpy",
301
  height=500,
302
  width=300,
303
  sources=[],
304
  )
305
  with gr.Row():
306
- augmented_image = gr.Gallery(rows=1, columns=3)
 
 
 
 
 
307
 
308
  select.change(fn=update_code_and_docs, inputs=[select], outputs=[code, docs])
309
  button.click(
 
25
 
26
  DEFAULT_TRANSFORM = "Rotate"
27
 
28
+ DEFAULT_IMAGE_PATH = "images/doctor.webp"
29
+ DEFAULT_IMAGE = np.array(Image.open(DEFAULT_IMAGE_PATH))
30
+ DEFAULT_IMAGE_HEIGHT = DEFAULT_IMAGE.shape[0]
31
+ DEFAULT_IMAGE_WIDTH = DEFAULT_IMAGE.shape[1]
32
  DEFAULT_BOXES = [
33
  [265, 121, 326, 177], # Mask
34
  [192, 169, 401, 395], # Coverall
 
145
  pil_image = Image.fromarray(image)
146
  draw = ImageDraw.Draw(pil_image)
147
  # align in the centerm, and make bigger font
148
+ text = f'Transform NOT working with "{annotation_type.upper()}" annotations.'
149
  length = draw.textlength(text)
150
  draw.text(
151
  (DEFAULT_IMAGE_WIDTH // 2 - length // 2, DEFAULT_IMAGE_HEIGHT // 2),
 
297
  )
298
  button = gr.Button("Apply!")
299
  image = gr.Image(
300
+ value=DEFAULT_IMAGE_PATH,
301
  type="numpy",
302
  height=500,
303
  width=300,
304
  sources=[],
305
  )
306
  with gr.Row():
307
+ augmented_image = gr.Gallery(
308
+ value=update_augmented_images(DEFAULT_IMAGE, "A.NoOp()"),
309
+ rows=1,
310
+ columns=3,
311
+ show_label=False,
312
+ )
313
 
314
  select.change(fn=update_code_and_docs, inputs=[select], outputs=[code, docs])
315
  button.click(