This project restores low-quality images using Hugging Face image-to-image generation with automatic issue detection.
The workflow:
- Load an input image
- Analyze quality issues (blur, lighting, haze, lens-related artifacts)
- Recommend prompt and generation settings
- Run image generation with adaptive parameters
- Save output image and process logs
Current project structure:
- cli.py: Main command-line entry point
- image_analyzer.py: Image quality analysis and adaptive recommendations
- image_to_image.py: Hugging Face generation logic
- process_logger.py: Per-run process logging setup
- requirements.txt: Python dependencies
- output/: Generated images are saved here by default
- my_logs/: Custom log folder used when running with --log-dir my_logs
- .venv/: Local virtual environment
Note:
- If you do not pass --log-dir, logs are saved in logs/ by default.
- Windows PowerShell (or any shell)
- Python 3.10+
- A Hugging Face token with access to the selected model/provider
- Open terminal in project folder.
- (Recommended) Create and activate virtual environment.
- Install dependencies.
- Set Hugging Face token in environment variable.
PowerShell commands:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
$env:HF_TOKEN="your_hf_token_here"If a virtual environment already exists, activate it and run only:
pip install -r requirements.txt
$env:HF_TOKEN="your_hf_token_here"Interactive mode (recommended):
python cli.pyInteractive mode with custom log directory:
python cli.py --log-dir my_logsNon-interactive mode (auto-suggested settings):
python cli.py --image "C:\path\to\image.jpg" --non-interactiveOptional arguments:
- --image: Input image path
- --prompt: Custom restoration prompt (overrides suggested prompt)
- --model: Model id (default is set in image_to_image.py)
- --output-dir: Output image directory (default: output)
- --log-dir: Log directory (default: logs)
- --non-interactive: Skip prompts and use analyzer suggestions
Output images:
- Saved to output/ by default
- Filename pattern: updatedimg_<input_name>_YYYYMMDD_HHMMSS.png
Log files:
- Saved to logs/ by default, or to custom folder from --log-dir
- Filename pattern: process_YYYYMMDD_HHMMSS.log
- Logs include run start, selected image, analysis summary, generation settings, output path, and errors
HF_TOKEN not set:
- Error indicates missing token
- Set it in current terminal:
$env:HF_TOKEN="your_hf_token_here"Module not found errors:
- Activate your virtual environment and reinstall dependencies:
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtImage file not found:
- Check full path and quotes around paths containing spaces
Model id validation errors:
- The code normalizes model ids to remove unsupported suffixes (for example provider routing suffixes)
- If access still fails, use a model available to your token/provider
- Denoising values above about 0.6 can alter identity/details significantly.
- For identity preservation (especially people/faces), keep denoising lower when possible.
- You can start with analyzer defaults, then fine-tune via interactive customization.