Skip to main content

Overview

Pipeline processing allows you to chain multiple AI models together, applying different transformations in sequence. This is particularly useful for comic book images that need dehalftoning, artifact removal, and upscaling.

Multi-step processing

The pipeline method accepts an array of processing steps, where each step can use a different model with different options:
Each step processes the output of the previous step, creating a processing pipeline.

Chaining operations

Different model types can be combined to achieve specific results:

Dehalftoning then upscaling

The most common workflow for scanned comic books:

Artifact removal, dehalftoning, and upscaling

For heavily compressed or damaged images:

Multiple upscaling passes

Some models work better at specific scales. You can chain them for very high upscaling factors:

Intermediate file handling

The pipeline automatically manages intermediate files during processing:
  1. Each step (except the last) creates a temporary file with a random UUID filename
  2. The temporary file is used as input for the next step
  3. After a step completes, the previous temporary file is automatically deleted
  4. Only the final output file is preserved
Temporary files are created in the same directory as the destination file and use the same file extension.

Progress tracking in pipelines

When using multiple steps, the progress callback reports overall progress across all steps:
The library calculates overall progress using this formula:

Real-world example from README

Here’s the complete example from the README, demonstrating a typical workflow:

Best practices

Order matters

Apply models in this recommended order:
  1. Artifact removal - Clean up compression artifacts first
  2. Dehalftoning - Remove halftone patterns before upscaling
  3. Upscaling - Finally increase resolution
This order prevents amplifying artifacts and halftone patterns during upscaling.

Choose appropriate models for each step

  • Use fast, lightweight models (“compact” or “lite” variants) for early steps
  • Reserve slower, higher-quality models for the final upscaling step
  • See model selection guide for details

Consider memory usage

Each step increases image dimensions:
Adjust tileSize in later steps if you encounter memory issues:

Performance optimization

For processing multiple images with the same pipeline, use daemon mode to significantly improve performance by preloading models.

Next steps