🔥 [Remove] layer_helper, same func as module_helper
Browse files- yolo/model/yolo.py +1 -1
- yolo/tools/layer_helper.py +0 -17
- yolo/tools/module_helper.py +16 -0
yolo/model/yolo.py
CHANGED
|
@@ -5,8 +5,8 @@ from loguru import logger
|
|
| 5 |
from omegaconf import ListConfig, OmegaConf
|
| 6 |
|
| 7 |
from yolo.config.config import Config, Model, YOLOLayer
|
| 8 |
-
from yolo.tools.layer_helper import get_layer_map
|
| 9 |
from yolo.tools.log_helper import log_model
|
|
|
|
| 10 |
from yolo.utils.drawer import draw_model
|
| 11 |
|
| 12 |
|
|
|
|
| 5 |
from omegaconf import ListConfig, OmegaConf
|
| 6 |
|
| 7 |
from yolo.config.config import Config, Model, YOLOLayer
|
|
|
|
| 8 |
from yolo.tools.log_helper import log_model
|
| 9 |
+
from yolo.tools.module_helper import get_layer_map
|
| 10 |
from yolo.utils.drawer import draw_model
|
| 11 |
|
| 12 |
|
yolo/tools/layer_helper.py
CHANGED
|
@@ -3,20 +3,3 @@ import inspect
|
|
| 3 |
import torch.nn as nn
|
| 4 |
|
| 5 |
from yolo.model import module
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def auto_pad():
|
| 9 |
-
raise NotImplementedError
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def get_layer_map():
|
| 13 |
-
"""
|
| 14 |
-
Dynamically generates a dictionary mapping class names to classes,
|
| 15 |
-
filtering to include only those that are subclasses of nn.Module,
|
| 16 |
-
ensuring they are relevant neural network layers.
|
| 17 |
-
"""
|
| 18 |
-
layer_map = {}
|
| 19 |
-
for name, obj in inspect.getmembers(module, inspect.isclass):
|
| 20 |
-
if issubclass(obj, nn.Module) and obj is not nn.Module:
|
| 21 |
-
layer_map[name] = obj
|
| 22 |
-
return layer_map
|
|
|
|
| 3 |
import torch.nn as nn
|
| 4 |
|
| 5 |
from yolo.model import module
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yolo/tools/module_helper.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from typing import Tuple, Union
|
| 2 |
|
| 3 |
from torch import Tensor, nn
|
|
@@ -18,6 +19,21 @@ def auto_pad(kernel_size: _size_2_t, dilation: _size_2_t = 1, **kwargs) -> Tuple
|
|
| 18 |
return (pad_h, pad_w)
|
| 19 |
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
def get_activation(activation: str) -> nn.Module:
|
| 22 |
"""
|
| 23 |
Retrieves an activation function from the PyTorch nn module based on its name, case-insensitively.
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
from typing import Tuple, Union
|
| 3 |
|
| 4 |
from torch import Tensor, nn
|
|
|
|
| 19 |
return (pad_h, pad_w)
|
| 20 |
|
| 21 |
|
| 22 |
+
def get_layer_map():
|
| 23 |
+
"""
|
| 24 |
+
Dynamically generates a dictionary mapping class names to classes,
|
| 25 |
+
filtering to include only those that are subclasses of nn.Module,
|
| 26 |
+
ensuring they are relevant neural network layers.
|
| 27 |
+
"""
|
| 28 |
+
layer_map = {}
|
| 29 |
+
from yolo.model import module
|
| 30 |
+
|
| 31 |
+
for name, obj in inspect.getmembers(module, inspect.isclass):
|
| 32 |
+
if issubclass(obj, nn.Module) and obj is not nn.Module:
|
| 33 |
+
layer_map[name] = obj
|
| 34 |
+
return layer_map
|
| 35 |
+
|
| 36 |
+
|
| 37 |
def get_activation(activation: str) -> nn.Module:
|
| 38 |
"""
|
| 39 |
Retrieves an activation function from the PyTorch nn module based on its name, case-insensitively.
|