File size: 7,528 Bytes
0561b0b db974fe 453dac8 be1cf9c 453dac8 be1cf9c 453dac8 db974fe 92f4ff2 db974fe b36b739 0a48ce1 b36b739 0a48ce1 b36b739 db974fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# Image Detection Bypass Utility
A polished PyQt5 GUI for the `image_postprocess` pipeline that adds live previews, an input/output analysis panel, an optional camera simulator, and easy parameter control β all wrapped in a clean, user-friendly interface.
---
## Features
- Select input, optional reference, and output paths with live previews.
- **Auto Mode**: one slider to control an expressive preset of postprocess parameters.
- **Manual Mode**: full access to noise, CLAHE, FFT, phase perturbation, pixel perturbation, etc.
- Camera pipeline simulator: Bayer/demosaic, JPEG cycles/quality, vignette, chromatic aberration, motion blur, hot pixels, read-noise, banding.
- Input / output analysis panels (via `AnalysisPanel`) to inspect images before/after processing.
- Background worker thread with progress reporting and rich error dialog (traceback viewer).
- Graceful handling of `image_postprocess` import errors (shows a critical dialog with the import error).
---
## Quick start
### ComfyUI Integration
Use ComfyUI Manager and install via GitHub link.
Or manually clone to custom_nodes folder.
```bash
git clone https://github.com/PurinNyova/Image-Detection-Bypass-Utility
```
then
```bash
cd Image-Detection-Bypass-Utility
pip install -r requirements.txt
```
Thanks to u/Race88 for the help on the ComfyUI code.
### Requirements
- Python 3.8+ recommended
- PyPI packages:
```bash
pip install pyqt5 pillow numpy matplotlib piexif
# optional but recommended for color matching / some functionality:
pip install opencv-python
```
OR
```bash
pip install -r requirements.txt
```
### Files expected in the same folder
- `image_postprocess.py` β your processing logic (export `process_image(...)` or compatible API).
- `worker.py` β Worker thread wrapper used to run the pipeline in background.
- `analysis_panel.py` β UI widget used for input/output analysis.
- `utils.py` β must provide `qpixmap_from_path(path, max_size=(w,h))`.
### Run
Save the GUI script (for example) as `image_postprocess_gui.py` (or use the existing name `image_postprocess_gui_with_analysis_updated.py`) and run:
```bash
python3 image_postprocess_gui.py
```
If `image_postprocess` cannot be imported, the GUI will show an error explaining the import failure (see **Troubleshooting** below).
---
## Using the GUI (at-a-glance)
1. **Choose Input** β opens file dialog; sets suggested output path automatically.
2. *(optional)* **Choose Reference** β used for FFT/color reference (OpenCV-based color match supported).
3. **Choose Output** β where processed image will be written.
4. **Auto Mode** β enable for a single slider to control a bundled preset.
5. **Manual Mode** β tune individual parameters in the Parameters group.
6. **Camera Simulator** β enable to reveal camera-specific controls (Bayer, JPEG cycles, vignette, chroma, etc.).
7. Click **Run β Process Image** to start. The GUI disables controls while running and shows progress.
8. When finished, the output preview and Output analysis panel update automatically.
---
## Parameters / Controls β `args` mapping
When you click **Run**, the GUI builds a lightweight argument namespace (similar to a `SimpleNamespace`) and passes it to the worker. Below are the important mappings used by the GUI (so you know what your `process_image` should expect):
- `args.noise_std` β Gaussian noise STD (fraction of 255)
- `args.clahe_clip` β CLAHE clip limit
- `args.tile` β CLAHE tile size
- `args.cutoff` β Fourier cutoff (0.01β1.0)
- `args.fstrength` β Fourier strength (0β1)
- `args.phase_perturb` β phase perturbation STD (radians)
- `args.randomness` β Fourier randomness factor
- `args.perturb` β small pixel perturbations
- `args.fft_mode` β one of `auto`, `ref`, `model`
- `args.fft_alpha` β alpha exponent for 1/f model (used when `fft_mode=='model'`)
- `args.radial_smooth` β radial smoothing bins for spectrum matching
- `args.jpeg_cycles` β number of lossy JPEG encode/decode cycles (camera sim)
- `args.jpeg_qmin`, `args.jpeg_qmax` β JPEG quality range used by camera sim
- `args.vignette_strength` β vignette intensity (0β1)
- `args.chroma_strength` β chromatic aberration strength (pixels)
- `args.iso_scale` β exposure multiplier (camera sim)
- `args.read_noise` β read noise in DN (camera sim)
- `args.hot_pixel_prob` β probability of hot pixels (camera sim)
- `args.banding_strength` β banding strength
- `args.motion_blur_kernel` β motion blur kernel size
- `args.seed` β integer seed or `None` when seed==0 in UI
- `args.sim_camera` β bool: run camera simulation path
- `args.no_no_bayer` β toggles Bayer/demosaic (True = enable RGGB demosaic)
- `args.fft_ref` β path to reference image (string) or `None`
> **Tip:** Your `process_image(inpath, outpath, args)` should be tolerant of missing keys (use `getattr(args, 'name', default)`), or accept the same `SimpleNamespace` object the GUI builds.
---
## Error handling / UI behavior
- The GUI uses a `Worker` thread to avoid blocking the UI. Worker emits signals: `started`, `finished(outpath)`, `error(msg, traceback_text)`.
- On error, a dialog displays the error message and a full traceback for debugging.
- If `image_postprocess` fails to import at startup, a critical dialog shows the exception details; fix the module or dependencies and restart.
---
## Development notes
- **Integrating your pipeline:** make sure `image_postprocess.py` exports a `process_image(inpath, outpath, args)` function (or adapt `worker.py` to match your pipeline signature).
- **Analysis panels:** `AnalysisPanel` should provide `update_from_path(path)`; used for both input and output.
- **Preview helper:** `utils.qpixmap_from_path` is used to load scaled QPixmap for previews β useful for keeping UI responsive.
- **Packaging:** If you want a single executable, consider `PyInstaller` (note: include `worker.py`, `analysis_panel.py`, `utils.py`, and the pipeline module).
---
## Troubleshooting
- **ImportError for `image_postprocess`** β ensure `image_postprocess.py` is in the same directory or on `PYTHONPATH`. Also confirm required packages (numpy, Pillow, opencv) are installed. The GUI shows the import error text at startup.
- **Previews blank/no image** β check that `qpixmap_from_path` returns a valid QPixmap. The preview widget falls back to `No image` if file missing.
- **Processing hangs** β confirm Worker is implemented to emit `finished` or `error`. If your `process_image` blocks indefinitely, the GUI will appear unresponsive (worker runs in background thread but won't return).
- **Color matching unavailable** β color matching uses OpenCV; if you did not install `opencv-python`, the GUI will still run, but reference-based color matching will be disabled.
---
## Example: minimal `process_image` signature
```python
# image_postprocess.py (sketch)
def process_image(inpath: str, outpath: str, args):
# args is a SimpleNamespace with attributes described above
# load image (PIL / numpy), run your pipeline, save output
pass
```
---
## Contributing
- PRs welcome. If you modify UI layout or parameter names, keep the `args` mapping consistent or update `README` and `worker.py` accordingly.
- Add unit tests for `worker.py` and the parameter serialization if you intend to refactor.
---
## License
MIT β free to use and adapt. Please include attribution if you fork or republish.
---
|