Skip to content
Permalink
Browse files

refactor(preprocessor): add gif chunk prep

  • Loading branch information...
jemmyshin committed Aug 23, 2019
1 parent b9fdb41 commit a7b12cb6787894a5a7c8e73f688d55868293c3ca
Showing with 4 additions and 3 deletions.
  1. +4 −3 gnes/preprocessor/image/segmentation.py
@@ -81,13 +81,14 @@ def apply(self, doc: 'gnes_pb2.Document'):
else:
self.logger.error('bad document: "raw_bytes" is empty!')

def _crop(self, original_image, coordinates):
return np.array(original_image.crop(coordinates))

def _get_seg_offset_nd(self, all_subareas: List[List[int]], index: List[List[int]], chunk: List[int]) -> List[int]:
iou_list = [self._cal_iou(area, chunk) for area in all_subareas]
return index[int(np.argmax(iou_list))][:2]

@staticmethod
def _crop(original_image, coordinates):
return np.array(original_image.crop(coordinates))

@staticmethod
def _cal_area(coordinate: List[int]):
return (coordinate[2] - coordinate[0]) * (coordinate[3] - coordinate[1])

0 comments on commit a7b12cb

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