geoyee 3 лет назад
Родитель
Сommit
a7485370b6

+ 2 - 1
paddlers/models/__init__.py

@@ -12,4 +12,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from . import ppcd, ppcls, ppdet, ppseg
+from . import ppcls, ppdet, ppseg, ppgan
+from . import cls, det, seg, gan, cd

+ 15 - 0
paddlers/models/cd/__init__.py

@@ -0,0 +1,15 @@
+# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from . import models

+ 0 - 0
paddlers/models/ppcd/__init__.py → paddlers/models/cd/models/__init__.py


+ 0 - 0
paddlers/models/ppcd/cdnet.py → paddlers/models/cd/models/cdnet.py


+ 13 - 0
paddlers/models/cls/__init__.py

@@ -0,0 +1,13 @@
+# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.

+ 13 - 0
paddlers/models/det/__init__.py

@@ -0,0 +1,13 @@
+# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.

+ 13 - 0
paddlers/models/gan/__init__.py

@@ -0,0 +1,13 @@
+# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.

+ 0 - 1
paddlers/models/ppseg/__init__.py

@@ -13,6 +13,5 @@
 # limitations under the License.
 
 from . import models, datasets, transforms
-from . import rs_models
 
 __version__ = 'develop'

+ 15 - 0
paddlers/models/seg/__init__.py

@@ -0,0 +1,15 @@
+# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from . import models

+ 0 - 0
paddlers/models/ppseg/rs_models/__init__.py → paddlers/models/seg/models/__init__.py


+ 0 - 0
paddlers/models/ppseg/rs_models/farseg/__init__.py → paddlers/models/seg/models/farseg/__init__.py


+ 1 - 1
paddlers/models/ppseg/rs_models/farseg/farseg.py → paddlers/models/seg/models/farseg/farseg.py

@@ -17,7 +17,7 @@ import paddle.nn as nn
 import paddle.nn.functional as F
 from paddle.vision.models import resnet50
 from .fpn import FPN
-from ppseg.rs_models.utils import Identity
+from seg.models.utils import Identity
 
 
 class SceneRelation(nn.Layer):

+ 1 - 1
paddlers/models/ppseg/rs_models/farseg/fpn.py → paddlers/models/seg/models/farseg/fpn.py

@@ -14,7 +14,7 @@
 
 from paddle import nn
 import paddle.nn.functional as F
-from ppseg.rs_models.utils import (
+from seg.models.utils import (
     ConvReLU, kaiming_normal_init, constant_init
 )
 

+ 0 - 0
paddlers/models/ppseg/rs_models/utils/__init__.py → paddlers/models/seg/models/utils/__init__.py


+ 0 - 0
paddlers/models/ppseg/rs_models/utils/layers_lib.py → paddlers/models/seg/models/utils/layers_lib.py


+ 0 - 0
paddlers/models/ppseg/rs_models/utils/param_init.py → paddlers/models/seg/models/utils/param_init.py


+ 0 - 0
paddlers/models/ppseg/rs_models/utils/torch_nn.py → paddlers/models/seg/models/utils/torch_nn.py


+ 3 - 2
paddlers/tasks/changedetector.py

@@ -29,7 +29,7 @@ from .base import BaseModel
 from .utils import seg_metrics as metrics
 from paddlers.utils.checkpoint import seg_pretrain_weights_dict
 from paddlers.transforms import ImgDecoder, Resize
-from paddlers.models.ppcd import CDNet as _CDNet
+import paddlers.models.cd as cd
 
 __all__ = ["CDNet"]
 
@@ -59,7 +59,8 @@ class BaseChangeDetector(BaseModel):
 
     def build_net(self, **params):
         # TODO: add other model
-        net = _CDNet(num_classes=self.num_classes, **params)
+        net = cd.models.__dict__[self.model_name](
+            num_classes=self.num_classes, **params)
         return net
 
     def _fix_transforms_shape(self, image_shape):

+ 3 - 2
paddlers/tasks/segmenter.py

@@ -21,6 +21,7 @@ import paddle
 import paddle.nn.functional as F
 from paddle.static import InputSpec
 import paddlers.models.ppseg as paddleseg
+import paddlers.models.seg as seg
 import paddlers
 from paddlers.transforms import arrange_transforms
 from paddlers.utils import get_single_card_bs, DisablePrint
@@ -44,7 +45,7 @@ class BaseSegmenter(BaseModel):
             del self.init_params['with_net']
         super(BaseSegmenter, self).__init__('segmenter')
         if not hasattr(paddleseg.models, model_name) and \
-           not hasattr(paddleseg.rs_models, model_name):
+           not hasattr(seg.models, model_name):
             raise Exception("ERROR: There's no model named {}.".format(
                 model_name))
         self.model_name = model_name
@@ -60,7 +61,7 @@ class BaseSegmenter(BaseModel):
     def build_net(self, **params):
         # TODO: when using paddle.utils.unique_name.guard,
         # DeepLabv3p and HRNet will raise a error
-        net = dict(paddleseg.models.__dict__, **paddleseg.rs_models.__dict__)[self.model_name](
+        net = dict(paddleseg.models.__dict__, **seg.models.__dict__)[self.model_name](
             num_classes=self.num_classes, **params)
         return net