Skip to content

Commit

Permalink
Add spaces and non-UTF filenames to tests (ultralytics#4517)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored Aug 23, 2023
1 parent 67eeb04 commit 7e1f7a9
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,25 @@ def test_predict_img():
def test_predict_grey_and_4ch():
# Convert SOURCE to greyscale and 4-ch
im = Image.open(SOURCE)
source_greyscale = Path(f'{SOURCE.parent / SOURCE.stem}_greyscale.jpg')
source_rgba = Path(f'{SOURCE.parent / SOURCE.stem}_4ch.png')
stem = SOURCE.parent / SOURCE.stem

source_greyscale = Path(f'{stem}_greyscale.jpg')
source_rgba = Path(f'{stem}_4ch.png')
source_non_utf = Path(f'{stem}_veículo.jpg')
source_spaces = Path(f'{stem} with spaces.jpg')

im.convert('L').save(source_greyscale) # greyscale
im.convert('RGBA').save(source_rgba) # 4-ch PNG with alpha
im.save(source_non_utf) # non-UTF characters in filename
im.save(source_spaces) # spaces in filename

# Inference
model = YOLO(MODEL)
for f in source_rgba, source_greyscale:
for f in source_rgba, source_greyscale, source_non_utf, source_spaces:
for source in Image.open(f), cv2.imread(str(f)), f:
model(source, save=True, verbose=True, imgsz=32)

# Cleanup
source_greyscale.unlink()
source_rgba.unlink()
results = model(source, save=True, verbose=True, imgsz=32)
assert len(results) == 1 # verify that an image was run
f.unlink() # cleanup


@pytest.mark.skipif(not ONLINE, reason='environment is offline')
Expand Down

0 comments on commit 7e1f7a9

Please sign in to comment.