Skip to content

Commit

Permalink
Merge pull request #82 from breezedeus/pytorch
Browse files Browse the repository at this point in the history
fix: a bug in the detect method of YoloDetector
  • Loading branch information
breezedeus authored Jun 17, 2024
2 parents 0637533 + 16dc63b commit 86fa231
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,6 @@ class LayoutAnalyzer(object):
函数输出结果为一个`list`,其中每个元素表示识别出的版面中的一个元素,包含以下信息:
* type: 版面元素对应的类型;可选值来自:`self.categories` ;
* box: 版面元素对应的矩形框;`np.ndarray`, shape: (4, 2),对应 box 4个点的坐标值 `(x, y)` ;
* score: 得分,越高表示越可信 。
#### 类函数`LayoutAnalyzer.analyze()`
Expand Down Expand Up @@ -438,6 +431,13 @@ def analyze(
* `iou_threshold` (float): IOU阈值;默认值为 `0.45`
* `**kwargs`: 额外的参数。
函数输出结果为一个`list`(如果 `img_list``list`,返回为两层嵌套的 `list`,其中每个元素为对应图片的检测结果),其中每个元素表示识别出的版面中的一个元素,包含以下信息:
* type: 版面元素对应的类型;可选值来自:`self.categories` ;
* box: 版面元素对应的矩形框;`np.ndarray`, shape: (4, 2),对应 box 4个点的坐标值 `(x, y)` ;
* score: 得分,越高表示越可信 。
#### 调用示例
Expand Down
11 changes: 11 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Release Notes

# Update 2024.06.17:发布 V1.2.4.1

Major Changes:

* Fixed a bug in the `detect` method of `YoloDetector`: when the input is a single file, the output is not a double-layer nested list.

主要变更:

* 修复了 `YoloDetector``detect` 方法的一个bug:输入为单个文件时,输出不是双层嵌套的 list。


# Update 2024.06.16:发布 V1.2.4

Major Changes:
Expand Down
2 changes: 1 addition & 1 deletion cnstd/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# specific language governing permissions and limitations
# under the License.

__version__ = '1.2.4'
__version__ = '1.2.4.1'
3 changes: 3 additions & 0 deletions cnstd/yolo_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def detect(
"""
dedup_thrsh = kwargs.pop('dedup_thrsh') if 'dedup_thrsh' in kwargs else 0.1
single = not isinstance(img_list, (list, tuple))
# Ultralytics 需要的 ndarray 是 HWC,BGR 格式
if isinstance(img_list, np.ndarray):
img_list = img_list[:, :, ::-1]
Expand Down Expand Up @@ -104,4 +105,6 @@ def detect(
one_out = dedup_boxes(one_out, threshold=dedup_thrsh)
outs.append(one_out)

if single and len(outs) == 1:
return outs[0]
return outs
4 changes: 1 addition & 3 deletions cnstd/yolov7/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
import torch
import torchvision

# from utils.google_utils import gsutil_getsize
# from utils.metrics import fitness
from .torch_utils import init_torch_seeds
from ..utils import xyxy2xywh, xywh2xyxy
from ..utils import xyxy2xywh, xywh2xyxy, box_partial_overlap

logger = logging.getLogger(__name__)

Expand Down

0 comments on commit 86fa231

Please sign in to comment.