Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(fasterrcnn): handle imgs with 0 chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmyshin committed Jul 18, 2019
1 parent 2da1942 commit 92f36c3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gnes/preprocessor/image/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 92f36c3

Please sign in to comment.