|
@@ -511,13 +511,8 @@ class BaseDetector(BaseModel):
|
|
|
batch_transforms = self._compose_batch_transform(transforms, 'test')
|
|
batch_transforms = self._compose_batch_transform(transforms, 'test')
|
|
|
batch_samples = batch_transforms(batch_samples)
|
|
batch_samples = batch_transforms(batch_samples)
|
|
|
if to_tensor:
|
|
if to_tensor:
|
|
|
- if isinstance(batch_samples, dict):
|
|
|
|
|
- for k in batch_samples:
|
|
|
|
|
- batch_samples[k] = paddle.to_tensor(batch_samples[k])
|
|
|
|
|
- else:
|
|
|
|
|
- for sample in batch_samples:
|
|
|
|
|
- for k in sample:
|
|
|
|
|
- sample[k] = paddle.to_tensor(sample[k])
|
|
|
|
|
|
|
+ for k in batch_samples:
|
|
|
|
|
+ batch_samples[k] = paddle.to_tensor(batch_samples[k])
|
|
|
|
|
|
|
|
return batch_samples
|
|
return batch_samples
|
|
|
|
|
|
|
@@ -987,18 +982,6 @@ class FasterRCNN(BaseDetector):
|
|
|
super(FasterRCNN, self).__init__(
|
|
super(FasterRCNN, self).__init__(
|
|
|
model_name='FasterRCNN', num_classes=num_classes, **params)
|
|
model_name='FasterRCNN', num_classes=num_classes, **params)
|
|
|
|
|
|
|
|
- def run(self, net, inputs, mode):
|
|
|
|
|
- if mode in ['train', 'eval']:
|
|
|
|
|
- outputs = net(inputs)
|
|
|
|
|
- else:
|
|
|
|
|
- outputs = []
|
|
|
|
|
- for sample in inputs:
|
|
|
|
|
- net_out = net(sample)
|
|
|
|
|
- for key in net_out:
|
|
|
|
|
- net_out[key] = net_out[key].numpy()
|
|
|
|
|
- outputs.append(net_out)
|
|
|
|
|
- return outputs
|
|
|
|
|
-
|
|
|
|
|
def _compose_batch_transform(self, transforms, mode='train'):
|
|
def _compose_batch_transform(self, transforms, mode='train'):
|
|
|
if mode == 'train':
|
|
if mode == 'train':
|
|
|
default_batch_transforms = [
|
|
default_batch_transforms = [
|
|
@@ -1022,8 +1005,7 @@ class FasterRCNN(BaseDetector):
|
|
|
|
|
|
|
|
batch_transforms = BatchCompose(
|
|
batch_transforms = BatchCompose(
|
|
|
custom_batch_transforms + default_batch_transforms,
|
|
custom_batch_transforms + default_batch_transforms,
|
|
|
- collate_batch=collate_batch,
|
|
|
|
|
- return_list=mode == 'test')
|
|
|
|
|
|
|
+ collate_batch=collate_batch)
|
|
|
|
|
|
|
|
return batch_transforms
|
|
return batch_transforms
|
|
|
|
|
|
|
@@ -1069,13 +1051,6 @@ class FasterRCNN(BaseDetector):
|
|
|
self.fixed_input_shape = image_shape
|
|
self.fixed_input_shape = image_shape
|
|
|
return self._define_input_spec(image_shape)
|
|
return self._define_input_spec(image_shape)
|
|
|
|
|
|
|
|
- def _postprocess(self, batch_pred):
|
|
|
|
|
- prediction = [
|
|
|
|
|
- super(FasterRCNN, self)._postprocess(pred)[0]
|
|
|
|
|
- for pred in batch_pred
|
|
|
|
|
- ]
|
|
|
|
|
- return prediction
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
class PPYOLO(YOLOv3):
|
|
class PPYOLO(YOLOv3):
|
|
|
def __init__(self,
|
|
def __init__(self,
|
|
@@ -1555,7 +1530,7 @@ class PPYOLOv2(YOLOv3):
|
|
|
return self._define_input_spec(image_shape)
|
|
return self._define_input_spec(image_shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
-class MaskRCNN(FasterRCNN):
|
|
|
|
|
|
|
+class MaskRCNN(BaseDetector):
|
|
|
def __init__(self,
|
|
def __init__(self,
|
|
|
num_classes=80,
|
|
num_classes=80,
|
|
|
backbone='ResNet50_vd',
|
|
backbone='ResNet50_vd',
|
|
@@ -1790,7 +1765,7 @@ class MaskRCNN(FasterRCNN):
|
|
|
'mask_post_process': mask_post_process
|
|
'mask_post_process': mask_post_process
|
|
|
})
|
|
})
|
|
|
self.with_fpn = with_fpn
|
|
self.with_fpn = with_fpn
|
|
|
- super(FasterRCNN, self).__init__(
|
|
|
|
|
|
|
+ super(MaskRCNN, self).__init__(
|
|
|
model_name='MaskRCNN', num_classes=num_classes, **params)
|
|
model_name='MaskRCNN', num_classes=num_classes, **params)
|
|
|
|
|
|
|
|
def _compose_batch_transform(self, transforms, mode='train'):
|
|
def _compose_batch_transform(self, transforms, mode='train'):
|
|
@@ -1816,8 +1791,7 @@ class MaskRCNN(FasterRCNN):
|
|
|
|
|
|
|
|
batch_transforms = BatchCompose(
|
|
batch_transforms = BatchCompose(
|
|
|
custom_batch_transforms + default_batch_transforms,
|
|
custom_batch_transforms + default_batch_transforms,
|
|
|
- collate_batch=collate_batch,
|
|
|
|
|
- return_list=mode == 'test')
|
|
|
|
|
|
|
+ collate_batch=collate_batch)
|
|
|
|
|
|
|
|
return batch_transforms
|
|
return batch_transforms
|
|
|
|
|
|