mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 21:44:22 +08:00
Add spaces and non-UTF filenames to tests (#4517)
This commit is contained in:
parent
67eeb0468d
commit
7e1f7a9d28
@ -88,20 +88,25 @@ def test_predict_img():
|
|||||||
def test_predict_grey_and_4ch():
|
def test_predict_grey_and_4ch():
|
||||||
# Convert SOURCE to greyscale and 4-ch
|
# Convert SOURCE to greyscale and 4-ch
|
||||||
im = Image.open(SOURCE)
|
im = Image.open(SOURCE)
|
||||||
source_greyscale = Path(f'{SOURCE.parent / SOURCE.stem}_greyscale.jpg')
|
stem = SOURCE.parent / SOURCE.stem
|
||||||
source_rgba = Path(f'{SOURCE.parent / SOURCE.stem}_4ch.png')
|
|
||||||
|
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('L').save(source_greyscale) # greyscale
|
||||||
im.convert('RGBA').save(source_rgba) # 4-ch PNG with alpha
|
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
|
# Inference
|
||||||
model = YOLO(MODEL)
|
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:
|
for source in Image.open(f), cv2.imread(str(f)), f:
|
||||||
model(source, save=True, verbose=True, imgsz=32)
|
results = model(source, save=True, verbose=True, imgsz=32)
|
||||||
|
assert len(results) == 1 # verify that an image was run
|
||||||
# Cleanup
|
f.unlink() # cleanup
|
||||||
source_greyscale.unlink()
|
|
||||||
source_rgba.unlink()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not ONLINE, reason='environment is offline')
|
@pytest.mark.skipif(not ONLINE, reason='environment is offline')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user