admin管理员组

文章数量:1123704

I have explored the Google Imagen 3 Multimodal model to replace an object with another object generated by a prompt using the API.

I am trying to explore the possibility of replacing an object with another object that is provided by me , instead of being generated by a prompt.

Any ideas on how to do it? Will grounding the Imagen 3 model or function calling help? I am using the following code, as you can see the replacement object is generated by the prompt and is not being provided as a static object.

I want to be able to provide a picture of my corgi instead of using a prompt to generate a picture of the corgi.

image_prompt = """
a french bulldog sitting in a living room on a couch with green throw pillows and a throw blanket,
a circular mirror with a slim black border is on the wall above the couch
"""
generated_image = generation_model.generate_images(
    prompt=image_prompt,
    number_of_images=1,
    aspect_ratio="1:1",
    safety_filter_level="block_some",
    person_generation="dont_allow",
)

edit_prompt = "a corgi sitting on a couch"
raw_ref_image = RawReferenceImage(image=generated_image[0], reference_id=0)
mask_ref_image = MaskReferenceImage(
    reference_id=1,
    image=None,
    mask_mode="semantic",
    segmentation_classes=[8],
    dilation=0.1,
)
edited_image = edit_model.edit_image(
    prompt=edit_prompt,
    edit_mode="inpainting-insert",
    reference_images=[raw_ref_image, mask_ref_image],
    number_of_images=1,
    safety_filter_level="block_some",
    person_generation="allow_adult",
)

display_images(generated_image[0], edited_image[0])

本文标签: Inpainting insert with a custom image using Imagen 3 on Google GeminiStack Overflow