LogicGoInfotechSpaces commited on
Commit
603d886
·
verified ·
1 Parent(s): e08df17

Update src/core.py

Browse files
Files changed (1) hide show
  1. src/core.py +10 -50
src/core.py CHANGED
@@ -22,56 +22,16 @@ log = logging.getLogger(__name__)
22
  DEFAULT_MODEL_ID = os.environ.get("GEMINI_IMAGE_MODEL", "gemini-3-pro-image-preview")
23
  DEFAULT_PROMPT = os.environ.get(
24
  "GEMINI_IMAGE_PROMPT",
25
- ("TASK: STRICT IMAGE INPAINTING MASK-BOUNDED OBJECT REMOVAL ONLY\n\n"
26
- "You are given:\n"
27
- "1) **Image A**: The original image, which contains various elements and objects.\n"
28
- "2) **Image B**: A binary mask that highlights the areas to be removed from the original image.\n\n"
29
-
30
- "MASK INTERPRETATION (CRITICAL):\n\n"
31
- "• **White pixels (#FFFFFF)** in Image B represent **the exact regions** in Image A that need to be removed. Only these regions can be modified or deleted.\n"
32
- "• **Black pixels (#000000)** in Image B must **remain completely unchanged** in Image A. Do **NOT** modify or generate anything in these black areas.\n"
33
- "• **Do NOT** modify or alter any other parts of Image A that are outside the white-masked region. Do not paint, blur, or alter any pixels that are not covered by the white mask.\n"
34
- " **Do NOT** attempt to remove or alter anything in the unmasked regions, even if the object in the unmasked area looks similar to the object inside the mask.\n"
35
- "• **The white-masked region is the **only** area to be modified. The rest of the image must **remain intact**. No other object or area should be painted or modified.\n"
36
- "\n"
37
-
38
- "STEP 1: OBJECT REMOVAL ANALYSIS\n\n"
39
- "• **Analyze the mask carefully** and **identify the exact areas** to be removed. Only focus on the white-masked region for removal.\n"
40
- "• The model must recognize what needs to be removed based on the white mask and **do nothing to the black (unmasked) regions**.\n"
41
- "• Do **NOT** modify, erase, or paint anything outside the white-masked region. Only remove what is explicitly covered by the white mask.\n\n"
42
-
43
- "STEP 2: OBJECT REMOVAL\n\n"
44
- "• **Completely remove** everything inside the white-masked region in Image A. This includes:\n"
45
- " - Erasing the object(s) entirely with **no visible remnants**, including shadows, outlines, or color traces.\n"
46
- " - If the mask overlaps only part of an object, **only remove the pixels covered by the white mask**, leaving the rest of the object untouched.\n"
47
- "• The goal is to **clear the masked region** entirely, **removing all visual content** from it.\n\n"
48
-
49
- "IMPORTANT NOTE ABOUT INPAINTING:\n\n"
50
- "• **The inpainted region must NOT be filled with pure white (#FFFFFF)**. The model should **never** generate a blank, white, or featureless region.\n"
51
- "• The white areas should be filled with **the natural surrounding background** of Image A. This means extending **existing textures, colors, lighting, and geometry naturally**, without introducing any artificial white filling.\n"
52
- "• **Do not paint or alter any other region** in the image, including the unmasked areas. **Only the white-masked area** should be modified, and no other content should be painted or changed.\n\n"
53
-
54
- "INPAINTING RULES:\n\n"
55
- "• After the object is removed, **fill the masked area** using **only the immediate surrounding pixels** from Image A.\n"
56
- "• **Do not invent new objects, structures, or details**. Only extend or copy background textures, lighting, and geometry from the unmasked areas.\n"
57
- "• The lighting, contrast, brightness, color temperature, and texture in the inpainted region must **perfectly match** the surrounding areas.\n"
58
- "• **Do not add** shadows, reflections, or new structures to the inpainted region.\n"
59
- "• The inpainted region should seamlessly blend with the surrounding pixels. It should appear as though the object was **never there**.\n\n"
60
-
61
- "STRICT CONSTRAINTS (NO EXCEPTIONS):\n\n"
62
- "• **Do NOT modify any black (unmasked) pixels**. The unmasked areas must remain **exactly** as they are in Image A.\n"
63
- "• **Do NOT remove entire objects** unless they are **fully and completely masked**. Only the regions inside the white mask should be modified.\n"
64
- "• **Do NOT alter the original image's **framing**, **perspective**, or **composition**. Only the regions inside the white mask should be affected.\n"
65
- "• **Do NOT apply any semantic cleanup** or scene optimization. This is a **strict removal task**; only the content inside the white mask should be removed.\n"
66
-
67
- "QUALITY REQUIREMENTS:\n\n"
68
- "• The final result should look as though the object **never existed** in the original image.\n"
69
- "• The inpainted region must blend **seamlessly** with surrounding pixels.\n"
70
- "• **No visible artifacts**, such as ghosting, halos, color shifts, or texture repetition, should be present.\n"
71
- "• The transition between the inpainted region and the unmasked areas must be **natural** and **imperceptible**.\n\n"
72
-
73
- "IMPORTANT:\n\n"
74
- "If there is a conflict between **semantic understanding** and the **mask**, **ALWAYS follow the mask exactly**. The mask is the **absolute guide**, and no interpretation should deviate from the mask’s instructions.\n"
75
  ),
76
  )
77
  _GENAI_MODEL: genai.GenerativeModel | None = None
 
22
  DEFAULT_MODEL_ID = os.environ.get("GEMINI_IMAGE_MODEL", "gemini-3-pro-image-preview")
23
  DEFAULT_PROMPT = os.environ.get(
24
  "GEMINI_IMAGE_PROMPT",
25
+ ("Remove ONLY the white areas shown in the mask. Keep everything else EXACTLY as it is.\n\n"
26
+ "CRITICAL RULES:\n"
27
+ "1. White pixels in mask = REMOVE (inpaint with background)\n"
28
+ "2. Black pixels in mask = KEEP UNCHANGED\n"
29
+ "3. Do NOT remove similar objects outside the mask\n"
30
+ "4. Do NOT recreate or add new objects\n"
31
+ "5. Only modify pixels where mask is white\n"
32
+ "6. Fill removed areas with surrounding background texture\n"
33
+ "7. Match lighting, colors, and texture perfectly\n\n"
34
+ "Follow the mask EXACTLY. Do not interpret semantically."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ),
36
  )
37
  _GENAI_MODEL: genai.GenerativeModel | None = None