Skip to content

Commit c824e7a

Browse files
ppwwyyxxfacebook-github-bot
authored andcommitted
update panoptic segmentation path
Reviewed By: rbgirshick Differential Revision: D20056724 fbshipit-source-id: 4fdb8b560ce64643391cea642b295aac54f65ee9
1 parent 11d5067 commit c824e7a

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

demo/demo.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ def get_parser():
4040
)
4141
parser.add_argument("--webcam", action="store_true", help="Take inputs from webcam.")
4242
parser.add_argument("--video-input", help="Path to video file.")
43-
parser.add_argument("--input", nargs="+", help="A list of space separated input images")
43+
parser.add_argument(
44+
"--input",
45+
nargs="+",
46+
help="A list of space separated input images; "
47+
"or a single glob pattern such as 'directory/*.jpg'",
48+
)
4449
parser.add_argument(
4550
"--output",
4651
help="A file or directory to save output visualizations. "

detectron2/evaluation/panoptic_evaluation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ def evaluate(self):
9090
if not comm.is_main_process():
9191
return
9292

93+
# PanopticApi requires local files
9394
gt_json = PathManager.get_local_path(self._metadata.panoptic_json)
94-
gt_folder = self._metadata.panoptic_root
95+
gt_folder = PathManager.get_local_path(self._metadata.panoptic_root)
9596

9697
with tempfile.TemporaryDirectory(prefix="panoptic_eval") as pred_dir:
9798
logger.info("Writing all panoptic predictions to {} ...".format(pred_dir))

detectron2/modeling/roi_heads/fast_rcnn.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def fast_rcnn_inference_single_image(
126126
class FastRCNNOutputs(object):
127127
"""
128128
A class that stores information about outputs of a Fast R-CNN head.
129+
It provides methods that are used to decode the outputs of a Fast R-CNN head.
129130
"""
130131

131132
def __init__(
@@ -259,19 +260,6 @@ def smooth_l1_loss(self):
259260
loss_box_reg = loss_box_reg / self.gt_classes.numel()
260261
return loss_box_reg
261262

262-
def losses(self):
263-
"""
264-
Compute the default losses for box head in Fast(er) R-CNN,
265-
with softmax cross entropy loss and smooth L1 loss.
266-
267-
Returns:
268-
A dict of losses (scalar tensors) containing keys "loss_cls" and "loss_box_reg".
269-
"""
270-
return {
271-
"loss_cls": self.softmax_cross_entropy_loss(),
272-
"loss_box_reg": self.smooth_l1_loss(),
273-
}
274-
275263
def _predict_boxes(self):
276264
"""
277265
Returns:
@@ -288,6 +276,24 @@ def _predict_boxes(self):
288276
)
289277
return boxes.view(num_pred, K * B)
290278

279+
"""
280+
A subclass is expected to have the following methods because
281+
they are used to query information about the head predictions.0
282+
"""
283+
284+
def losses(self):
285+
"""
286+
Compute the default losses for box head in Fast(er) R-CNN,
287+
with softmax cross entropy loss and smooth L1 loss.
288+
289+
Returns:
290+
A dict of losses (scalar tensors) containing keys "loss_cls" and "loss_box_reg".
291+
"""
292+
return {
293+
"loss_cls": self.softmax_cross_entropy_loss(),
294+
"loss_box_reg": self.smooth_l1_loss(),
295+
}
296+
291297
def predict_boxes(self):
292298
"""
293299
Returns:

detectron2/modeling/roi_heads/keypoint_head.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2-
from typing import Dict, List
2+
from typing import List
33
import torch
44
from torch import nn
55
from torch.nn import functional as F
@@ -133,10 +133,10 @@ def __init__(self, cfg, input_shape):
133133
self.num_keypoints * batch_size_per_image * positive_sample_fraction
134134
)
135135

136-
def forward(self, x: Dict[str, torch.Tensor], instances: List[Instances]):
136+
def forward(self, x, instances: List[Instances]):
137137
"""
138138
Args:
139-
x (dict[str,Tensor]): input region feature(s) provided by :class:`ROIHeads`.
139+
x: input region feature(s) provided by :class:`ROIHeads`.
140140
instances (list[Instances]): contains the boxes & labels corresponding
141141
to the input features.
142142
Exact format is up to its caller to decide.

detectron2/modeling/roi_heads/mask_head.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2-
from typing import Dict, List
2+
from typing import List
33
import fvcore.nn.weight_init as weight_init
44
import torch
55
from torch import nn
@@ -151,10 +151,10 @@ def __init__(self, cfg, input_shape):
151151
super().__init__()
152152
self.vis_period = cfg.VIS_PERIOD
153153

154-
def forward(self, x: Dict[str, torch.Tensor], instances: List[Instances]):
154+
def forward(self, x, instances: List[Instances]):
155155
"""
156156
Args:
157-
x (dict[str,Tensor]): input region feature(s) provided by :class:`ROIHeads`.
157+
x: input region feature(s) provided by :class:`ROIHeads`.
158158
instances (list[Instances]): contains the boxes & labels corresponding
159159
to the input features.
160160
Exact format is up to its caller to decide.

0 commit comments

Comments
 (0)