pierreguillou commited on
Commit
eb9b9b5
·
1 Parent(s): e7d8eda

scores infos

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -58,12 +58,19 @@ def analyze_image(img):
58
  if field == 'pred_boxes':
59
  boxes = output.get_fields()[field]
60
  boxes_numpy = boxes.tensor.cpu().numpy()
61
- boxes_bytes = boxes_numpy.tobytes()
62
  boxes_numpy_shape = str(boxes_numpy.shape)
63
  boxes_numpy_dtype = str(boxes_numpy.dtype)
64
  # boxes_recover = torch.from_numpy(np.frombuffer(boxes_bytes, dtype=boxes_numpy_dtype).reshape(boxes_numpy_shape))
 
 
 
 
 
 
 
65
 
66
- return result_image, num_instances, image_size, boxes_bytes, boxes_numpy_shape, boxes_numpy_dtype
67
 
68
  title = "Interactive demo: Document Layout Analysis with DiT"
69
  description = "Demo for Microsoft's DiT, the Document Image Transformer for state-of-the-art document understanding tasks. This particular model is fine-tuned on PubLayNet, a large dataset for document layout analysis (read more at the links below). To use it, simply upload an image or use the example image below and click 'Submit'. Results will show up in a few seconds. If you want to make the output bigger, right-click on it and select 'Open image in new tab'."
@@ -80,6 +87,9 @@ iface = gr.Interface(fn=analyze_image,
80
  gr.outputs.Textbox(label="boxes bytes"),
81
  gr.outputs.Textbox(label="boxes numpy shape"),
82
  gr.outputs.Textbox(label="boxes numpy dtype"),
 
 
 
83
  ],
84
  title=title,
85
  description=description,
 
58
  if field == 'pred_boxes':
59
  boxes = output.get_fields()[field]
60
  boxes_numpy = boxes.tensor.cpu().numpy()
61
+ boxes_bytes = str(boxes_numpy.tobytes())
62
  boxes_numpy_shape = str(boxes_numpy.shape)
63
  boxes_numpy_dtype = str(boxes_numpy.dtype)
64
  # boxes_recover = torch.from_numpy(np.frombuffer(boxes_bytes, dtype=boxes_numpy_dtype).reshape(boxes_numpy_shape))
65
+ elif field == 'scores':
66
+ scores = output.get_fields()[field]
67
+ scores_numpy = scores.cpu().numpy()
68
+ scores_bytes = str(scores_numpy.tobytes())
69
+ scores_numpy_shape = str(scores_numpy.shape)
70
+ scores_numpy_dtype = str(scores_numpy.dtype)
71
+ # scores_recover = torch.from_numpy(np.frombuffer(scores_bytes, dtype=scores_numpy_dtype).reshape(scores_numpy_shape))
72
 
73
+ return result_image, num_instances, image_size, boxes_bytes, boxes_numpy_shape, boxes_numpy_dtype, scores_bytes, scores_numpy_shape, scores_numpy_dtype
74
 
75
  title = "Interactive demo: Document Layout Analysis with DiT"
76
  description = "Demo for Microsoft's DiT, the Document Image Transformer for state-of-the-art document understanding tasks. This particular model is fine-tuned on PubLayNet, a large dataset for document layout analysis (read more at the links below). To use it, simply upload an image or use the example image below and click 'Submit'. Results will show up in a few seconds. If you want to make the output bigger, right-click on it and select 'Open image in new tab'."
 
87
  gr.outputs.Textbox(label="boxes bytes"),
88
  gr.outputs.Textbox(label="boxes numpy shape"),
89
  gr.outputs.Textbox(label="boxes numpy dtype"),
90
+ gr.outputs.Textbox(label="scores bytes"),
91
+ gr.outputs.Textbox(label="scores numpy shape"),
92
+ gr.outputs.Textbox(label="scores numpy dtype")
93
  ],
94
  title=title,
95
  description=description,