Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new examples : a parallel pipeline for image processing(resize) #1755

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

milkymap
Copy link

@milkymap milkymap commented Sep 5, 2022

this example shows how to use zeromq and multiprocessing to set up a parallel system capable of processing(resize) a large volume of images. the architecture is based on 4 types of sockets : server-side: router/publisher, client-side : dealer/subscriber.

Copy link
Member

@minrk minrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Can you add a README.md describing this example, what it illustrates, and how to run it?

# a job is an image to resize and a path where the resized_image will be saved
# once, the image was resied, the worker can ask a new job
# server will keep sending job to workers until there is no images left or user hit ctl+c
NOTE: opencv, numpy, click, loguru must be installed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably makes sense to add a requirements.txt to the directory

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, as you suggest, i've added the README.md and a requirements.txt(click, pyzmq, pillow).

@@ -0,0 +1,17 @@
from sys import stdout

from loguru import logger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not worth it to use a third-party logger for a simple example? Let's stick to the standard library.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i also changed the loguru with the standard logging library.

start = time.time()
for cursor, path2source_image in enumerate(image_filepaths):
bgr_image = cv2.imread(path2source_image)
resized_image = cv2.resize(bgr_image, dsize=size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're just resizing images, pillow is a far lighter dependency than a full computer vision library like opencv.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new version use pillow for image resizing, hope this example will help the community to have a better understanding on how to combine zeromq and python-multiprocessing for fast image processing tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants