Update src/core.py
Browse files- src/core.py +51 -29
src/core.py
CHANGED
|
@@ -24,35 +24,57 @@ DEFAULT_PROMPT = os.environ.get(
|
|
| 24 |
"GEMINI_IMAGE_PROMPT",
|
| 25 |
(
|
| 26 |
"TASK TYPE: STRICT IMAGE INPAINTING — OBJECT REMOVAL ONLY\n\n"
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
),
|
| 57 |
)
|
| 58 |
_GENAI_MODEL: genai.GenerativeModel | None = None
|
|
|
|
| 24 |
"GEMINI_IMAGE_PROMPT",
|
| 25 |
(
|
| 26 |
"TASK TYPE: STRICT IMAGE INPAINTING — OBJECT REMOVAL ONLY\n\n"
|
| 27 |
+
"You are provided with two images:\n\n"
|
| 28 |
+
"1) The original image (Image A) which contains the scene with various objects.\n"
|
| 29 |
+
"2) The binary mask image (Image B) that highlights the region(s) to be removed in the original image.\n\n"
|
| 30 |
+
|
| 31 |
+
"MASK RULE (MANDATORY):\n\n"
|
| 32 |
+
"• In the mask image (Image B), white pixels (#FFFFFF) represent the exact regions in the original image (Image A) "
|
| 33 |
+
"that need to be completely removed.\n"
|
| 34 |
+
"• Black pixels (#000000) in the mask image indicate areas of the original image that must remain completely unchanged "
|
| 35 |
+
"and should not be altered in any way.\n"
|
| 36 |
+
|
| 37 |
+
"PRIMARY OBJECTIVE:\n\n"
|
| 38 |
+
"The goal is to **remove** all the objects or parts of objects that are highlighted in the white-masked regions of the mask image. "
|
| 39 |
+
"The object in the white region must be **entirely erased** with no visible remnants, shadows, outlines, or color traces remaining. "
|
| 40 |
+
"Once the objects are removed, the region should be seamlessly filled by **inpainting** using only the surrounding background information from the original image. "
|
| 41 |
+
"The inpainted area must blend smoothly with the unmasked regions so that no traces of the removal are visible.\n\n"
|
| 42 |
+
|
| 43 |
+
"INPAINTING INSTRUCTIONS:\n\n"
|
| 44 |
+
"1) **Object Recognition and Removal:**\n"
|
| 45 |
+
" The model should first **understand** that the white areas in the binary mask represent the specific regions where objects or elements need to be **completely removed**. "
|
| 46 |
+
" This could be anything from objects, people, text, or any unwanted areas in the image. It should not leave any part of the removed object behind — not even partial shapes, shadows, outlines, or color traces.\n"
|
| 47 |
+
" The object removal should ensure that no part of the deleted object is visible in the final image.\n\n"
|
| 48 |
+
|
| 49 |
+
"2) **Inpainting the Removed Region:**\n"
|
| 50 |
+
" After removing the designated regions, the surrounding **background textures, patterns, and structures** should be used to **fill in** the removed area. "
|
| 51 |
+
" This should be done by **extending the background information** naturally, continuing the textures, structures, and lighting patterns that were present in the surrounding unmasked regions.\n"
|
| 52 |
+
" The model should focus on ensuring that the inpainted region **matches** the existing background in terms of:\n"
|
| 53 |
+
" • **Lighting Direction** – Ensure the lighting in the inpainted region matches the natural direction and intensity of the surrounding areas.\n"
|
| 54 |
+
" • **Brightness and Contrast** – The brightness and contrast should be consistent across the image, without any abrupt changes where the object was removed.\n"
|
| 55 |
+
" • **Color Temperature** – Ensure the inpainted area aligns with the color temperature of the surrounding image (i.e., warm, cool, neutral tones).\n"
|
| 56 |
+
" • **Noise and Texture** – Maintain the same noise level and texture (grain) in the inpainted region as in the surrounding areas, avoiding unnatural smoothness or patchiness.\n\n"
|
| 57 |
+
|
| 58 |
+
"3) **Seamless Blending:**\n"
|
| 59 |
+
" The inpainting should blend **seamlessly** with the surrounding areas, creating a smooth transition between the removed object and the rest of the image. "
|
| 60 |
+
" This includes extending edges, lines, and surfaces naturally across the removed area. The goal is that **the boundary of the inpainted region should be indistinguishable from the original background**, "
|
| 61 |
+
" without any visible edge halos, smearing, or rough transitions.\n\n"
|
| 62 |
+
|
| 63 |
+
"STRICT CONSTRAINTS:\n\n"
|
| 64 |
+
"• Do **NOT** generate or keep any part of the removed object. There should be no visible remnants, outlines, or partial shapes from the deleted object.\n"
|
| 65 |
+
"• Do **NOT** modify or enhance the unmasked areas (black regions). The unmasked regions should remain completely unchanged, with no alteration to the content, color, or lighting.\n"
|
| 66 |
+
"• Do **NOT** alter the **original composition**, **camera angle**, or **perspective** of the image. The overall structure of the image should remain intact.\n\n"
|
| 67 |
+
|
| 68 |
+
"FAILURE CONDITIONS (MUST BE AVOIDED):\n\n"
|
| 69 |
+
"• If any **outline, shadow, or color fragment** from the removed object is still visible in the final result, the inpainting is considered incorrect and must be re-generated.\n"
|
| 70 |
+
"• If the inpainted region **does not blend** properly with the surrounding areas (i.e., visible transitions, edge halos, ghosting effects), the result is incorrect and must be re-generated.\n\n"
|
| 71 |
+
|
| 72 |
+
"QUALITY REQUIREMENTS:\n\n"
|
| 73 |
+
"• The result must look like the object **never existed** in the original image.\n"
|
| 74 |
+
"• There should be no **ghosting**, **halo effects**, or **smearing** in the inpainted area.\n"
|
| 75 |
+
"• The final image must have **natural and realistic inpainting**. The inpainted area should seamlessly match the rest of the image, without any **patchy fills** or **repeated textures**.\n"
|
| 76 |
+
"• The **background** in the inpainted region should match the **lighting, texture, color**, and **depth** of the surrounding area.\n\n"
|
| 77 |
+
"Please ensure that all conditions are followed strictly for accurate and flawless object removal. The output should be a polished, high-quality image where the removed area is seamlessly inpainted without leaving any detectable signs of modification."
|
| 78 |
),
|
| 79 |
)
|
| 80 |
_GENAI_MODEL: genai.GenerativeModel | None = None
|