Skip to content
ManNotNITPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart Adaptive Image Restoration CLI

This project restores low-quality images using Hugging Face image-to-image generation with automatic issue detection.

The workflow:

  1. Load an input image
  2. Analyze quality issues (blur, lighting, haze, lens-related artifacts)
  3. Recommend prompt and generation settings
  4. Run image generation with adaptive parameters
  5. Save output image and process logs

Directory Details

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.

Prerequisites

  • Windows PowerShell (or any shell)
  • Python 3.10+
  • A Hugging Face token with access to the selected model/provider

Installation Steps

  1. Open terminal in project folder.
  2. (Recommended) Create and activate virtual environment.
  3. Install dependencies.
  4. 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"

How to Run

Interactive mode (recommended):

python cli.py

Interactive mode with custom log directory:

python cli.py --log-dir my_logs

Non-interactive mode (auto-suggested settings):

python cli.py --image "C:\path\to\image.jpg" --non-interactive

Optional 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 and Logs

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

Troubleshooting

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.txt

Image 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

Relevant Notes

  • 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages