{
  "markdown": "# AI-Based Restoration of Degraded Images : Forsaken Apex\n\nRRDB-based single-image restoration network (5.997M parameters) that upscales and denoises degraded grayscale inputs by 2x.\n\n## Wiki\n\nDetailed documentation is available in the [Wiki](https://github.com/Codiosityy/ForsakenApex/wiki):\n\n| Section | Pages |\n|---------|-------|\n| **Architecture** | [Overview](https://github.com/Codiosityy/ForsakenApex/wiki/overview) · [RestorationNet](https://github.com/Codiosityy/ForsakenApex/wiki/restoration_net) · [DenseBlock](https://github.com/Codiosityy/ForsakenApex/wiki/dense_block) · [RRDB](https://github.com/Codiosityy/ForsakenApex/wiki/rrdb) · [PixelShuffle](https://github.com/Codiosityy/ForsakenApex/wiki/pixel_shuffle_upsample) |\n| **Training** | [Configuration](https://github.com/Codiosityy/ForsakenApex/wiki/configuration) · [Data Handling](https://github.com/Codiosityy/ForsakenApex/wiki/data_handling) |\n| **Inference** | [Guide](https://github.com/Codiosityy/ForsakenApex/wiki/loading_models) |\n| **Evaluation** | [Metrics](https://github.com/Codiosityy/ForsakenApex/wiki/metrics) · [Results](https://github.com/Codiosityy/ForsakenApex/wiki/results) |\n| **Reference** | [Model Files](https://github.com/Codiosityy/ForsakenApex/wiki/available_models) · [Dev Setup](https://github.com/Codiosityy/ForsakenApex/wiki/environment_setup) · [Quick Start](https://github.com/Codiosityy/ForsakenApex/wiki/quickstart) |\n\n## Results\n\n### Performance\n\n| Metric | Value |\n|--------|-------|\n| PSNR (dB) | 28.47 |\n| SSIM | 0.767 |\n| LPIPS | 0.164 |\n| Sharpness | 50.5% of GT |\n\nEvaluated on 320 full-resolution validation images.\n\n### Inference Throughput\n\n| Batch Size | ms/image | images/sec |\n|------------|----------|------------|\n| 1 | 9.80 | 102.0 |\n| 4 | 5.74 | 174.3 |\n\n### Benchmark Comparison\n\nRestorationNet vs. bicubic and standard AI baseline across PSNR, SSIM, and throughput:\n\n![Benchmark Detailed](Benchmark-2.png)\n\n### PSNR Comparison\n\nHigher PSNR indicates better image reconstruction quality:\n\n![PSNR Comparison](comparision.png)\n\n### Result Examples\n\n**Success Case** : clean texture recovery, minimal artifacts:\n\n![Success Case](success_case.png)\n\n**Failure Case** : some over-smoothing in high-frequency detail regions:\n\n![Failure Case](failure_case.png)\n\n## Architecture\n\n### Enhancement Process\n\n```mermaid\nflowchart LR\n    A[Noisy Input] --> B[Feature Extraction] --> C[8x RRDB] --> D[PixelShuffle 2x] --> E[Residual] --> F[Clean Output]\n```\n\n### Model Architecture\n\n```mermaid\nflowchart TD\n    A[Input] --> B[Head Conv2d]\n    B --> C[8x RRDB Blocks]\n    C --> D[Body Tail + Global Residual]\n    D --> E[PixelShuffle 2x]\n    D --> F[Noise Head]\n    E --> G[HR Conv + LeakyReLU]\n    G --> H[Output Conv]\n    H --> I[Add Bicubic Residual]\n    I --> J[Clamp 0-1]\n    J --> K[Output 2x Resolution]\n```\n\n| Parameter | Value |\n|-----------|-------|\n| Parameters | 5.997M |\n| Input | 1-ch grayscale, arbitrary size |\n| Output | 1-ch grayscale, 2x resolution |\n| RRDB blocks | 8 |\n| DenseBlock growth | gc=32, base nf=64 |\n| Upsample | PixelShuffle 2x |\n| Output | Global residual on bicubic interpolation |\n\n## Training\n\n### Technical Validation Workflow\n\nOur training pipeline uses a gated fine-tuning approach with accept/reject gates:\n\n![Technical Validation](technical_validation.png)\n\n### Base Training (100 epochs)\n\n- **Loss:** Composite : Charbonnier (w=1.0) + Gradient (w=0.1) + Physics Consistency (w=0.1) + SSIM (w=0.2) + LPIPS (w=0.05) + Blind Spot (w=0.05)\n- **Optimizer:** AdamW (lr=2e-4, betas=(0.9, 0.99), weight_decay=1e-4)\n- **Scheduler:** CosineAnnealingLR (T_max=100)\n- **Batch size:** 16 effective (4 x 4 gradient accumulation)\n- **Mixed precision:** AMP with GradScaler, gradient clipping (max_norm=5.0)\n- **Data:** 50% real pairs + 50% synthetic degradation (speckle noise, Gaussian readout)\n- **Seeds:** torch/random = 42\n\n### Refinement Pipeline\n\n| Stage | Epochs | Change | PSNR | Decision |\n|-------|--------|--------|------|----------|\n| Base | 100 | : | 28.58 dB | Baseline |\n| Exp 1 | 15 | clip=False in degradation | 28.60 dB | Accepted |\n| Exp 2 | 7 | w_grad=0.4, w_lpips=0.25 | ~26.7 dB | Rejected |\n| Exp 2b (final) | 9 | w_grad=0.2, w_lpips=0.12 | 28.47 dB | Accepted |\n\n**Final checkpoint:** `best_refined.pt` (epoch 9 of Exp 2b)\n\nExp 2b traded -0.13 dB PSNR for +2.87 points of sharpness (~22x the noise floor), with improved LPIPS (0.181 to 0.164).\n\n## Setup\n\n```bash\npip install -r requirements.txt\n```\n\nPlace the trained checkpoint at:\n\n```\nmodels/restoration_best.pt\n```\n\n## Usage\n\n```bash\npython run.py <input-dir> <output-dir>\n```\n\n- `<input-dir>` : directory containing `.npy` degraded images (grayscale, float `[0,1]` or uint8 `[0,255]`)\n- `<output-dir>` : directory where restored `.npy` files are written\n\nOutput images are saved as float32 `.npy` files with values in `[0, 1]`, shape `(H, W)` where `H = 2 * input_h` and `W = 2 * input_w`.\n\n## Environment\n\n- Python >= 3.10\n- CUDA-capable GPU (NVIDIA, tested with CUDA 12.x)\n- No internet access required at inference time\n",
  "bytes": 5037,
  "sha": "9e68c496c5d59178d379f23b9ab539a1a82b523284bd53b102b62b1e84fd6c51",
  "repo_slug": "codiosityy/forsakenapex",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/okf_codiosityy_forsakenapex_openwiki_index_m_f1be0ccb/readme"
}