Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rafelafrance committed Feb 9, 2024
1 parent 44b477c commit a86aab7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ We find labels with a custom trained YOLOv7 model (https://github.com/WongKinYiu
Local scripts:
- `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.
- `yolo-inference`: Prepare herbarium sheet image for inference; i.e. finding labels. The images must be in the same size the training data.
- YOLO scripts also requires a CSV file containing the paths to the herbarium sheets and the class and location of the labels on that sheet.
- `yolo-inference`: Prepare herbarium sheet images 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`
Expand Down
12 changes: 8 additions & 4 deletions finder/pylib/sheet_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@ def to_yolo_image(path, yolo_images, yolo_size) -> tuple[int, int] | None:
try:
resized = image.resize((yolo_size, yolo_size))
resized.save(yolo)
return image.size

except IMAGE_EXCEPTIONS as err:
logging.error(f"Could not prepare {path.name}: {err}")
msg = f"Could not prepare {path.name}: {err}"
logging.exception(msg)
return None

return image.size


def sheet_image(path):
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning) # No EXIF warnings

try:
image = Image.open(path).convert("RGB")
return image

except IMAGE_EXCEPTIONS as err:
logging.error(f"Could not prepare {path.name}: {err}")
msg = f"Could not prepare {path.name}: {err}"
logging.exception(msg)
return None

return image
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ target-version = "py311"

show-fixes = true

select = [
lint.select = [
"F",
"E",
"W",
Expand Down Expand Up @@ -105,7 +105,7 @@ select = [
"RUF",
]

ignore = [
lint.ignore = [
"COM812", # Trailing comma missing
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
Expand Down

0 comments on commit a86aab7

Please sign in to comment.