Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yolov5 namespace #2886

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# vscode
.vscode

# Repo-specific GitIgnore ----------------------------------------------------------------------------------------------
*.jpg
*.jpeg
Expand Down Expand Up @@ -26,8 +29,8 @@
storage.googleapis.com
runs/*
data/*
!data/images/zidane.jpg
!data/images/bus.jpg
!yolov5/data/images/zidane.jpg
!yolov5/data/images/bus.jpg
!data/coco.names
!data/coco_paper.names
!data/coco.data
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 10 additions & 6 deletions detect.py β†’ yolov5/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
import torch.backends.cudnn as cudnn
from numpy import random

from models.experimental import attempt_load
from utils.datasets import LoadStreams, LoadImages
from utils.general import check_img_size, check_requirements, check_imshow, non_max_suppression, apply_classifier, \
scale_coords, xyxy2xywh, strip_optimizer, set_logging, increment_path, save_one_box
from utils.plots import plot_one_box
from utils.torch_utils import select_device, load_classifier, time_synchronized
from yolov5.models.experimental import attempt_load
from yolov5.utils.datasets import LoadImages, LoadStreams
from yolov5.utils.general import (apply_classifier, check_img_size,
check_imshow, check_requirements,
increment_path, non_max_suppression,
save_one_box, scale_coords, set_logging,
strip_optimizer, xyxy2xywh)
from yolov5.utils.plots import plot_one_box
from yolov5.utils.torch_utils import (load_classifier, select_device,
time_synchronized)


def detect():
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions models/common.py β†’ yolov5/models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
from PIL import Image
from torch.cuda import amp

from utils.datasets import letterbox
from utils.general import non_max_suppression, make_divisible, scale_coords, increment_path, xyxy2xywh, save_one_box
from utils.plots import color_list, plot_one_box
from utils.torch_utils import time_synchronized
from yolov5.utils.datasets import letterbox
from yolov5.utils.general import (increment_path, make_divisible,
non_max_suppression, save_one_box,
scale_coords, xyxy2xywh)
from yolov5.utils.plots import color_list, plot_one_box
from yolov5.utils.torch_utils import time_synchronized


def autopad(k, p=None): # kernel, padding
Expand Down
4 changes: 2 additions & 2 deletions models/experimental.py β†’ yolov5/models/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import torch
import torch.nn as nn

from models.common import Conv, DWConv
from utils.google_utils import attempt_download
from yolov5.models.common import Conv, DWConv
from yolov5.utils.google_utils import attempt_download


class CrossConv(nn.Module):
Expand Down
12 changes: 5 additions & 7 deletions models/export.py β†’ yolov5/models/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
import sys
import time

sys.path.append('./') # to run '$ python *.py' files in subdirectories

import torch
import torch.nn as nn

import models
from models.experimental import attempt_load
from utils.activations import Hardswish, SiLU
from utils.general import colorstr, check_img_size, check_requirements, set_logging
from utils.torch_utils import select_device
import yolov5.models
from yolov5.models.experimental import attempt_load
from yolov5.utils.activations import Hardswish, SiLU
from yolov5.utils.general import colorstr, check_img_size, check_requirements, set_logging
from yolov5.utils.torch_utils import select_device

if __name__ == '__main__':
parser = argparse.ArgumentParser()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions models/yolo.py β†’ yolov5/models/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import argparse
import logging
import sys
from copy import deepcopy

sys.path.append('./') # to run '$ python *.py' files in subdirectories
logger = logging.getLogger(__name__)

from models.common import *
from models.experimental import *
from utils.autoanchor import check_anchor_order
from utils.general import make_divisible, check_file, set_logging
from utils.torch_utils import time_synchronized, fuse_conv_and_bn, model_info, scale_img, initialize_weights, \
select_device, copy_attr
from yolov5.models.common import *
from yolov5.models.experimental import *
from yolov5.utils.autoanchor import check_anchor_order
from yolov5.utils.general import check_file, make_divisible, set_logging
from yolov5.utils.torch_utils import (copy_attr, fuse_conv_and_bn,
initialize_weights, model_info,
scale_img, select_device,
time_synchronized)

try:
import thop # for FLOPS computation
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 11 additions & 7 deletions test.py β†’ yolov5/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
import yaml
from tqdm import tqdm

from models.experimental import attempt_load
from utils.datasets import create_dataloader
from utils.general import coco80_to_coco91_class, check_dataset, check_file, check_img_size, check_requirements, \
box_iou, non_max_suppression, scale_coords, xyxy2xywh, xywh2xyxy, set_logging, increment_path, colorstr
from utils.metrics import ap_per_class, ConfusionMatrix
from utils.plots import plot_images, output_to_target, plot_study_txt
from utils.torch_utils import select_device, time_synchronized
from yolov5.models.experimental import attempt_load
from yolov5.utils.datasets import create_dataloader
from yolov5.utils.general import (box_iou, check_dataset, check_file,
check_img_size, check_requirements,
coco80_to_coco91_class, colorstr,
increment_path, non_max_suppression,
scale_coords, set_logging, xywh2xyxy,
xyxy2xywh)
from yolov5.utils.metrics import ConfusionMatrix, ap_per_class
from yolov5.utils.plots import output_to_target, plot_images, plot_study_txt
from yolov5.utils.torch_utils import select_device, time_synchronized


def test(data,
Expand Down
33 changes: 20 additions & 13 deletions train.py β†’ yolov5/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@
from torch.utils.tensorboard import SummaryWriter
from tqdm import tqdm

import test # import test.py to get mAP after each epoch
from models.experimental import attempt_load
from models.yolo import Model
from utils.autoanchor import check_anchors
from utils.datasets import create_dataloader
from utils.general import labels_to_class_weights, increment_path, labels_to_image_weights, init_seeds, \
fitness, strip_optimizer, get_latest_run, check_dataset, check_file, check_git_status, check_img_size, \
check_requirements, print_mutation, set_logging, one_cycle, colorstr
from utils.google_utils import attempt_download
from utils.loss import ComputeLoss
from utils.plots import plot_images, plot_labels, plot_results, plot_evolution
from utils.torch_utils import ModelEMA, select_device, intersect_dicts, torch_distributed_zero_first, is_parallel
from utils.wandb_logging.wandb_utils import WandbLogger, check_wandb_resume
import yolov5.test as test # import test.py to get mAP after each epoch
from yolov5.models.experimental import attempt_load
from yolov5.models.yolo import Model
from yolov5.utils.autoanchor import check_anchors
from yolov5.utils.datasets import create_dataloader
from yolov5.utils.general import (check_dataset, check_file, check_git_status,
check_img_size, check_requirements, colorstr,
fitness, get_latest_run, increment_path,
init_seeds, labels_to_class_weights,
labels_to_image_weights, one_cycle,
print_mutation, set_logging, strip_optimizer)
from yolov5.utils.google_utils import attempt_download
from yolov5.utils.loss import ComputeLoss
from yolov5.utils.plots import (plot_evolution, plot_images, plot_labels,
plot_results)
from yolov5.utils.torch_utils import (ModelEMA, intersect_dicts, is_parallel,
select_device,
torch_distributed_zero_first)
from yolov5.utils.wandb_logging.wandb_utils import (WandbLogger,
check_wandb_resume)

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion utils/autoanchor.py β†’ yolov5/utils/autoanchor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from scipy.cluster.vq import kmeans
from tqdm import tqdm

from utils.general import colorstr
from yolov5.utils.general import colorstr


def check_anchor_order(m):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 5 additions & 3 deletions utils/datasets.py β†’ yolov5/utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
from torch.utils.data import Dataset
from tqdm import tqdm

from utils.general import check_requirements, xyxy2xywh, xywh2xyxy, xywhn2xyxy, xyn2xy, segment2box, segments2boxes, \
resample_segments, clean_str
from utils.torch_utils import torch_distributed_zero_first
from yolov5.utils.general import (check_requirements, clean_str,
resample_segments, segment2box,
segments2boxes, xyn2xy, xywh2xyxy,
xywhn2xyxy, xyxy2xywh)
from yolov5.utils.torch_utils import torch_distributed_zero_first

# Parameters
help_url = 'https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data'
Expand Down
6 changes: 3 additions & 3 deletions utils/general.py β†’ yolov5/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import torchvision
import yaml

from utils.google_utils import gsutil_getsize
from utils.metrics import fitness
from utils.torch_utils import init_torch_seeds
from yolov5.utils.google_utils import gsutil_getsize
from yolov5.utils.metrics import fitness
from yolov5.utils.torch_utils import init_torch_seeds

# Settings
torch.set_printoptions(linewidth=320, precision=5, profile='long')
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions utils/loss.py β†’ yolov5/utils/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import torch
import torch.nn as nn

from utils.general import bbox_iou
from utils.torch_utils import is_parallel
from yolov5.utils.general import bbox_iou
from yolov5.utils.torch_utils import is_parallel


def smooth_BCE(eps=0.1): # https://github.com/ultralytics/yolov3/issues/238#issuecomment-598028441
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions utils/plots.py β†’ yolov5/utils/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from PIL import Image, ImageDraw, ImageFont
from scipy.signal import butter, filtfilt

from utils.general import xywh2xyxy, xyxy2xywh
from utils.metrics import fitness
from yolov5.utils.general import xywh2xyxy, xyxy2xywh
from yolov5.utils.metrics import fitness

# Settings
matplotlib.rc('font', **{'size': 11})
Expand Down
File renamed without changes.
Empty file.
File renamed without changes.