diff --git a/__pycache__/test.cpython-38.pyc b/__pycache__/test.cpython-38.pyc new file mode 100644 index 0000000..b438747 Binary files /dev/null and b/__pycache__/test.cpython-38.pyc differ diff --git a/data/val2yolo.py b/data/val2yolo.py index ddd8eda..2c167b3 100644 --- a/data/val2yolo.py +++ b/data/val2yolo.py @@ -44,7 +44,7 @@ def wider2face(root, phase='val', ignore_small=0): if box[2] < ignore_small or box[3] < ignore_small: continue box = convert((width, height), xywh2xxyy(box)) - label = '0 {} {} {} {} -1 -1 -1 -1 -1 -1 -1 -1 -1 -1'.format(round(box[0], 4), round(box[1], 4), + label = '0 {} {} {} {}'.format(round(box[0], 4), round(box[1], 4), round(box[2], 4), round(box[3], 4)) data[path].append(label) return data @@ -61,6 +61,7 @@ def wider2face(root, phase='val', ignore_small=0): exit(1) root_path = sys.argv[1] + print("print path :",os.path.join(root_path, 'val', 'label.txt'),"\n") if not os.path.isfile(os.path.join(root_path, 'val', 'label.txt')): print('Missing label.txt file.') exit(1) diff --git a/data/widerface.yaml b/data/widerface.yaml index 999f44c..9d3e017 100644 --- a/data/widerface.yaml +++ b/data/widerface.yaml @@ -10,8 +10,8 @@ download: bash data/scripts/get_voc.sh # train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/] -train: /ssd_1t/derron/yolov5-face/data/widerface/train # 16551 images -val: /ssd_1t/derron/yolov5-face/data/widerface/val # 16551 images +train: C:\Mantra_works\Facial\Dataset\Save\Wider_face_train # 16551 images +val: C:\Mantra_works\Facial\Dataset\Save\Wider_face_vald # 16551 images #val: /ssd_1t/derron/yolov5-face/data/widerface/train/ # 4952 images # number of classes diff --git a/download_weights.py b/download_weights.py new file mode 100644 index 0000000..927e60c --- /dev/null +++ b/download_weights.py @@ -0,0 +1,2 @@ +from utils.google_utils import attempt_download +attempt_download(f'yolov5s.pt') \ No newline at end of file diff --git a/models/common.py b/models/common.py index e8d2efd..a391119 100644 --- a/models/common.py +++ b/models/common.py @@ -40,7 +40,7 @@ def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True): # ch_in, ch_out, k super(Conv, self).__init__() self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False) self.bn = nn.BatchNorm2d(c2) - self.act = nn.SiLU() if act is True else (act if isinstance(act, nn.Module) else nn.Identity()) + self.act = nn.LeakyReLU(0.1,inplace=True) if act is True else (act if isinstance(act, nn.Module) else nn.Identity()) #self.act = self.act = nn.LeakyReLU(0.1, inplace=True) if act is True else (act if isinstance(act, nn.Module) else nn.Identity()) def forward(self, x): @@ -127,7 +127,7 @@ def __init__(self, inp, oup, stride): nn.BatchNorm2d(inp), nn.Conv2d(inp, branch_features, kernel_size=1, stride=1, padding=0, bias=False), nn.BatchNorm2d(branch_features), - nn.SiLU(), + nn.LeakyReLU(0.1,inplace=True), ) else: self.branch1 = nn.Sequential() @@ -135,12 +135,12 @@ def __init__(self, inp, oup, stride): self.branch2 = nn.Sequential( nn.Conv2d(inp if (self.stride > 1) else branch_features, branch_features, kernel_size=1, stride=1, padding=0, bias=False), nn.BatchNorm2d(branch_features), - nn.SiLU(), + nn.LeakyReLU(0.1,inplace=True), self.depthwise_conv(branch_features, branch_features, kernel_size=3, stride=self.stride, padding=1), nn.BatchNorm2d(branch_features), nn.Conv2d(branch_features, branch_features, kernel_size=1, stride=1, padding=0, bias=False), nn.BatchNorm2d(branch_features), - nn.SiLU(), + nn.LeakyReLU(0.1,inplace=True), ) @staticmethod @@ -180,7 +180,7 @@ def __init__(self, in_channels,out_channels,mid_channels=None,stride=1): nn.BatchNorm2d(out_channels), ) - self.relu = nn.SiLU(inplace=True) + self.relu = nn.LeakyReLU(0.1,inplace=True) def forward(self, x): branch1 = self.branch1(x) @@ -202,7 +202,7 @@ def __init__(self,in_channels,out_channels,mid_channels=None,stride=1): nn.BatchNorm2d(in_channels), nn.Conv2d(in_channels=in_channels, out_channels=mid_channels, kernel_size=1, stride=1), nn.BatchNorm2d(mid_channels), - nn.SiLU(inplace=True), + nn.LeakyReLU(0.1,inplace=True), nn.Conv2d(in_channels=mid_channels, out_channels=mid_channels, kernel_size=5, stride=1,padding=2), nn.BatchNorm2d(mid_channels), nn.Conv2d(in_channels=mid_channels, out_channels=out_channels, kernel_size=1, stride=1), @@ -216,7 +216,7 @@ def __init__(self,in_channels,out_channels,mid_channels=None,stride=1): nn.BatchNorm2d(out_channels), ) - self.relu = nn.SiLU(inplace=True) + self.relu = nn.LeakyReLU(0.1,inplace=True) def forward(self, x): branch1 = self.branch1(x) diff --git a/models/yolov5s.yaml b/models/yolov5s.yaml index 3e27b3b..5257d27 100644 --- a/models/yolov5s.yaml +++ b/models/yolov5s.yaml @@ -1,6 +1,6 @@ # parameters nc: 1 # number of classes -depth_multiple: 0.33 # model depth multiple +depth_multiple: 1.0 # model depth multiple width_multiple: 0.5 # layer channel multiple # anchors diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0d2b987 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,57 @@ +absl-py==2.1.0 +cachetools==5.3.3 +certifi==2024.7.4 +charset-normalizer==3.3.2 +colorama==0.4.6 +contourpy==1.1.1 +cycler==0.12.1 +filelock==3.15.4 +fonttools==4.53.1 +fsspec==2024.6.1 +google-auth==2.32.0 +google-auth-oauthlib==1.0.0 +grpcio==1.64.1 +idna==3.7 +importlib_metadata==8.0.0 +importlib_resources==6.4.0 +intel-openmp==2021.4.0 +Jinja2==3.1.4 +kiwisolver==1.4.5 +Markdown==3.6 +MarkupSafe==2.1.5 +matplotlib==3.7.5 +mkl==2021.4.0 +mpmath==1.3.0 +networkx==3.1 +numpy==1.24.4 +oauthlib==3.2.2 +opencv-python==4.10.0.84 +packaging==24.1 +pandas==2.0.3 +pillow==10.4.0 +protobuf==5.27.2 +pyasn1==0.6.0 +pyasn1_modules==0.4.0 +pyparsing==3.1.2 +python-dateutil==2.9.0.post0 +pytz==2024.1 +PyYAML==6.0.1 +requests==2.32.3 +requests-oauthlib==2.0.0 +rsa==4.9 +scipy==1.10.1 +seaborn==0.13.2 +six==1.16.0 +sympy==1.13.0 +tbb==2021.13.0 +tensorboard==2.14.0 +tensorboard-data-server==0.7.2 +thop==0.1.1.post2209072238 +torch==2.3.1 +torchvision==0.18.1 +tqdm==4.66.4 +typing_extensions==4.12.2 +tzdata==2024.1 +urllib3==2.2.2 +Werkzeug==3.0.3 +zipp==3.19.2 diff --git a/runs/train/exp/events.out.tfevents.1721043755.DESKTOP-D2JUS4J.2112.0 b/runs/train/exp/events.out.tfevents.1721043755.DESKTOP-D2JUS4J.2112.0 new file mode 100644 index 0000000..2a93862 Binary files /dev/null and b/runs/train/exp/events.out.tfevents.1721043755.DESKTOP-D2JUS4J.2112.0 differ diff --git a/runs/train/exp/hyp.yaml b/runs/train/exp/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp/opt.yaml b/runs/train/exp/opt.yaml new file mode 100644 index 0000000..e9a9947 --- /dev/null +++ b/runs/train/exp/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp diff --git a/runs/train/exp10/events.out.tfevents.1721047110.DESKTOP-D2JUS4J.9500.0 b/runs/train/exp10/events.out.tfevents.1721047110.DESKTOP-D2JUS4J.9500.0 new file mode 100644 index 0000000..f38e156 Binary files /dev/null and b/runs/train/exp10/events.out.tfevents.1721047110.DESKTOP-D2JUS4J.9500.0 differ diff --git a/runs/train/exp10/hyp.yaml b/runs/train/exp10/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp10/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp10/labels.jpg b/runs/train/exp10/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp10/labels.jpg differ diff --git a/runs/train/exp10/labels_correlogram.jpg b/runs/train/exp10/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp10/labels_correlogram.jpg differ diff --git a/runs/train/exp10/opt.yaml b/runs/train/exp10/opt.yaml new file mode 100644 index 0000000..25f2284 --- /dev/null +++ b/runs/train/exp10/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp10 diff --git a/runs/train/exp11/events.out.tfevents.1721047353.DESKTOP-D2JUS4J.12392.0 b/runs/train/exp11/events.out.tfevents.1721047353.DESKTOP-D2JUS4J.12392.0 new file mode 100644 index 0000000..53735f2 Binary files /dev/null and b/runs/train/exp11/events.out.tfevents.1721047353.DESKTOP-D2JUS4J.12392.0 differ diff --git a/runs/train/exp11/hyp.yaml b/runs/train/exp11/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp11/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp11/labels.jpg b/runs/train/exp11/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp11/labels.jpg differ diff --git a/runs/train/exp11/labels_correlogram.jpg b/runs/train/exp11/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp11/labels_correlogram.jpg differ diff --git a/runs/train/exp11/opt.yaml b/runs/train/exp11/opt.yaml new file mode 100644 index 0000000..3d5d391 --- /dev/null +++ b/runs/train/exp11/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp11 diff --git a/runs/train/exp12/events.out.tfevents.1721047836.DESKTOP-D2JUS4J.9296.0 b/runs/train/exp12/events.out.tfevents.1721047836.DESKTOP-D2JUS4J.9296.0 new file mode 100644 index 0000000..bf6026c Binary files /dev/null and b/runs/train/exp12/events.out.tfevents.1721047836.DESKTOP-D2JUS4J.9296.0 differ diff --git a/runs/train/exp12/hyp.yaml b/runs/train/exp12/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp12/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp12/labels.jpg b/runs/train/exp12/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp12/labels.jpg differ diff --git a/runs/train/exp12/labels_correlogram.jpg b/runs/train/exp12/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp12/labels_correlogram.jpg differ diff --git a/runs/train/exp12/opt.yaml b/runs/train/exp12/opt.yaml new file mode 100644 index 0000000..aac64df --- /dev/null +++ b/runs/train/exp12/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp12 diff --git a/runs/train/exp13/events.out.tfevents.1721048049.DESKTOP-D2JUS4J.8848.0 b/runs/train/exp13/events.out.tfevents.1721048049.DESKTOP-D2JUS4J.8848.0 new file mode 100644 index 0000000..bb6e7d4 Binary files /dev/null and b/runs/train/exp13/events.out.tfevents.1721048049.DESKTOP-D2JUS4J.8848.0 differ diff --git a/runs/train/exp13/hyp.yaml b/runs/train/exp13/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp13/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp13/labels.jpg b/runs/train/exp13/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp13/labels.jpg differ diff --git a/runs/train/exp13/labels_correlogram.jpg b/runs/train/exp13/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp13/labels_correlogram.jpg differ diff --git a/runs/train/exp13/opt.yaml b/runs/train/exp13/opt.yaml new file mode 100644 index 0000000..73ab76e --- /dev/null +++ b/runs/train/exp13/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp13 diff --git a/runs/train/exp13/train_batch0.jpg b/runs/train/exp13/train_batch0.jpg new file mode 100644 index 0000000..8a65645 Binary files /dev/null and b/runs/train/exp13/train_batch0.jpg differ diff --git a/runs/train/exp13/train_batch1.jpg b/runs/train/exp13/train_batch1.jpg new file mode 100644 index 0000000..7c514d7 Binary files /dev/null and b/runs/train/exp13/train_batch1.jpg differ diff --git a/runs/train/exp13/train_batch2.jpg b/runs/train/exp13/train_batch2.jpg new file mode 100644 index 0000000..579c9d4 Binary files /dev/null and b/runs/train/exp13/train_batch2.jpg differ diff --git a/runs/train/exp2/events.out.tfevents.1721045221.DESKTOP-D2JUS4J.18104.0 b/runs/train/exp2/events.out.tfevents.1721045221.DESKTOP-D2JUS4J.18104.0 new file mode 100644 index 0000000..a2fee89 Binary files /dev/null and b/runs/train/exp2/events.out.tfevents.1721045221.DESKTOP-D2JUS4J.18104.0 differ diff --git a/runs/train/exp2/hyp.yaml b/runs/train/exp2/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp2/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp2/opt.yaml b/runs/train/exp2/opt.yaml new file mode 100644 index 0000000..66a9c38 --- /dev/null +++ b/runs/train/exp2/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp2 diff --git a/runs/train/exp3/events.out.tfevents.1721045454.DESKTOP-D2JUS4J.9900.0 b/runs/train/exp3/events.out.tfevents.1721045454.DESKTOP-D2JUS4J.9900.0 new file mode 100644 index 0000000..5f5d280 Binary files /dev/null and b/runs/train/exp3/events.out.tfevents.1721045454.DESKTOP-D2JUS4J.9900.0 differ diff --git a/runs/train/exp3/hyp.yaml b/runs/train/exp3/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp3/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp3/opt.yaml b/runs/train/exp3/opt.yaml new file mode 100644 index 0000000..dc0320e --- /dev/null +++ b/runs/train/exp3/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp3 diff --git a/runs/train/exp4/events.out.tfevents.1721045550.DESKTOP-D2JUS4J.5048.0 b/runs/train/exp4/events.out.tfevents.1721045550.DESKTOP-D2JUS4J.5048.0 new file mode 100644 index 0000000..7f2594a Binary files /dev/null and b/runs/train/exp4/events.out.tfevents.1721045550.DESKTOP-D2JUS4J.5048.0 differ diff --git a/runs/train/exp4/hyp.yaml b/runs/train/exp4/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp4/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp4/labels.jpg b/runs/train/exp4/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp4/labels.jpg differ diff --git a/runs/train/exp4/labels_correlogram.jpg b/runs/train/exp4/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp4/labels_correlogram.jpg differ diff --git a/runs/train/exp4/opt.yaml b/runs/train/exp4/opt.yaml new file mode 100644 index 0000000..84ca34f --- /dev/null +++ b/runs/train/exp4/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp4 diff --git a/runs/train/exp5/events.out.tfevents.1721045735.DESKTOP-D2JUS4J.14792.0 b/runs/train/exp5/events.out.tfevents.1721045735.DESKTOP-D2JUS4J.14792.0 new file mode 100644 index 0000000..82e56b2 Binary files /dev/null and b/runs/train/exp5/events.out.tfevents.1721045735.DESKTOP-D2JUS4J.14792.0 differ diff --git a/runs/train/exp5/hyp.yaml b/runs/train/exp5/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp5/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp5/labels.jpg b/runs/train/exp5/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp5/labels.jpg differ diff --git a/runs/train/exp5/labels_correlogram.jpg b/runs/train/exp5/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp5/labels_correlogram.jpg differ diff --git a/runs/train/exp5/opt.yaml b/runs/train/exp5/opt.yaml new file mode 100644 index 0000000..637ae29 --- /dev/null +++ b/runs/train/exp5/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp5 diff --git a/runs/train/exp6/events.out.tfevents.1721046157.DESKTOP-D2JUS4J.21192.0 b/runs/train/exp6/events.out.tfevents.1721046157.DESKTOP-D2JUS4J.21192.0 new file mode 100644 index 0000000..976fd53 Binary files /dev/null and b/runs/train/exp6/events.out.tfevents.1721046157.DESKTOP-D2JUS4J.21192.0 differ diff --git a/runs/train/exp6/hyp.yaml b/runs/train/exp6/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp6/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp6/labels.jpg b/runs/train/exp6/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp6/labels.jpg differ diff --git a/runs/train/exp6/labels_correlogram.jpg b/runs/train/exp6/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp6/labels_correlogram.jpg differ diff --git a/runs/train/exp6/opt.yaml b/runs/train/exp6/opt.yaml new file mode 100644 index 0000000..43cfb55 --- /dev/null +++ b/runs/train/exp6/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp6 diff --git a/runs/train/exp7/events.out.tfevents.1721046337.DESKTOP-D2JUS4J.14732.0 b/runs/train/exp7/events.out.tfevents.1721046337.DESKTOP-D2JUS4J.14732.0 new file mode 100644 index 0000000..67e0dfc Binary files /dev/null and b/runs/train/exp7/events.out.tfevents.1721046337.DESKTOP-D2JUS4J.14732.0 differ diff --git a/runs/train/exp7/hyp.yaml b/runs/train/exp7/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp7/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp7/labels.jpg b/runs/train/exp7/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp7/labels.jpg differ diff --git a/runs/train/exp7/labels_correlogram.jpg b/runs/train/exp7/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp7/labels_correlogram.jpg differ diff --git a/runs/train/exp7/opt.yaml b/runs/train/exp7/opt.yaml new file mode 100644 index 0000000..a3c59f7 --- /dev/null +++ b/runs/train/exp7/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp7 diff --git a/runs/train/exp8/events.out.tfevents.1721046563.DESKTOP-D2JUS4J.18684.0 b/runs/train/exp8/events.out.tfevents.1721046563.DESKTOP-D2JUS4J.18684.0 new file mode 100644 index 0000000..e8cb66d Binary files /dev/null and b/runs/train/exp8/events.out.tfevents.1721046563.DESKTOP-D2JUS4J.18684.0 differ diff --git a/runs/train/exp8/hyp.yaml b/runs/train/exp8/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp8/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp8/labels.jpg b/runs/train/exp8/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp8/labels.jpg differ diff --git a/runs/train/exp8/labels_correlogram.jpg b/runs/train/exp8/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp8/labels_correlogram.jpg differ diff --git a/runs/train/exp8/opt.yaml b/runs/train/exp8/opt.yaml new file mode 100644 index 0000000..ce554ec --- /dev/null +++ b/runs/train/exp8/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp8 diff --git a/runs/train/exp9/events.out.tfevents.1721046862.DESKTOP-D2JUS4J.19364.0 b/runs/train/exp9/events.out.tfevents.1721046862.DESKTOP-D2JUS4J.19364.0 new file mode 100644 index 0000000..587403e Binary files /dev/null and b/runs/train/exp9/events.out.tfevents.1721046862.DESKTOP-D2JUS4J.19364.0 differ diff --git a/runs/train/exp9/hyp.yaml b/runs/train/exp9/hyp.yaml new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/runs/train/exp9/hyp.yaml @@ -0,0 +1,28 @@ +lr0: 0.01 +lrf: 0.2 +momentum: 0.937 +weight_decay: 0.0005 +warmup_epochs: 3.0 +warmup_momentum: 0.8 +warmup_bias_lr: 0.1 +box: 0.05 +cls: 0.5 +landmark: 0.005 +cls_pw: 1.0 +obj: 1.0 +obj_pw: 1.0 +iou_t: 0.2 +anchor_t: 4.0 +fl_gamma: 0.0 +hsv_h: 0.015 +hsv_s: 0.7 +hsv_v: 0.4 +degrees: 0.0 +translate: 0.1 +scale: 0.5 +shear: 0.5 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.5 +mixup: 0.0 diff --git a/runs/train/exp9/labels.jpg b/runs/train/exp9/labels.jpg new file mode 100644 index 0000000..c911788 Binary files /dev/null and b/runs/train/exp9/labels.jpg differ diff --git a/runs/train/exp9/labels_correlogram.jpg b/runs/train/exp9/labels_correlogram.jpg new file mode 100644 index 0000000..23da4e6 Binary files /dev/null and b/runs/train/exp9/labels_correlogram.jpg differ diff --git a/runs/train/exp9/opt.yaml b/runs/train/exp9/opt.yaml new file mode 100644 index 0000000..6920ec1 --- /dev/null +++ b/runs/train/exp9/opt.yaml @@ -0,0 +1,34 @@ +weights: yolov5s.pt +cfg: models/yolov5s.yaml +data: data/widerface.yaml +hyp: data/hyp.scratch.yaml +epochs: 250 +batch_size: 16 +img_size: +- 800 +- 800 +rect: false +resume: false +nosave: false +notest: false +noautoanchor: false +evolve: false +bucket: '' +cache_images: false +image_weights: false +device: '' +multi_scale: false +single_cls: false +adam: false +sync_bn: false +local_rank: -1 +log_imgs: 16 +log_artifacts: false +workers: 4 +project: runs/train +name: exp +exist_ok: false +total_batch_size: 16 +world_size: 1 +global_rank: -1 +save_dir: runs\train\exp9 diff --git a/test.py b/test.py index a06f62a..6657dba 100644 --- a/test.py +++ b/test.py @@ -99,7 +99,7 @@ def test(data, for batch_i, (img, targets, paths, shapes) in enumerate(tqdm(dataloader, desc=s)): img = img.to(device, non_blocking=True) img = img.half() if half else img.float() # uint8 to fp16/32 - img /= 255.0 # 0 - 255 to 0.0 - 1.0 + img /= 256.0-0.5 # 0 - 255 to 0.0 - 1.0 targets = targets.to(device) nb, _, height, width = img.shape # batch size, channels, height, width diff --git a/train.py b/train.py index c47ef36..8973be0 100644 --- a/train.py +++ b/train.py @@ -263,7 +263,7 @@ def train(hyp, opt, device, tb_writer=None, wandb=None): optimizer.zero_grad() for i, (imgs, targets, paths, _) in pbar: # batch ------------------------------------------------------------- ni = i + nb * epoch # number integrated batches (since train start) - imgs = imgs.to(device, non_blocking=True).float() / 255.0 # uint8 to float32, 0-255 to 0.0-1.0 + imgs = imgs.to(device, non_blocking=True).float() / 256.0-0.5 # uint8 to float32, 0-255 to 0.0-1.0 # Warmup if ni <= nw: diff --git a/utils/face_datasets.py b/utils/face_datasets.py index efd6f49..52cd0e7 100755 --- a/utils/face_datasets.py +++ b/utils/face_datasets.py @@ -129,6 +129,7 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r f = [] # image files for p in path if isinstance(path, list) else [path]: p = Path(p) # os-agnostic + print("p: ", p,"\n") if p.is_dir(): # dir f += glob.glob(str(p / '**' / '*.*'), recursive=True) elif p.is_file(): # file @@ -171,7 +172,7 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r x[:, 0] = 0 n = len(shapes) # number of images - bi = np.floor(np.arange(n) / batch_size).astype(np.int) # batch index + bi = np.floor(np.arange(n) / batch_size).astype(np.int8) # batch index nb = bi[-1] + 1 # number of batches self.batch = bi # batch index of image self.n = n @@ -199,7 +200,7 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r elif mini > 1: shapes[i] = [1, 1 / mini] - self.batch_shapes = np.ceil(np.array(shapes) * img_size / stride + pad).astype(np.int) * stride + self.batch_shapes = np.ceil(np.array(shapes) * img_size / stride + pad).astype(np.int8) * stride # Cache images into memory for faster training (WARNING: large datasets may exceed system RAM) self.imgs = [None] * n diff --git a/utils/general.py b/utils/general.py index cb3a291..84d25c4 100755 --- a/utils/general.py +++ b/utils/general.py @@ -170,7 +170,7 @@ def labels_to_class_weights(labels, nc=80): return torch.Tensor() labels = np.concatenate(labels, 0) # labels.shape = (866643, 5) for COCO - classes = labels[:, 0].astype(np.int) # labels = [class xywh] + classes = labels[:, 0].astype(np.int8) # labels = [class xywh] weights = np.bincount(classes, minlength=nc) # occurrences per class # Prepend gridpoint count (for uCE training) @@ -185,7 +185,7 @@ def labels_to_class_weights(labels, nc=80): def labels_to_image_weights(labels, nc=80, class_weights=np.ones(80)): # Produces image weights based on class_weights and image contents - class_counts = np.array([np.bincount(x[:, 0].astype(np.int), minlength=nc) for x in labels]) + class_counts = np.array([np.bincount(x[:, 0].astype(np.int8), minlength=nc) for x in labels]) image_weights = (class_weights.reshape(1, nc) * class_counts).sum(1) # index = random.choices(range(n), weights=image_weights, k=1) # weight image sample return image_weights diff --git a/utils/loss.py b/utils/loss.py index 8211db9..1968bb7 100644 --- a/utils/loss.py +++ b/utils/loss.py @@ -144,7 +144,12 @@ def compute_loss(p, targets, model): # predictions, targets, model n = b.shape[0] # number of targets if n: nt += n # cumulative targets - ps = pi[b, a, gj, gi] # prediction subset corresponding to targets + print("b :",b.shape) + b_long = b.long() + a_long = a.long() + gj_long = gj.long() + gi_long =gi.long() + ps = pi[b_long, a_long, gj_long, gi_long] # prediction subset corresponding to targets # Regression pxy = ps[:, :2].sigmoid() * 2. - 0.5 @@ -154,7 +159,7 @@ def compute_loss(p, targets, model): # predictions, targets, model lbox += (1.0 - iou).mean() # iou loss # Objectness - tobj[b, a, gj, gi] = (1.0 - model.gr) + model.gr * iou.detach().clamp(0).type(tobj.dtype) # iou ratio + tobj[b_long, a_long, gj_long, gi_long] = (1.0 - model.gr) + model.gr * iou.detach().clamp(0).type(tobj.dtype) # iou ratio # Classification if model.nc > 1: # cls loss (only if multiple classes) @@ -237,10 +242,10 @@ def build_targets(p, targets, model): offsets = 0 # Define - b, c = t[:, :2].long().T # image, class + b, c = t[:, :2].float().T # image, class gxy = t[:, 2:4] # grid xy gwh = t[:, 4:6] # grid wh - gij = (gxy - offsets).long() + gij = (gxy - offsets).float() gi, gj = gij.T # grid xy indices # Append diff --git a/yolov5s-face.onnx b/yolov5s-face.onnx new file mode 100644 index 0000000..20e0d80 Binary files /dev/null and b/yolov5s-face.onnx differ diff --git a/yolov5s-face.pt b/yolov5s-face.pt new file mode 100644 index 0000000..7a26e7b Binary files /dev/null and b/yolov5s-face.pt differ diff --git a/yolov5s.pt b/yolov5s.pt new file mode 100644 index 0000000..841108f Binary files /dev/null and b/yolov5s.pt differ