@@ -665,6 +665,7 @@ def _generate_images(
665
665
"inpainting-remove" ,
666
666
"outpainting" ,
667
667
"product-image" ,
668
+ "background-swap" ,
668
669
"default" ,
669
670
]
670
671
] = None ,
@@ -724,6 +725,8 @@ def _generate_images(
724
725
mask)
725
726
* product-image: Changes the background for the predominant
726
727
product or subject in the image
728
+ * background-swap: Changes the background for the predominant
729
+ product or subject in the image
727
730
* default: Default editing mode
728
731
mask_mode: Solicits generation of the mask (v/s providing mask as an
729
732
input). Supported values are:
@@ -884,7 +887,9 @@ class ID
884
887
if isinstance (reference_image .config , ControlImageConfig ):
885
888
reference_image_instance ["controlImageConfig" ] = {
886
889
"controlType" : reference_image .config .control_type ,
887
- "enableControlImageComputation" : reference_image .config .enable_control_image_computation ,
890
+ "enableControlImageComputation" : (
891
+ reference_image .config .enable_control_image_computation
892
+ ),
888
893
}
889
894
shared_generation_parameters [
890
895
f"reference_image_control_config_{ reference_image .reference_id } "
@@ -952,6 +957,7 @@ class ID
952
957
"inpainting-insert" : "EDIT_MODE_INPAINT_INSERTION" ,
953
958
"inpainting-remove" : "EDIT_MODE_INPAINT_REMOVAL" ,
954
959
"outpainting" : "EDIT_MODE_OUTPAINT" ,
960
+ "background-swap" : "EDIT_MODE_BGSWAP" ,
955
961
}
956
962
capability_mode = (
957
963
edit_mode_to_enum_map [edit_mode ]
@@ -961,7 +967,9 @@ class ID
961
967
parameters ["editMode" ] = capability_mode
962
968
shared_generation_parameters ["edit_mode" ] = capability_mode
963
969
else :
964
- edit_config ["editMode" ] = edit_mode
970
+ edit_config ["editMode" ] = (
971
+ edit_mode if edit_mode != "background-swap" else "inpainting-insert"
972
+ )
965
973
shared_generation_parameters ["edit_mode" ] = edit_mode
966
974
967
975
if mask is None and edit_mode is not None and edit_mode != "product-image" :
0 commit comments