diff --git a/ocrd_segment/evaluate.py b/ocrd_segment/evaluate.py index 7036229..7df7ac7 100644 --- a/ocrd_segment/evaluate.py +++ b/ocrd_segment/evaluate.py @@ -527,7 +527,7 @@ def get(arg): coco_eval.accumulate() coco_eval.summarize() - statInds = np.ones(12, np.bool) + statInds = np.ones(12, bool) statInds[7] = False # AR maxDet[1] statInds[8] = False # AR maxDet[2] coco_eval.stats = coco_eval.stats[statInds] diff --git a/ocrd_segment/extract_pages.py b/ocrd_segment/extract_pages.py index 60b548b..fd6ed4e 100644 --- a/ocrd_segment/extract_pages.py +++ b/ocrd_segment/extract_pages.py @@ -308,7 +308,7 @@ def process(self): self.parameter['plot_overlay']) if not poly: continue - polygon = np.array(poly.exterior.coords, np.int)[:-1].tolist() + polygon = np.array(poly.exterior.coords, int)[:-1].tolist() xywh = xywh_from_polygon(polygon) area = poly.area description.setdefault('regions', []).append( @@ -330,7 +330,7 @@ def process(self): {'id': i, 'image_id': num_page_id, 'category_id': next((cat['id'] for cat in categories if cat['name'] == subrtype), next((cat['id'] for cat in categories if cat['name'] == rtype))), - 'segmentation': np.array(poly.exterior.coords, np.int)[:-1].reshape(1, -1).tolist(), + 'segmentation': np.array(poly.exterior.coords, int)[:-1].reshape(1, -1).tolist(), 'area': area, 'bbox': [xywh['x'], xywh['y'], xywh['w'], xywh['h']], 'iscrowd': 0}) @@ -430,7 +430,7 @@ def get_points(rogroup, level): poly = regiondict.get(regionref.get_regionRef(), None) if poly: # we have seen this region - morepoints.append((level, tuple(np.array(poly.centroid, np.int)))) + morepoints.append((level, tuple(np.array(poly.centroid, int)))) if not isinstance(regionref, (RegionRefType, RegionRefIndexedType)): # try to get subgroup regions instead morepoints = get_points(regionref, level + 1) or morepoints @@ -445,7 +445,7 @@ def get_points(rogroup, level): points.extend(get_points(readingorder, 0)) else: # use XML ordering - points.extend([(0, tuple(np.array(region.poly.centroid, np.int))) for region in regions]) + points.extend([(0, tuple(np.array(region.poly.centroid, int))) for region in regions]) for p1, p2 in zip(points[:-1], points[1:]): color = 'ReadingOrderLevel%s' % (str(p1[0]) if p1[0] < 2 else 'N') if color not in classes: diff --git a/ocrd_segment/extract_regions.py b/ocrd_segment/extract_regions.py index f4f47b9..d51b715 100644 --- a/ocrd_segment/extract_regions.py +++ b/ocrd_segment/extract_regions.py @@ -205,7 +205,7 @@ def process(self): poly = segment_poly(page_id, subregion, region_coords) if not poly: continue - polygon = np.array(poly.exterior.coords, np.int)[:-1].tolist() + polygon = np.array(poly.exterior.coords, int)[:-1].tolist() xywh = xywh_from_polygon(polygon) area = poly.area if subrtype in ['TextRegion', 'ChartRegion', 'GraphicRegion']: @@ -229,7 +229,7 @@ def process(self): {'id': i, 'image_id': j, 'category_id': next((cat['id'] for cat in categories if cat['name'] == subsubrtype), next((cat['id'] for cat in categories if cat['name'] == subrtype))), - 'segmentation': np.array(poly.exterior.coords, np.int)[:-1].reshape(1, -1).tolist(), + 'segmentation': np.array(poly.exterior.coords, int)[:-1].reshape(1, -1).tolist(), 'area': area, 'bbox': [xywh['x'], xywh['y'], xywh['w'], xywh['h']], 'iscrowd': 0}) diff --git a/ocrd_segment/repair.py b/ocrd_segment/repair.py index ca31e0d..e9bfb29 100644 --- a/ocrd_segment/repair.py +++ b/ocrd_segment/repair.py @@ -538,7 +538,7 @@ def shrink_regions(page_image, page_coords, page, page_id, padding=0): scale = 43 for region in page.get_AllRegions(): #LOG.info('Shrinking region "%s"', region.id) - region_mask = np.zeros_like(page_array, dtype=np.bool) + region_mask = np.zeros_like(page_array, dtype=bool) region_polygon = coordinates_of_segment(region, page_image, page_coords) region_mask[draw.polygon(region_polygon[:, 1], region_polygon[:, 0], @@ -701,7 +701,7 @@ def ensure_valid(element): coords = element.get_Coords() points = coords.points polygon = polygon_from_points(points) - array = np.array(polygon, np.int) + array = np.array(polygon, int) if array.min() < 0: array = np.maximum(0, array) changed = True