Fix: Ensure Object is Correctly Placed in Scene without Texturing when the texture is not provided

#4

In the previous implementation of the run_texture_scene method, if a texture image was not provided, the scene was being incorrectly set to the object image. This resulted in the object not being placed correctly in the provided scene.

To address this, I added a dedicated condition check to handle scenarios where only the object and scene images are provided, ensuring the object is correctly integrated into the scene.

Modified Code
Here is the modified run_texture_scene method with added comments for clarity:

def run_texture_scene(self, image_object_path, image_texture_path, image_scene_path):
# Process the input images
image_object = self.process_image(image_object_path)
image_texture = self.process_image(image_texture_path)
image_scene = self.process_image(image_scene_path)

if image_object is None:
    raise gr.Error('Object image is required')

current_emb = None

# If both object and scene images are provided, run scene processing
if image_scene is not None:
    current_emb = self.run_binary(input_a=image_object, input_b=image_scene, prior_type='scene')
    scene_input = current_emb.image_embeds
else:
    scene_input = image_object

# If a texture image is provided, apply texturing
if image_texture is not None:
    current_emb = self.run_binary(input_a=scene_input, input_b=image_texture, prior_type='texturing')

if current_emb is None:
    raise gr.Error('At least one of the images is required')

# Render the final image
image = self.render(current_emb)

return image

implementation of run_texture_scene, the method now correctly handles scenarios where:
Only the object and scene images are provided, ensuring the object is correctly placed within the scene.
A texture image is also provided, allowing for the application of texture to the combined object and scene.

Previous pops.py version:

1.png

updated pops.py version

1.png
10.png

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment