How to use in ComfyUI
Hi, thanks for sharing your Lora! It works really well imo. I was just wondering how you utilize or make the box in ComfyUI ?
Do you just have to create the box in say photoshop and then use that as the first image ?
Yes, you just have to draw the red box on the image. We use Pillow for this, it is probably possible to create a ComfyUI component to do it - maybe there is one already - but I don't know ComfyUI at all. In the meantime using Photoshop or that Python snippet should work.
Something important to keep in mind is that the red box must have the ratio of the reference image. If you have a human-drawn bbox like this space you can use this function to compute this actual bbox.
hmmm ... one 10 works(not that much ^^) ... with comfy iam not shure how best parameters for image support.
so an image lets say sunglass must be the right size or only right aspect ratio to match the red box, i can deliver both option so that both images same size or that the real size match.
most often real size better so a small sunglass left side match the size of the face on the right side.
what you suggest for red box border size ? 1024 pix image and 3 pix border?
so an image lets say sunglass must be the right size or only right aspect ratio to match the red box
Only the aspect ratio matters.
As mentioned above, if a user draws a target box in the UI like this:
You can then use get_actual_bbox to compute the final box. This ensures the subject (sunglasses, etc) keeps its aspect ratio, fits inside the target box, and is positioned correctly.
That gives you the red box you should draw (see below for details):
most often real size better so a small sunglass left side match the size of the face on the right side.
We provide some examples in the Space to illustrate how this works:
You can find the corresponding assets here: https://huggingface.co/spaces/finegrain/finegrain-product-placement-lora/tree/main/examples
what you suggest for red box border size ? 1024 pix image and 3 pix border?
Short answer: 1024px image with a 6px border.
Long answer: the scene is resized the same way as in the Space here. The corresponding preprocessing code is in the finegrain-toolbox repo: see process:
Steps:
- Compute the low-res scene dimensions with
rescale_mod - Process the user-drawn box with
get_actual_bboxand rescale it viaproject_bboxso it fits the low-res scene. - Downscale the input scene image with
resize(Pillow). - Draw the red box on the downscaled scene image with
draw_bbox.
Reference image preparation:
For the input reference image, please make sure to provide a version with the background removed (a cutout), with no extra borders, like this:
(original image: link)
Then it gets processed by cutout_to_reference_image before being used by the model.
You can use the Finegrain Object Cutter Space to create such cutouts.
Hope this helps! Let us know if anything is unclear or if you have other questions.



