Metadata-Version: 2.5
Name: issynthetic
Version: 0.1.0
Summary: Open-source library to detect AI-generated images and videos via metadata inspection
Project-URL: Homepage, https://github.com/SynthDetect/SynthDetect
Project-URL: Repository, https://github.com/SynthDetect/SynthDetect
Project-URL: Documentation, https://github.com/SynthDetect/SynthDetect#readme
Author: SynthDetect Contributors
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: ai-detection,c2pa,exif,metadata,synthetic-media
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Security
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: filetype>=1.2.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pillow>=10.0.0
Provides-Extra: c2pa
Requires-Dist: c2pa-python>=0.5.0; extra == 'c2pa'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0; extra == 'yaml'
Description-Content-Type: text/markdown

# SynthDetect / issynthetic

Open-source Python library to detect whether images and videos were generated by AI, starting with metadata inspection (C2PA, EXIF/XMP, PNG chunks).

## Installation

```bash
# With uv (recommended for development)
uv sync

# With pip
pip install issynthetic

# Optional: C2PA support
pip install issynthetic[c2pa]
```

## Quick start

### Python API

```python
import issynthetic as is_ai

result = is_ai.inspect("image.png")
print(result.is_generated)    # True, False, or None (uncertain)
print(result.confidence)      # 0.0 – 1.0
print(result.generator_name)  # e.g. "Automatic1111", "DALL-E 3"
print(result.details)         # raw metadata dict
```

### CLI

```bash
issynthetic inspect image.png
issynthetic inspect image.png --json
issynthetic export-unknown --format json
issynthetic sync-rules
issynthetic config --show
```

## Hybrid metadata learning

The library uses a four-layer system to expand detection rules over time:

| Layer | Default | Description |
|-------|---------|-------------|
| Local observations | On | Records unknown tag names in `~/.local/share/issynthetic/` |
| Rules pull | On | Downloads updated `rules.json` every 7 days |
| Telemetry | **Off** | Opt-in anonymized contribution (`issynthetic config --enable-telemetry`) |
| Manual export | Always | `issynthetic export-unknown` for PR contributions |

See [PRIVACY.md](PRIVACY.md) for details on what data is stored and sent.

## Architecture

- **Inspector** orchestrates extractors in priority order: C2PA → PNG → EXIF → Video
- **RulesStore** merges bundled, remote, and user rules; evaluates matchers
- **Extractors** implement a plugin interface (`BaseExtractor`) for extensibility

## Development

```bash
uv sync
uv run pytest
uv run ruff check .
uv run mypy src
uv build
```

### Test corpus

Synthetic cases run in CI via `tests/corpus/manifest.json`. Optional real images go in `tests/fixtures/corpus/` (see README there).

```bash
uv run pytest tests/test_corpus.py -v
uv run pytest tests/test_metadata_contract.py -v
```

## Release

Semi-manual flow with automatic GitHub Release on tag push:

```bash
# 1. Bump version in pyproject.toml (PR → merge)
# 2. Tag and push:
git tag v0.1.1
git push origin v0.1.1
```

GitHub Actions will:

1. Verify tag matches `pyproject.toml` (`scripts/check_version_tag.py`)
2. Run lint, typecheck, and full test suite (including metadata contract + corpus)
3. Build wheel/sdist and attach `rules.json` to the GitHub Release

Verify locally before tagging:

```bash
uv run python scripts/check_version_tag.py --tag v0.1.1
```

PyPI publishing is prepared but disabled in [`.github/workflows/release.yml`](.github/workflows/release.yml) until `PYPI_TOKEN` is configured.

## Zero-cost architecture

| Component | Default | Network |
|-----------|---------|---------|
| Local observations | On | No |
| Rules sync | On | Pull only (GitHub Releases) |
| Telemetry | **Off** | Opt-in only |
| Export manual | Always | No |

Rules are fetched from `releases/latest/download/rules.json` — no custom server required.

## Roadmap

- **Phase 1 (current):** Metadata inspection (C2PA, EXIF/XMP, PNG text chunks, video stubs)
- **Phase 2:** Visual forensics (frequency analysis, artifact detection, ML classifiers)

## License

Apache License 2.0 — see [LICENSE](LICENSE).
