Skip to content
Permalink
Browse files

fix(fasterrcnn): handle imgs with 0 chunk

  • Loading branch information...
jemmyshin committed Jul 18, 2019
1 parent 2da1942 commit 92f36c332354e32119eeb5c02cbd7e0c2c626d81
Showing with 8 additions and 0 deletions.
  1. +8 −0 gnes/preprocessor/image/segmentation.py
@@ -42,6 +42,14 @@ def apply(self, doc: 'gnes_pb2.Document'):
seg_output = self._model([image_tensor])
chunks = seg_output[0]['boxes'].tolist()
weight = seg_output[0]['scores'].tolist()
if len(chunks) == 0:
c = doc.chunks.add()
c.doc_id = doc.doc_id
c.blob.CopyFrom(array2blob(np.array(original_image.resize((self.target_img_size,
self.target_img_size)))))
c.offset_1d = 1
c.weight = 1.

for ci, ele in enumerate(zip(chunks, weight)):
c = doc.chunks.add()
c.doc_id = doc.doc_id

0 comments on commit 92f36c3

Please sign in to comment.
You can’t perform that action at this time.