Download code/src/enhancements/diffusion_aug.py from savastakan/hitit-cuneiform-ocr: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/savastakan/hitit-cuneiform-ocr/resolve/main/code/src/enhancements/diffusion_aug.py
- Command line
-
hf download hf://savastakan/hitit-cuneiform-ocr/code/src/enhancements/diffusion_aug.py
-
curl -L -o diffusion_aug.py https://huggingface.co/savastakan/hitit-cuneiform-ocr/resolve/main/code/src/enhancements/diffusion_aug.py
1.6 kB
| #!/usr/bin/env python3 | |
| """#6 Diffusion-based augmentation for rare signs. | |
| Reference: DA-Fusion (Trabucco 2023); DiffuseMix (Islam 2024 CVPR); | |
| Flux.1-dev (BFL 2024). | |
| Strategy for rare classes (<10 sample): | |
| 1. Gerçek örneklerden ControlNet LoRA fine-tune | |
| 2. "relief + clay texture" synthesis | |
| 3. Expert review (quality control zorunlu) | |
| """ | |
| import json | |
| from pathlib import Path | |
| ROOT = Path("/arf/scratch/stakan/hitit-proje") | |
| RECIPE = { | |
| "name": "Diffusion augmentation — rare cuneiform sign synthesis", | |
| "method": "ControlNet LoRA on Flux.1-dev or SD3", | |
| "target": "Rare signs (class_sample_count < 10 in hitit_local)", | |
| "strategy": [ | |
| "1. Gerçek örneklerden sign-specific ControlNet LoRA eğit (3-5 sample yeter)", | |
| "2. Conditioning: edge map + depth (MaiCuBeDa 3D render'dan)", | |
| "3. Generate: relief + clay texture + lighting variation", | |
| "4. Expert paleographer review (accept/reject loop)", | |
| "5. Manifest'e synthetic=True flag" | |
| ], | |
| "expected_gain": "+0.2-0.5% (tail tier improvement)", | |
| "caveats": [ | |
| "Diffusion kolay hallucinate eder → yanlış stroke riski", | |
| "Sadece in-distribution noise/lighting, yeni sign sentezi DEĞİL", | |
| "Expert review zorunlu" | |
| ], | |
| "gpu_hours": 100, | |
| "status": "recipe-only (implementation in diffusion_synthetic_runbook.md)" | |
| } | |
| def main(): | |
| out = ROOT / "datasets/processed/diffusion_aug_recipe.json" | |
| with open(out, 'w') as f: | |
| json.dump(RECIPE, f, indent=2, ensure_ascii=False) | |
| print(f"Diffusion aug recipe: {out}") | |
| if __name__ == '__main__': | |
| main() | |