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

Grayscale v7 #6

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1ac56a2
Added grayscale
Feb 21, 2022
8391372
Changed train and val plots limit to 16
Apr 4, 2022
9020f08
Many validations sets, albumentations json, mosaic drop
Jul 29, 2022
cd1f194
mAP plots
Aug 2, 2022
90bca07
separate results polts
Aug 3, 2022
77565be
All class plots & epoch to csv fix
Aug 4, 2022
76b3cde
Summary plot fix
Aug 5, 2022
e96a537
Default agumentations
Aug 5, 2022
96433ed
code cleanup
Aug 5, 2022
2bac69b
training jupyter
Aug 5, 2022
ee27bb4
saving best for each valid set
Aug 5, 2022
0cdf7a2
Merge pull request #1 from Surveily/feature/QoL
Sumered Aug 5, 2022
3b2767a
Mistakes saved during validation
Oct 25, 2022
c979d03
Added yolo_analyze_service, changed hyps to have new params
Nov 16, 2022
e239d38
Added changes in plots
Nov 16, 2022
54c346e
Removed copyrights
Nov 16, 2022
fdab5e2
Merge pull request #2 from Surveily/grayscale-update
kbegiedza Nov 16, 2022
98cb6fb
Update requirements.txt
kbegiedza Nov 18, 2022
0eaf38a
Merge pull request #4 from Surveily/grayscale-requirements
kbegiedza Nov 18, 2022
6544d52
Fixed loss.py for newer torch, fixed typo in hyps
Nov 18, 2022
ae6a0a7
Merge pull request #5 from Surveily/grayscale-update
kbegiedza Nov 22, 2022
49ab6fe
Merge branch 'grayscale' into grayscale-v7
Dec 7, 2022
ddb5104
Fixes after testing
Dec 8, 2022
9e38289
Added switch for rgb and grayscale
Dec 8, 2022
c22b8b2
Typo and small mistakes fixes
Dec 8, 2022
a833598
Rgb/Grayscale handling for tb graph
Dec 9, 2022
5c10af8
Typo fixes
Dec 9, 2022
0e3b271
Tiny code readability improvement
Dec 9, 2022
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
35 changes: 35 additions & 0 deletions Train.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "4fbd6fa3-a31c-4ba1-a917-6669fafcd904",
"metadata": {},
"outputs": [],
"source": [
"!python -m torch.distributed.launch --nproc_per_node 2 train.py --img <img size> --batch <number of batches> --epochs <number of epochs> --data <yaml with labels path> --hyp data/hyps/hyp.scratch-low.yaml --weights yolov5m --cache --device 0,1 --name <experiment name>"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
7 changes: 7 additions & 0 deletions data/hyps/hyp.Objects365.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ fliplr: 0.5
mosaic: 1.0
mixup: 0.0
copy_paste: 0.0

# Custom Params
area_threshold: 0.3 # area threshold for random perspective
maximum_mistakes_size: 7680 # image size for mistakes mosaic
maximum_mistakes_subplots: 64 # subimages in mistakes mosaic
minimum_mistakes_iou: 0.5 # mistakes minimum iou for match
minimum_mistakes_confidence: 0.5 # mistakes minimum confidence for checking
7 changes: 7 additions & 0 deletions data/hyps/hyp.scratch-high.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ fliplr: 0.5 # image flip left-right (probability)
mosaic: 1.0 # image mosaic (probability)
mixup: 0.1 # image mixup (probability)
copy_paste: 0.1 # segment copy-paste (probability)

# Custom Params
area_threshold: 0.3 # area threshold for random perspective
maximum_mistakes_size: 7680 # image size for mistakes mosaic
maximum_mistakes_subplots: 64 # subimages in mistakes mosaic
minimum_mistakes_iou: 0.5 # mistakes minimum iou for match
minimum_mistakes_confidence: 0.5 # mistakes minimum confidence for checking
7 changes: 7 additions & 0 deletions data/hyps/hyp.scratch-low.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ fliplr: 0.5 # image flip left-right (probability)
mosaic: 1.0 # image mosaic (probability)
mixup: 0.0 # image mixup (probability)
copy_paste: 0.0 # segment copy-paste (probability)

# Custom Params
area_threshold: 0.3 # area threshold for random perspective
maximum_mistakes_size: 7680 # image size for mistakes mosaic
maximum_mistakes_subplots: 64 # subimages in mistakes mosaic
minimum_mistakes_iou: 0.5 # mistakes minimum iou for match
minimum_mistakes_confidence: 0.5 # mistakes minimum confidence for checking
7 changes: 7 additions & 0 deletions data/hyps/hyp.scratch-med.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ fliplr: 0.5 # image flip left-right (probability)
mosaic: 1.0 # image mosaic (probability)
mixup: 0.1 # image mixup (probability)
copy_paste: 0.0 # segment copy-paste (probability)

# Custom Params
area_threshold: 0.3 # area threshold for random perspective
maximum_mistakes_size: 7680 # image size for mistakes mosaic
maximum_mistakes_subplots: 64 # subimages in mistakes mosaic
minimum_mistakes_iou: 0.5 # mistakes minimum iou for match
minimum_mistakes_confidence: 0.5 # mistakes minimum confidence for checking
7 changes: 6 additions & 1 deletion models/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _apply(self, fn):

class DetectionModel(BaseModel):
# YOLOv5 detection model
def __init__(self, cfg='yolov5s.yaml', ch=3, nc=None, anchors=None): # model, input channels, number of classes
def __init__(self, cfg='yolov5s.yaml', ch=1, nc=None, anchors=None): # model, input channels, number of classes
super().__init__()
if isinstance(cfg, dict):
self.yaml = cfg # model dict
Expand All @@ -188,6 +188,9 @@ def __init__(self, cfg='yolov5s.yaml', ch=3, nc=None, anchors=None): # model, i

# Build strides, anchors
m = self.model[-1] # Detect()

ch = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why override anyway here ?


if isinstance(m, (Detect, Segment)):
s = 256 # 2x min stride
m.inplace = self.inplace
Expand Down Expand Up @@ -298,11 +301,13 @@ def _from_yaml(self, cfg):

def parse_model(d, ch): # model_dict, input_channels(3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input_channels(3) -> 1

# Parse a YOLOv5 model.yaml dictionary
ch = [1] #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment (maybe use passed value instead of overriding it)

LOGGER.info(f"\n{'':>3}{'from':>18}{'n':>3}{'params':>10} {'module':<40}{'arguments':<30}")
anchors, nc, gd, gw, act = d['anchors'], d['nc'], d['depth_multiple'], d['width_multiple'], d.get('activation')
if act:
Conv.default_act = eval(act) # redefine default activation, i.e. Conv.default_act = nn.SiLU()
LOGGER.info(f"{colorstr('activation:')} {act}") # print

na = (len(anchors[0]) // 2) if isinstance(anchors, list) else anchors # number of anchors
no = na * (nc + 5) # number of outputs = anchors * (classes + 5)

Expand Down
1 change: 1 addition & 0 deletions models/yolov5m.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ head:

[[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
]
ch: 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add to other yamls if required

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ psutil # system resources
PyYAML>=5.3.1
requests>=2.23.0
scipy>=1.4.1
thop>=0.1.1 # FLOPs computation
torch>=1.7.0 # see https://pytorch.org/get-started/locally (recommended)
thop>=0.1.1 # FLOPs computation
torch>=1.7.0
torchvision>=0.8.1
tqdm>=4.64.0
# protobuf<=3.20.1 # https://github.com/ultralytics/yolov5/issues/8012
Expand Down
Loading