LogicGoInfotechSpaces commited on
Commit
41ae1c4
·
verified ·
1 Parent(s): e3ec294

Update src/core.py

Browse files
Files changed (1) hide show
  1. 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
- "You are provided with two images:\n\n"
28
- "The original image (Image A).\n\n"
29
- "The binary mask image (Image B).\n\n"
30
- "MASK RULE (MANDATORY):\n\n"
31
- "White pixels (#FFFFFF) in the mask image represent the areas to be removed from the original image.\n"
32
- "Black pixels (#000000) indicate regions that must remain unchanged and should not be modified.\n\n"
33
- "PRIMARY OBJECTIVE:\n\n"
34
- "Your task is to remove everything inside the white-masked area of the original image (Image A). "
35
- "The object in the white region must be completely erased with no visible remnants, no partial outlines, "
36
- "and no color traces remaining.\n\n"
37
- "The area should be inpainted by reconstructing the surrounding background content to seamlessly fill the removed region.\n\n"
38
- "INPAINTING INSTRUCTIONS:\n\n"
39
- "Use only the surrounding background of the original image to fill the white-masked area.\n"
40
- "Extend nearby textures, patterns, and structures naturally.\n"
41
- "Match the lighting, brightness, contrast, and color temperature of the surrounding areas.\n"
42
- "Ensure that edges, lines, and surfaces continue across the removed area naturally and smoothly.\n"
43
- "The boundary of the inpainted region should blend seamlessly with the original background, and the edit should be visually undetectable.\n\n"
44
- "STRICT CONSTRAINTS:\n\n"
45
- "Do NOT generate or retain any part of the removed object.\n"
46
- "Do NOT modify or enhance the unmasked areas (black regions).\n"
47
- "Do NOT alter the original composition or camera angle of the image.\n\n"
48
- "FAILURE CONDITIONS:\n\n"
49
- "If any outline, shadow, or color fragment from the removed object is still visible in the final result, "
50
- "the edit is incorrect and needs to be regenerated.\n\n"
51
- "QUALITY REQUIREMENTS:\n\n"
52
- "The result must look like the object never existed in the original image.\n"
53
- "No ghosting, halo effects, or smearing should be present.\n"
54
- "The final image should have natural and realistic inpainting, without patchy fills or repeated textures.\n\n"
55
- "Please ensure that all conditions are followed strictly for accurate and flawless object removal."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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