diff --git a/README.md b/README.md index d83fe5f..fd91968 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,9 @@ http://127.0.0.1:8080/ocr +## flask-restful api 内存测试(dbnet) +200张图片测试稳定在1-1.5G左右的内存 +![](test_imgs/flask-api.png) ## 参考 diff --git a/dbnet/dbnet_infer.py b/dbnet/dbnet_infer.py index a7c8718..54f9b42 100644 --- a/dbnet/dbnet_infer.py +++ b/dbnet/dbnet_infer.py @@ -21,7 +21,7 @@ def draw_bbox(img_path, result, color=(255, 0, 0), thickness=2): return img_path -class DBNET(object, metaclass=SingletonType): +class DBNET(metaclass=SingletonType): def __init__(self, MODEL_PATH, short_size=640): self.sess = rt.InferenceSession(MODEL_PATH) self.short_size = short_size diff --git a/dbnet/decode.py b/dbnet/decode.py index d1a9914..925940f 100644 --- a/dbnet/decode.py +++ b/dbnet/decode.py @@ -13,7 +13,7 @@ def __init__(self, thresh=0.3, box_thresh=0.5, max_candidates=1000, unclip_ratio self.unclip_ratio = unclip_ratio def __call__(self, pred, height, width): - ''' + """ batch: (image, polygons, ignore_tags batch: a dict produced by dataloaders. image: tensor of shape (N, C, H, W). @@ -25,7 +25,7 @@ def __call__(self, pred, height, width): binary: text region segmentation map, with shape (N, H, W) thresh: [if exists] thresh hold prediction with shape (N, H, W) thresh_binary: [if exists] binarized with threshhold, (N, H, W) - ''' + """ pred = pred[0, :, :] segmentation = self.binarize(pred) @@ -38,10 +38,10 @@ def binarize(self, pred): return pred > self.thresh def boxes_from_bitmap(self, pred, bitmap, dest_width, dest_height): - ''' + """ _bitmap: single map with shape (H, W), whose values are binarized as {0, 1} - ''' + """ assert len(bitmap.shape) == 2 # bitmap = _bitmap.cpu().numpy() # The first channel