Upload agents/semantic_agent.py with huggingface_hub
Browse files- agents/semantic_agent.py +16 -4
agents/semantic_agent.py
CHANGED
|
@@ -280,9 +280,18 @@ Your 8 analysis domains:
|
|
| 280 |
|
| 281 |
7. SIGN & LABEL COHERENCE: Visible signs, labels, and text should be appropriate for the scene type. A restaurant should show food-related signage. A hospital should show medical signage. Signs in a residential area should show house numbers, street names. Complete absence of expected signage in a commercial area is mildly suspicious.
|
| 282 |
|
| 283 |
-
8. OBJECT FUNCTION & ARRANGEMENT: Furniture should be arranged for use (chairs face tables). Appliances should be connected (lamps plugged in, or at least near outlets). Tools should be held or stored correctly. Kitchen items should be in kitchens. Check for: objects that serve no function, impossible arrangements, or items placed where they'd be impractical.
|
| 284 |
-
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
1. Temporal/Season β vegetation vs clothing vs weather
|
| 287 |
2. Time of Day β sky vs shadows vs lighting
|
| 288 |
3. Era/Technology β anachronistic objects
|
|
@@ -291,6 +300,7 @@ USR_CONTEXT = """Analyze contextual plausibility across all 8 domains:
|
|
| 291 |
6. Attire-Setting β clothing appropriate for location/activity
|
| 292 |
7. Sign/Label Coherence β signage matches scene type
|
| 293 |
8. Object Arrangement β functional, plausible placement
|
|
|
|
| 294 |
|
| 295 |
Respond in JSON:
|
| 296 |
{
|
|
@@ -302,6 +312,7 @@ Respond in JSON:
|
|
| 302 |
"attire_setting_match": true/false,
|
| 303 |
"signage_coherent": true/false,
|
| 304 |
"objects_functional": true/false,
|
|
|
|
| 305 |
"anomalies": ["specific contextual violations with reasoning"],
|
| 306 |
"confidence": 0.0-1.0,
|
| 307 |
"verdict": "AUTHENTIC" or "SUSPICIOUS" or "MANIPULATED",
|
|
@@ -432,7 +443,8 @@ def run_semantic_agent(img):
|
|
| 432 |
|
| 433 |
context_features = ["Season Consistency","Time-of-Day","Era/Technology",
|
| 434 |
"Geographic Coherence","Weather Coherence",
|
| 435 |
-
"Attire-Setting Match","Sign/Label Coherence",
|
|
|
|
| 436 |
for feat in context_features:
|
| 437 |
findings.append({"test": feat, "score": sc / len(context_features),
|
| 438 |
"note": parsed.get("explanation", "")[:100], "parent": "Context"})
|
|
|
|
| 280 |
|
| 281 |
7. SIGN & LABEL COHERENCE: Visible signs, labels, and text should be appropriate for the scene type. A restaurant should show food-related signage. A hospital should show medical signage. Signs in a residential area should show house numbers, street names. Complete absence of expected signage in a commercial area is mildly suspicious.
|
| 282 |
|
| 283 |
+
8. OBJECT FUNCTION & ARRANGEMENT: Furniture should be arranged for use (chairs face tables). Appliances should be connected (lamps plugged in, or at least near outlets). Tools should be held or stored correctly. Kitchen items should be in kitchens. Check for: objects that serve no function, impossible arrangements, or items placed where they'd be impractical.
|
| 284 |
+
|
| 285 |
+
9. AI STOCK PHOTO AESTHETICS β CRITICAL CHECK: AI-generated professional/office/lifestyle images have distinctive tells:
|
| 286 |
+
- UNNATURALLY CLEAN environments: offices with zero clutter, kitchens with no crumbs, desks with nothing out of place. Real offices have cable tangles, personal items, slight mess.
|
| 287 |
+
- IMPOSSIBLY PERFECT LIGHTING: perfectly even illumination with no harsh shadows, especially in indoor scenes where windows should create directional light and dark corners.
|
| 288 |
+
- REPEATED IDENTICAL ELEMENTS: multiple sticky notes that are exactly the same size/color/angle, identical books on a shelf, repeated patterns that a human would vary.
|
| 289 |
+
- WHITEBOARD/SCREEN CONTENT: Text on whiteboards that looks coherent from a distance but contains repeated phrases, nonsensical diagrams, or text that doesn't quite form real words. Look for duplicated headers, flowcharts that loop impossibly, and bullet points that repeat.
|
| 290 |
+
- STOCK PHOTO POSES: People in unnaturally perfect poses, smiling too evenly, gesturing in ways that look like stock photography templates rather than candid moments.
|
| 291 |
+
- SKIN PERFECTION: Completely poreless, airbrushed-looking skin with no visible texture, freckles, or imperfections. Real people have skin texture visible at any reasonable resolution.
|
| 292 |
+
Flag ANY of these patterns β they are strong AI-generation indicators.""" + CONFIDENCE_CALIBRATION
|
| 293 |
+
|
| 294 |
+
USR_CONTEXT = """Analyze contextual plausibility across all 9 domains:
|
| 295 |
1. Temporal/Season β vegetation vs clothing vs weather
|
| 296 |
2. Time of Day β sky vs shadows vs lighting
|
| 297 |
3. Era/Technology β anachronistic objects
|
|
|
|
| 300 |
6. Attire-Setting β clothing appropriate for location/activity
|
| 301 |
7. Sign/Label Coherence β signage matches scene type
|
| 302 |
8. Object Arrangement β functional, plausible placement
|
| 303 |
+
9. AI Stock Photo Aesthetics β unnaturally clean, perfect lighting, repeated elements, whiteboard gibberish, stock poses, poreless skin
|
| 304 |
|
| 305 |
Respond in JSON:
|
| 306 |
{
|
|
|
|
| 312 |
"attire_setting_match": true/false,
|
| 313 |
"signage_coherent": true/false,
|
| 314 |
"objects_functional": true/false,
|
| 315 |
+
"ai_stock_aesthetics": true/false,
|
| 316 |
"anomalies": ["specific contextual violations with reasoning"],
|
| 317 |
"confidence": 0.0-1.0,
|
| 318 |
"verdict": "AUTHENTIC" or "SUSPICIOUS" or "MANIPULATED",
|
|
|
|
| 443 |
|
| 444 |
context_features = ["Season Consistency","Time-of-Day","Era/Technology",
|
| 445 |
"Geographic Coherence","Weather Coherence",
|
| 446 |
+
"Attire-Setting Match","Sign/Label Coherence",
|
| 447 |
+
"Object Arrangement","AI Stock Photo Aesthetics"]
|
| 448 |
for feat in context_features:
|
| 449 |
findings.append({"test": feat, "score": sc / len(context_features),
|
| 450 |
"note": parsed.get("explanation", "")[:100], "parent": "Context"})
|