Skip to content

Commit

Permalink
Refactor YOLOv5 code for readability, maintainability, and efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
sanowl committed Jun 21, 2024
1 parent b20fa80 commit 2211ef5
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions models/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,15 @@
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative

from models.common import (
C3,
C3SPP,
C3TR,
SPP,
SPPF,
Bottleneck,
BottleneckCSP,
C3Ghost,
C3x,
Classify,
Concat,
Contract,
Conv,
CrossConv,
DetectMultiBackend,
DWConv,
DWConvTranspose2d,
Expand,
Focus,
GhostBottleneck,
GhostConv,
Proto,
C3, C3SPP, C3TR, SPP, SPPF, Bottleneck, BottleneckCSP, C3Ghost, C3x, Classify, Concat, Contract, Conv,
CrossConv, DetectMultiBackend, DWConv, DWConvTranspose2d, Expand, Focus, GhostBottleneck, GhostConv, Proto,
)
from models.experimental import MixConv2d
from utils.autoanchor import check_anchor_order
from utils.general import LOGGER, check_version, check_yaml, colorstr, make_divisible, print_args
from utils.plots import feature_visualization
from utils.torch_utils import (
fuse_conv_and_bn,
initialize_weights,
model_info,
profile,
scale_img,
select_device,
time_sync,
fuse_conv_and_bn, initialize_weights, model_info, profile, scale_img, select_device, time_sync,
)

try:
Expand Down Expand Up @@ -341,7 +315,7 @@ def __init__(self, cfg="yolov5s-seg.yaml", ch=3, nc=None, anchors=None):
class ClassificationModel(BaseModel):
# YOLOv5 classification model
def __init__(self, cfg=None, model=None, nc=1000, cutoff=10):
"""Initializes YOLOv5 model with config file `cfg`, input channels `ch`, number of classes `nc`, and `cuttoff`
"""Initializes YOLOv5 model with config file `cfg`, input channels `ch`, number of classes `nc`, and `cutoff`
index.
"""
super().__init__()
Expand Down

0 comments on commit 2211ef5

Please sign in to comment.