Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -46,16 +46,21 @@ def run_all_agents(img: Image.Image) -> Tuple[List[AgentEvidence], ForensicVerdi
|
|
| 46 |
ratio = max_dim / max(w, h)
|
| 47 |
img = img.resize((int(w * ratio), int(h * ratio)), Image.LANCZOS)
|
| 48 |
|
| 49 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
signal_agents = [
|
| 51 |
-
("optical", run_optical_agent),
|
| 52 |
-
("sensor", run_sensor_agent),
|
| 53 |
-
("model", run_model_agent),
|
| 54 |
-
("statistical", run_statistical_agent),
|
| 55 |
-
("metadata", run_metadata_agent),
|
| 56 |
]
|
| 57 |
|
| 58 |
-
# VLM agents (
|
| 59 |
vlm_agents = [
|
| 60 |
("semantic", run_semantic_agent),
|
| 61 |
("text", run_text_agent),
|
|
@@ -73,7 +78,6 @@ def run_all_agents(img: Image.Image) -> Tuple[List[AgentEvidence], ForensicVerdi
|
|
| 73 |
try:
|
| 74 |
results[name] = future.result()
|
| 75 |
except Exception as e:
|
| 76 |
-
# Create a failed agent evidence
|
| 77 |
results[name] = AgentEvidence(
|
| 78 |
agent_name=f"{name.title()} Agent (Error)",
|
| 79 |
violation_score=0.0,
|
|
@@ -97,6 +101,14 @@ def run_all_agents(img: Image.Image) -> Tuple[List[AgentEvidence], ForensicVerdi
|
|
| 97 |
# Bayesian synthesis
|
| 98 |
verdict = bayesian_synthesis(ordered)
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
# Generate explanations
|
| 101 |
verdict.forensic_report = generate_forensic_report(verdict)
|
| 102 |
reasoning = generate_reasoning_tree(verdict)
|
|
|
|
| 46 |
ratio = max_dim / max(w, h)
|
| 47 |
img = img.resize((int(w * ratio), int(h * ratio)), Image.LANCZOS)
|
| 48 |
|
| 49 |
+
# ββ Capture Modality Detection (runs BEFORE agents) βββββββββββββββ
|
| 50 |
+
from agents.modality_detector import detect_modality
|
| 51 |
+
modality = detect_modality(img)
|
| 52 |
+
adj = modality.score_adjustments
|
| 53 |
+
|
| 54 |
+
# Signal processing agents (fast, run in parallel with modality adjustments)
|
| 55 |
signal_agents = [
|
| 56 |
+
("optical", lambda i: run_optical_agent(i, adj)),
|
| 57 |
+
("sensor", lambda i: run_sensor_agent(i, adj)),
|
| 58 |
+
("model", lambda i: run_model_agent(i, adj)),
|
| 59 |
+
("statistical", lambda i: run_statistical_agent(i, adj)),
|
| 60 |
+
("metadata", lambda i: run_metadata_agent(i, adj)),
|
| 61 |
]
|
| 62 |
|
| 63 |
+
# VLM agents (no modality adjustment needed β VLM sees the image directly)
|
| 64 |
vlm_agents = [
|
| 65 |
("semantic", run_semantic_agent),
|
| 66 |
("text", run_text_agent),
|
|
|
|
| 78 |
try:
|
| 79 |
results[name] = future.result()
|
| 80 |
except Exception as e:
|
|
|
|
| 81 |
results[name] = AgentEvidence(
|
| 82 |
agent_name=f"{name.title()} Agent (Error)",
|
| 83 |
violation_score=0.0,
|
|
|
|
| 101 |
# Bayesian synthesis
|
| 102 |
verdict = bayesian_synthesis(ordered)
|
| 103 |
|
| 104 |
+
# Attach modality info to verdict for reporting
|
| 105 |
+
verdict.reasoning_tree["modality"] = {
|
| 106 |
+
"detected": modality.modality,
|
| 107 |
+
"confidence": modality.confidence,
|
| 108 |
+
"indicators": {k: v for k, v in modality.indicators.items() if not isinstance(v, np.ndarray)},
|
| 109 |
+
"adjustments_applied": len(modality.score_adjustments),
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
# Generate explanations
|
| 113 |
verdict.forensic_report = generate_forensic_report(verdict)
|
| 114 |
reasoning = generate_reasoning_tree(verdict)
|