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

Fix CI #94

Merged
merged 7 commits into from
Apr 12, 2023
Merged
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
27 changes: 15 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
name: Ubuntu CI
name: CI

on: [push, pull_request, workflow_dispatch]
on: [pull_request, workflow_dispatch]

jobs:
main:
runs-on: ubuntu-18.04
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04, windows-latest]
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.8

- name: Upgrade pip
run: python3 -m pip install --upgrade pip

- name: Install Poetry
run: pip3 install poetry --user

Expand All @@ -25,21 +28,21 @@ jobs:
# Prints the help pages of all scripts to see if the imports etc. work
- name: Test the help pages
run: |
poetry run yolo-train -h
poetry run yolo-test -h
poetry run yolo-detect -h
poetry run yoeo-train -h
poetry run yoeo-test -h
poetry run yoeo-detect -h

- name: Demo Training
run: poetry run yolo-train --data config/custom.data --model config/yolov3.cfg --epochs 30
run: poetry run yoeo-train --data config/custom.data --epochs 30

- name: Demo Evaluate
run: poetry run yolo-test --data config/custom.data --model config/yolov3.cfg --weights checkpoints/yolov3_ckpt_29.pth
run: poetry run yoeo-test --data config/custom.data --weights checkpoints/yoeo_checkpoint_29.pth

- name: Demo Detect
run: poetry run yolo-detect --batch_size 2 --weights checkpoints/yolov3_ckpt_29.pth
run: poetry run yoeo-detect --batch_size 2 --weights checkpoints/yoeo_checkpoint_29.pth

linter:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You can adjust the log directory using `--logdir <path>` when running `tensorboa
## Train on Custom Dataset

#### Classes
Add class names to `data/custom/classes.names`. This file should have one row per class name.
Add class names to `data/custom/yoeo_names.yaml`.

#### Image Folder
Move the images of your dataset to `data/custom/images/`.
Expand All @@ -77,7 +77,7 @@ Move the images of your dataset to `data/custom/images/`.
Move your yolo annotations to `data/custom/labels/`. The dataloader expects that the annotation file corresponding to the image `data/custom/images/train.jpg` has the path `data/custom/labels/train.txt`. Each row in the annotation file should define one bounding box, using the syntax `label_idx x_center y_center width height`. The coordinates should be scaled `[0, 1]`, and the `label_idx` should be zero-indexed and correspond to the row number of the class name in `data/custom/classes.names`.

#### Segmentation Annotation Folder
Move your segmentation annotations to `data/custom/segmentations/`. The dataloader expects that the annotation file corresponding to the image `data/custom/images/train.jpg` has the path `data/custom/segmentations/train.png`. The classes for each pixel are encoded via the class id.
Move your segmentation annotations to `data/custom/yoeo_segmentations/`. The dataloader expects that the annotation file corresponding to the image `data/custom/images/train.jpg` has the path `data/custom/yoeo_segmentations/train.png`. The classes for each pixel are encoded via the class id.

#### Define Train and Validation Sets
In `data/custom/train.txt` and `data/custom/valid.txt`, add paths to images that will be used as train and validation data respectively.
Expand Down
3 changes: 1 addition & 2 deletions config/custom.data
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
classes= 1
train=data/custom/train.txt
valid=data/custom/valid.txt
names=data/custom/class_names.yaml
names=data/custom/yoeo_names.yaml
Binary file added data/custom/images/1028-img00671.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions data/custom/labels/1028-img00671.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2 0.7056451612903226 0.3854166666666667 0.10806451612903226 0.26666666666666666
2 0.09032258064516129 0.4510416666666667 0.18064516129032257 0.47708333333333336
1 0.3596774193548387 0.2677083333333333 0.07096774193548387 0.5354166666666667
0 0.6508064516129032 0.475 0.0467741935483871 0.0625
7 changes: 7 additions & 0 deletions data/custom/labels/138-16_02_2018__12_01_43_0417_upper.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
2 0.05625 0.19270833333333334 0.1125 0.08958333333333333
2 0.1375 0.09583333333333334 0.075 0.12916666666666668
2 0.228125 0.14479166666666668 0.090625 0.17708333333333334
2 0.41953125 0.128125 0.1046875 0.22708333333333333
2 0.65078125 0.12916666666666668 0.0671875 0.22916666666666666
1 0.23671875 0.042708333333333334 0.0234375 0.08541666666666667
1 0.00703125 0.11666666666666667 0.0140625 0.075
2 changes: 2 additions & 0 deletions data/custom/train.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/custom/images/1028-img00671.png
data/custom/images/138-16_02_2018__12_01_43_0417_upper.png
2 changes: 2 additions & 0 deletions data/custom/valid.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/custom/images/1028-img00671.png
data/custom/images/138-16_02_2018__12_01_43_0417_upper.png
8 changes: 8 additions & 0 deletions data/custom/yoeo_names.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
detection:
- ball
- goalpost
- robot
segmentation:
- background
- lines
- field
Binary file added data/custom/yoeo_segmentations/1028-img00671.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions yoeo/utils/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ def build_targets(p, targets, model):
# Check if we have targets
if nt:
t = t.squeeze(0)
# Check if we use anchor boxes
if na != 1:
# Calculate ratio between anchor and target box for both width and height
r = t[:, :, 4:6] / anchors[:, None]
# Select the ratios that have the highest divergence in any axis and check if the ratio is less than 4
Flova marked this conversation as resolved.
Show resolved Hide resolved
j = torch.max(r, 1. / r).max(2)[0] < 4
# Only use targets that have the correct ratios for their anchors
# That means we only keep ones that have a matching anchor and we loose the anchor dimension
# The anchor id is still saved in the 7th value of each target
t = t[j]
else:
t = targets[0]

Expand Down