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
Thepipeline method accepts an array of processing steps, where each step can use a different model with different options:
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:- Each step (except the last) creates a temporary file with a random UUID filename
- The temporary file is used as input for the next step
- After a step completes, the previous temporary file is automatically deleted
- 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: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:- Artifact removal - Clean up compression artifacts first
- Dehalftoning - Remove halftone patterns before upscaling
- Upscaling - Finally increase resolution
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: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
- Learn about model selection to choose the right models for your pipeline
- Explore daemon mode for faster batch processing
- Understand ICC profile preservation for color accuracy