Spaces:
Paused
Paused
Download api/schemas.py from MohsinElis/patch-mfft-api: direct link, hf CLI and curl.
- Browser
- Download file 3.01 kB
-
https://huggingface.co/spaces/MohsinElis/patch-mfft-api/resolve/main/api/schemas.py
- Command line
-
hf download hf://spaces/MohsinElis/patch-mfft-api/api/schemas.py
-
curl -L -o schemas.py https://huggingface.co/spaces/MohsinElis/patch-mfft-api/resolve/main/api/schemas.py
3.01 kB
| """ | |
| Pydantic Schemas for Patch-MFFT Tampering Forensics API. | |
| """ | |
| from typing import Dict, List, Optional | |
| from pydantic import BaseModel, Field | |
| class ModelInfo(BaseModel): | |
| id: str | |
| loaded: bool | |
| params: str | |
| description: str | |
| class HealthResponse(BaseModel): | |
| status: str | |
| version: str = "1.0.0" | |
| models_loaded: List[str] | |
| timestamp: str | |
| class PredictionResponse(BaseModel): | |
| prediction: str = Field(..., description="'authentic', 'full_ai', or 'spliced_tampered'") | |
| confidence: float | |
| tampering_detected: bool | |
| class_probabilities: Dict[str, float] | |
| tampering_heatmap_b64: Optional[str] = Field(None, description="Base64 PNG pixel-level tampering localization mask") | |
| tampering_overlay_b64: Optional[str] = Field(None, description="Base64 RGBA PNG with transparent authentic background for seamless overlay") | |
| tampering_peak_score: float = Field(default=0.0, description="Peak tampering probability within the localization mask") | |
| tampering_coverage_ratio: float = Field(default=0.0, description="Percentage of frame area exceeding tampering threshold (p > 0.50)") | |
| frequency_band_contributions: Dict[str, float] | |
| processing_time_ms: float | |
| model_variant: str | |
| is_non_photographic_graphic: bool = Field( | |
| default=False, | |
| description="True if pre-flight domain heuristics detect a digital diagram, flowchart, vector graphic, or screenshot", | |
| ) | |
| domain_status: str = Field( | |
| default="photographic", | |
| description="'photographic', 'non_photographic_graphic', or 'solid_canvas_ood'", | |
| ) | |
| is_social_media_compressed: bool = Field( | |
| default=False, | |
| description="True if lossy social media compression (WhatsApp, Telegram, etc.) or 8x8 blockiness is detected", | |
| ) | |
| compression_blockiness: float = Field( | |
| default=1.0, | |
| description="Estimated 8x8 DCT boundary discontinuity metric", | |
| ) | |
| consensus_status: Optional[str] = Field( | |
| default="single_model", | |
| description="'verified_consensus', 'disputed', or 'single_model'", | |
| ) | |
| consensus_message: Optional[str] = Field( | |
| default=None, | |
| description="Explanation of multi-model consensus or discrepancy", | |
| ) | |
| exif_summary: Optional[Dict[str, str]] = Field( | |
| default=None, | |
| description="Extracted camera EXIF parameters or null if stripped", | |
| ) | |
| generative_software_tag: Optional[str] = Field( | |
| default=None, | |
| description="Detected AI synthesis software string in metadata", | |
| ) | |
| sha256_hash: Optional[str] = Field( | |
| default=None, | |
| description="Cryptographic SHA-256 hash of image payload", | |
| ) | |
| cached: bool = Field( | |
| default=False, | |
| description="True if served from high-speed in-memory LRU cache", | |
| ) | |
| warning: Optional[str] = Field( | |
| default=None, | |
| description="Forensic domain warnings or OOD guidance", | |
| ) | |
| class ModelsResponse(BaseModel): | |
| default: str | |
| models: List[ModelInfo] | |