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

Commit

Permalink
refactor(preprocessor): add gif chunk prep
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmyshin committed Aug 23, 2019
1 parent b9fdb41 commit a7b12cb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions gnes/preprocessor/image/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit a7b12cb

Please sign in to comment.