Skip to content

Commit

Permalink
Remove setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rafelafrance committed Feb 9, 2024
1 parent 49238ab commit 44b477c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 52 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ We find labels with a custom trained YOLOv7 model (https://github.com/WongKinYiu
- All other identified labels are outlined in teal.

Local scripts:
- `build_training_data.py`: This formats images of herbarium sheets to prepare them for training a YOLO model.
- `fix-herbarium-sheet-names`: I had a problem where herbarium sheet file names were given as URLs and it confused the Pillow (PIL) module so I renamed the files to remove problem characters. You may not need this script.
- `yolo-training`: If you are training your own YOLO7 model then you may want to use this script to prepare the images of herbarium sheets for training. The herbarim images may be in all sorts of sizes, and model training requires that they're all uniformly sized.
- This script also requires a CSV file containing the paths to the herbarium sheets and the class and location of the labels on that sheet.
- `build_inference_data.py`: This formats herbarium sheet images for YOLO inference.
- It requires a CSV file containing the paths to all of the herbarium sheets.
- `results_to_labels.py`: This takes for output of the YOLO model and creates label images. The label name contains information about the YOLO results. The label name format:
- `yolo-inference`: Prepare herbarium sheet image for inference; i.e. finding labels. The images must be in the same size the training data.
- `yolo-results-to-labels`: This takes for output of the YOLO model and creates label images. The label name contains information about the YOLO results. The label name format:
- `<sheet name>_<label class>_<left pixel>_<top pixel>_<right pixel>_<bottom pixel>.jpg`
- For example: `my-herbarium-sheet_typewritten_2261_3580_3397_4611.jpg`
- `filter_labels.py`: Move typewritten label images into a separate directory.
- `fix_file_names.py`: I had a problem where herbarium sheet file names were given as URLs and it confused the Pillow (PIL) module so I renamed the files to remove problem characters. You probably won't need this.
- `old_*.py`: These modules are for ingesting training data from Zooniverse "expeditions". They are old and need to be rewritten.
- `filter_labels.py`: Move typewritten label images into a separate directory that are then available for further processing.

You will notice that there are no scripts for running the YOLO models directly. You will need to download that repository separately and run its scripts. Example invocations of YOLO scripts are below:

Expand Down
3 changes: 2 additions & 1 deletion finder/__finder_label_babel_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
import textwrap
from pathlib import Path

from pylib.rise_of_machines import reconcile_expedition
from util.pylib import log

from finder.pylib.rise_of_machines import reconcile_expedition


def main():
log.started()
Expand Down
3 changes: 2 additions & 1 deletion finder/__finder_rise_of_machines_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import textwrap
from pathlib import Path

from pylib.finder.rise_of_machines import build_expedition
from traiter.pylib import log

from finder.pylib.finder.rise_of_machines import build_expedition


def main():
log.started()
Expand Down
3 changes: 2 additions & 1 deletion finder/__finder_rise_of_machines_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import textwrap
from pathlib import Path

from pylib.finder.rise_of_machines import reconcile_expedition
from traiter.pylib import log

from finder.pylib.finder.rise_of_machines import reconcile_expedition


def main():
args = parse_args()
Expand Down
3 changes: 2 additions & 1 deletion finder/yolo_inference_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import textwrap
from pathlib import Path

from pylib.yolo import inference_data
from util.pylib import log

from finder.pylib.yolo import inference_data


def main():
log.started()
Expand Down
3 changes: 2 additions & 1 deletion finder/yolo_results_to_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import textwrap
from pathlib import Path

from pylib.yolo import yolo_to_labels
from util.pylib import log

from finder.pylib.yolo import yolo_to_labels


def main():
log.started()
Expand Down
3 changes: 2 additions & 1 deletion finder/yolo_training_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import textwrap
from pathlib import Path

from pylib.yolo import training_data
from util.pylib import log

from finder.pylib.yolo import training_data


def main():
log.started()
Expand Down
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ optional-dependencies.dev = [
"build",
"pre-commit",
"pre-commit-hooks",
"python-lsp-server[all]",
"ruff",
"ruff-lsp",
]

[project.scripts]
fix-herbarium-sheet-names = "finder.fix_herbarium_sheet_names:main"
get-typewritten-labels = "finder.get_typewritten_labels:main"
yolo-training = "finder.yolo_training:main"
yolo-inference = "finder.yolo_inference:main"
yolo-training = "finder.yolo_training_data:main"
yolo-inference = "finder.yolo_inference_data:main"
yolo-results-to-labels = "finder.yolo_results_to_labels:main"

[tool.setuptools]
py-modules = []

[tool.setuptools.packages.find]
where = ["."]
include = ["finder"]
namespaces = false

[tool.ruff]
target-version = "py311"

Expand Down
34 changes: 0 additions & 34 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/pylib/test_box_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy.testing as npt
import torch

import finder.pylib.old_box_calc as calc
from finder.pylib import old_box_calc as calc


class TestBoxCalc(unittest.TestCase):
Expand All @@ -22,7 +22,7 @@ def test_iou_02(self):
self.assertEqual(calc.iou(box1, box2), 0.0)

def test_iou_03(self):
"""It handles one box inside of another box."""
"""It handles one box inside another box."""
box1 = [0, 0, 10, 10]
box2 = [0, 0, 5, 5]
ii1 = 10.0 * 10.0
Expand Down

0 comments on commit 44b477c

Please sign in to comment.