Spaces:
Running
Running
Anish-530
Fixed Mobile support. Added a new AI media detection mechanism by Farid, that creates geometric lines. Fixed logs
817ad83 | from typing import Dict, Any | |
| def generated_structured_explanation(features: Dict[str, float], prob: float) -> Dict[str, Any]: | |
| if prob > 0.80: | |
| confidence = "High" | |
| label = "AI" | |
| elif prob > 0.60: | |
| confidence = "Moderate" | |
| label = "Suspicious" | |
| elif prob > 0.50: | |
| confidence = "Low" | |
| label = "Suspicious" | |
| else: | |
| confidence = "High" if prob < 0.20 else "Moderate" | |
| label = "Real" | |
| contributions = {} | |
| region_analysis = [] | |
| freq = features.get("frequency_score", 0.0) | |
| cnn = features.get("cnn_score", 0.0) | |
| geometry_score = features.get("geometry_score") | |
| geometry_message = features.get("geometry_message") | |
| if freq > 1.5: | |
| contributions["frequency"] = freq | |
| region_analysis.append({ | |
| "region": "Global High-Frequency", | |
| "reason": f"Frequency variance score of {freq:.2f} strongly indicates synthetic noise patterns (Target > 1.5)." | |
| }) | |
| if cnn > 1.0: | |
| contributions["cnn"] = cnn | |
| region_analysis.append({ | |
| "region": "CNN Activation Areas", | |
| "reason": f"CNN artifact score of {cnn:.2f} indicates structural anomalies in bounding edges (Target > 1.0)." | |
| }) | |
| if geometry_score is not None and geometry_score < 50: | |
| contributions["geometry"] = geometry_score | |
| region_analysis.append({ | |
| "region": "Perspective & Structural Lines", | |
| "reason": f"Perspective consistency score of {geometry_score:.1f}/100. {geometry_message}" | |
| }) | |
| elif geometry_score is not None and geometry_score >= 75: | |
| region_analysis.append({ | |
| "region": "Perspective & Structural Lines", | |
| "reason": f"Perspective consistency score of {geometry_score:.1f}/100. {geometry_message}" | |
| }) | |
| if not region_analysis: | |
| region_analysis.append({ | |
| "region": "Image-Wide", | |
| "reason": "Measurements align with natural photographic noise distribution baselines." | |
| }) | |
| return { | |
| "label": label, | |
| "probability": float(prob), | |
| "confidence_level": confidence, | |
| "feature_contributions": contributions, | |
| "region_analysis": region_analysis | |
| } |