facebookresearch / facebookresearch/detectron2

Desnpose Import Error

Open
#4,823 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
34.7k
Forks
7.9k
PR merge metrics
No merged PRs in 30d

Description

After installation of Detectron2 I am not able to run Densepose and getting error:

ImportError: cannot import name 'matched_boxlist_iou' from 'detectron2.structures.boxes' from .conda/envs/pytorch3d/lib/python3.9/site-packages/detectron2/structures.box.py

After looking into the code, the name of a function was changed from matched_boxlist_iou to matched_pairwise_iou.

I just simply added another function called matched_boxlist_iou, but I guess one can correct the imports in densepose.

'''

def matched_boxlist_iou(boxes1: Boxes, boxes2: Boxes) -> torch.Tensor:
"""
Compute pairwise intersection over union (IOU) of two sets of matched
boxes that have the same number of boxes.
Similar to :func:`pairwise_iou`, but computes only diagonal elements of the matrix.

Args:
boxes1 (Boxes): bounding boxes, sized [N,4].
boxes2 (Boxes): same length as boxes1
Returns:
Tensor: iou, sized [N].
"""
assert len(boxes1) == len(
boxes2
), "boxlists should have the same" "number of entries, got {}, {}".format(
len(boxes1), len(boxes2)
)
area1 = boxes1.area() # [N]
area2 = boxes2.area() # [N]
box1, box2 = boxes1.tensor, boxes2.tensor
lt = torch.max(box1[:, :2], box2[:, :2]) # [N,2]
rb = torch.min(box1[:, 2:], box2[:, 2:]) # [N,2]
wh = (rb - lt).clamp(min=0) # [N,2]
inter = wh[:, 0] * wh[:, 1] # [N]
iou = inter / (area1 + area2 - inter) # [N]
return iou

'''

Contributor guide

Open the contributing guide

Research direction

Locate the DensePose imports of matched_boxlist_iou and inspect detectron2.structures.boxes, where the issue reports that the function was renamed to matched_pairwise_iou. Done means DensePose can be imported and run without this ImportError; the issue does not name a specific test file.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.