Hello!
I need to replace the person in the scene with another model, leaving everything else (clothes, stage, lighting, etc.) unchanged.
So, I have a prompt like this in Imagen:
prompt = (
"Replace the person in [1] with the person from [2], keeping the same pose, "
"clothes, colors, lighting, and studio background. Produce a realistic photo."
)
data = {
"instances": [
{
"prompt": prompt,
"referenceImages": [
{
"referenceType": "REFERENCE_TYPE_RAW",
"referenceId": 1,
"referenceImage": {"bytesBase64Encoded": scene_b64},
},
{
"referenceType": "REFERENCE_TYPE_SUBJECT",
"referenceId": 2,
"referenceImage": {"bytesBase64Encoded": face_b64},
"subjectImageConfig": {
"subjectDescription": "a person with natural face",
"subjectType": "SUBJECT_TYPE_PERSON",
},
},
],
}
],
"parameters": {
"sampleCount": 2,
"seed": 2,
"language": "en",
"negativePrompt": (
"low quality, distorted face, artifacts, blurry, unnatural lighting"
),
},
}
Source files:
I got two results:
So, the second one is what I need, and the first one is not what I need at all. And this happens all the time. How can I fix this so that I don’t have to rely on luck? I feel like this is some kind of casino. Thank you!
Another example:
Input
(I can’t add more then 3 images, so i uploaded it)
Result
https://i.ibb.co/vx6KbmRr/2025-11-02-183201.png
Here it changed the colors and hair in the first try.




