diff --git a/pysolotools/core/iterators/frame_iterator.py b/pysolotools/core/iterators/frame_iterator.py index d15c37e..0f3ba41 100644 --- a/pysolotools/core/iterators/frame_iterator.py +++ b/pysolotools/core/iterators/frame_iterator.py @@ -1,4 +1,5 @@ import glob +import logging import os import time @@ -11,6 +12,8 @@ from pysolotools.core.models import ( SemanticSegmentationAnnotation, ) +logger = logging.getLogger(__name__) + class FramesIterator: SENSORS = [ @@ -49,7 +52,7 @@ class FramesIterator: self.frame_idx = start pre = time.time() self.metadata = metadata - print("DONE (t={:0.5f}s)".format(time.time() - pre)) + logger.info("DONE (t={:0.5f}s)".format(time.time() - pre)) self.total_frames = self.metadata.totalFrames self.total_sequences = self.metadata.totalSequences diff --git a/tests/core/iterators/test_frame_iterator.py b/tests/core/iterators/test_frame_iterator.py index 3a3431d..57ee31b 100644 --- a/tests/core/iterators/test_frame_iterator.py +++ b/tests/core/iterators/test_frame_iterator.py @@ -1,3 +1,4 @@ +import logging from dataclasses import dataclass from unittest.mock import MagicMock @@ -16,6 +17,8 @@ from pysolotools.core import ( from pysolotools.core.iterators import FramesIterator from pysolotools.core.models import DatasetAnnotations, DatasetMetadata +logger = logging.getLogger(__name__) + @dataclass class FrameIteratorTest: @@ -51,7 +54,9 @@ class TestFramesIterator: lambda k: isinstance(k, RGBCameraCapture), setup_frame_iterator.frame.captures, ) - print(f"\n \n Testing with {len(list(rgb_captures))} RGBCameraCapture \n \n ") + logger.debug( + f"\n \n Testing with {len(list(rgb_captures))} RGBCameraCapture \n \n " + ) for capture in rgb_captures: assert isinstance(capture, RGBCameraCapture) @@ -66,7 +71,7 @@ class TestFramesIterator: bbox2dannotations = filter( lambda c: isinstance(c, BoundingBox2DAnnotation), annotations ) - print( + logger.debug( f"\n \n Testing with {len(list(bbox2dannotations))} BoundingBox2DAnnotation \n \n " ) for bbox2d in bbox2dannotations: @@ -75,7 +80,7 @@ class TestFramesIterator: bbox3dannotations = filter( lambda c: isinstance(c, BoundingBox3DAnnotation), annotations ) - print( + logger.debug( f"\n \n Testing with {len(list(bbox3dannotations))} BoundingBox3DAnnotation \n \n " ) for bbox3d in bbox3dannotations: @@ -84,7 +89,7 @@ class TestFramesIterator: instance_segmentation_annotations = filter( lambda c: isinstance(c, InstanceSegmentationAnnotation), annotations ) - print( + logger.debug( f"\n \n Testing with {len(list(instance_segmentation_annotations))} " f"InstanceSegmentationAnnotation \n \n " ) @@ -96,7 +101,7 @@ class TestFramesIterator: semantic_segmentation_annotations = filter( lambda c: isinstance(c, SemanticSegmentationAnnotation), annotations ) - print( + logger.debug( f"\n \n Testing with {len(list(semantic_segmentation_annotations))} " f"SemanticSegmentationAnnotation \n \n " ) @@ -108,7 +113,7 @@ class TestFramesIterator: keypoint_annotations = filter( lambda c: isinstance(c, KeypointAnnotation), annotations ) - print( + logger.debug( f"\n \n Testing with {len(list(keypoint_annotations))} " f"SemanticSegmentationAnnotation \n \n " )