-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile_script.py
More file actions
43 lines (35 loc) · 1.22 KB
/
profile_script.py
File metadata and controls
43 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Script to profile memory usage of the image processor.
"""
from image_processor.transformations.processor import ImageProcessor
from image_processor.utils.test_data import generate_test_images
import os
import shutil
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
logger = logging.getLogger(__name__)
@profile
def process_images(input_dir, output_dir):
"""Process images with memory profiling."""
processor = ImageProcessor(input_dir, output_dir)
processor.process_images()
return processor
def main():
"""Run the image processor with memory profiling."""
input_dir = "data/input"
output_dir = "data/output"
# Clean directories
for dir_path in [input_dir, output_dir]:
if os.path.exists(dir_path):
shutil.rmtree(dir_path)
os.makedirs(dir_path)
# Generate test images
logger.info("Generating test images...")
generate_test_images(input_dir, num_images=5)
# Process images with memory profiling
logger.info("Processing images...")
process_images(input_dir, output_dir)
logger.info("Processing complete.")
if __name__ == "__main__":
main()