mirror of https://github.com/open-mmlab/mmocr.git
[Enhancement] Make lanms-neo optional (#1772)
* [Enhancement] Make lanms-neo optional * fix * rmpull/1753/head
parent
465316f193
commit
47f54304f5
|
@ -6,7 +6,11 @@ import numpy as np
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
import torch.nn.functional as F
|
import torch.nn.functional as F
|
||||||
|
|
||||||
|
try:
|
||||||
from lanms import merge_quadrangle_n9 as la_nms
|
from lanms import merge_quadrangle_n9 as la_nms
|
||||||
|
except ImportError:
|
||||||
|
la_nms = None
|
||||||
from mmcv.ops import RoIAlignRotated
|
from mmcv.ops import RoIAlignRotated
|
||||||
from mmengine.model import BaseModule
|
from mmengine.model import BaseModule
|
||||||
from numpy import ndarray
|
from numpy import ndarray
|
||||||
|
@ -838,6 +842,9 @@ class ProposalLocalGraphs:
|
||||||
self.comp_shrink_ratio,
|
self.comp_shrink_ratio,
|
||||||
self.comp_w_h_ratio)
|
self.comp_w_h_ratio)
|
||||||
|
|
||||||
|
if la_nms is None:
|
||||||
|
raise ImportError('lanms-neo is not installed, '
|
||||||
|
'please run "pip install lanms-neo==1.0.2".')
|
||||||
text_comps = la_nms(text_comps, self.nms_thr)
|
text_comps = la_nms(text_comps, self.nms_thr)
|
||||||
text_comp_mask = np.zeros(mask_sz)
|
text_comp_mask = np.zeros(mask_sz)
|
||||||
text_comp_boxes = text_comps[:, :8].reshape(
|
text_comp_boxes = text_comps[:, :8].reshape(
|
||||||
|
|
|
@ -4,7 +4,11 @@ from typing import Dict, List, Sequence, Tuple
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
|
try:
|
||||||
from lanms import merge_quadrangle_n9 as la_nms
|
from lanms import merge_quadrangle_n9 as la_nms
|
||||||
|
except ImportError:
|
||||||
|
la_nms = None
|
||||||
from mmcv.image import imrescale
|
from mmcv.image import imrescale
|
||||||
from mmdet.models.utils import multi_apply
|
from mmdet.models.utils import multi_apply
|
||||||
from numpy import ndarray
|
from numpy import ndarray
|
||||||
|
@ -447,6 +451,9 @@ class DRRGModuleLoss(TextSnakeModuleLoss):
|
||||||
|
|
||||||
score = np.ones((text_comps.shape[0], 1), dtype=np.float32)
|
score = np.ones((text_comps.shape[0], 1), dtype=np.float32)
|
||||||
text_comps = np.hstack([text_comps, score])
|
text_comps = np.hstack([text_comps, score])
|
||||||
|
if la_nms is None:
|
||||||
|
raise ImportError('lanms-neo is not installed, '
|
||||||
|
'please run "pip install lanms-neo==1.0.2".')
|
||||||
text_comps = la_nms(text_comps, self.text_comp_nms_thr)
|
text_comps = la_nms(text_comps, self.text_comp_nms_thr)
|
||||||
|
|
||||||
if text_comps.shape[0] >= 1:
|
if text_comps.shape[0] >= 1:
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
imgaug
|
imgaug
|
||||||
kwarray
|
kwarray
|
||||||
lanms-neo==1.0.2
|
|
||||||
lmdb
|
lmdb
|
||||||
matplotlib
|
matplotlib
|
||||||
mmcv>=2.0.0rc1
|
mmcv>=2.0.0rc1
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
imgaug
|
imgaug
|
||||||
lanms-neo==1.0.2
|
|
||||||
lmdb
|
lmdb
|
||||||
matplotlib
|
matplotlib
|
||||||
numpy
|
numpy
|
||||||
|
|
|
@ -5,6 +5,7 @@ interrogate
|
||||||
isort
|
isort
|
||||||
# Note: used for kwarray.group_items, this may be ported to mmcv in the future.
|
# Note: used for kwarray.group_items, this may be ported to mmcv in the future.
|
||||||
kwarray
|
kwarray
|
||||||
|
lanms-neo==1.0.2
|
||||||
parameterized
|
parameterized
|
||||||
pytest
|
pytest
|
||||||
pytest-cov
|
pytest-cov
|
||||||
|
|
Loading…
Reference in New Issue