opencomic-ai-bin
v1.5.0
Published
Upscale and dehalftone images using AI models like Real-CUGAN, Real-ESRGAN, Waifu2x and Upscayl.
Maintainers
Readme
opencomic-ai-bin
This package provides pre-built binaries (realcugan, waifu2x, and upscayl) through a simple Node.js API.
Model files are not included, they are downloaded automatically when needed.
If you prefer to install all models upfront, use the opencomic-ai-models package.
Installation
npm install opencomic-ai-binMethods
This package can be used using CommonJS or ES Module.
// CommonJS
const OpenComicAI = require('opencomic-ai-bin');
// ES Module
import OpenComicAI from 'opencomic-ai-bin';Simple example of package usage
import OpenComicAI from 'opencomic-ai-bin';
import sharp from 'sharp'; // This is optional, only needed if you want to keep ICC profile or use a YOLO26 model
(async () => {
// Set the base directory for binary paths, for example change to app.asar.unpacked path in Electron apps
OpenComicAI.setDirname(OpenComicAI.__dirname.replace(/app(-(?:arm64|x64))?\.asar/, 'app$1.asar.unpacked'));
// Models path, if the model is not found in this folder, it will be downloaded
OpenComicAI.setModelsPath('./models');
// Set sharp instance
OpenComicAI.setSharp(sharp);
// Keep ICC profile from input image, requires sharp instance
OpenComicAI.keepIccProfile('rgb16');
await OpenComicAI.pipeline('./input.jpg', './output.jpg', [
{
model: 'opencomic-ai-descreen-hard-fast-v3',
},
{
model: 'opencomic-ai-upscale-fast-v3',
scale: 4,
}
], (progress) => {
console.log(`Processing: ${Math.round(progress * 100)}%`);
}, {
start: () => {
console.log(`Start download`);
},
progress: (progress) => {
console.log(`Downloading: ${Math.round(progress * 100)}%`);
},
end: () => {
console.log(`End download`);
},
});
})();OpenComicAI.setDirname
Set the base directory for binary paths.
OpenComicAI.setDirname(dirname: string): voidOpenComicAI.setModelsPath
Set the directory where models will be downloaded and stored.
OpenComicAI.setModelsPath(path: string): voidOpenComicAI.setCustomModel
Register a custom model so it can be used with image() or pipeline() like any other model.
OpenComicAI.setCustomModel(model: ModelObject): voidThe model argument follows the ModelObject interface. The key, name, upscaler, scales, and files properties are required when registering a custom model.
The model files must already exist locally. Their paths are resolved as follows:
<modelsPath>/<type>/<folder>/<file>For example, with type: 'custom' and folder: './models', place the model files in <modelsPath>/custom/models/.
The .bin and .param files must use the exact names listed in files.
const customModel = 'my-custom-model-1x';
// Use a path appropriate for your installation. The selected directory must
// resolve to the folder containing the platform binary directories.
OpenComicAI.setDirname('/path/to/opencomic-ai-bin/runtime');
OpenComicAI.setModelsPath('/path/to/models');
OpenComicAI.setCustomModel({
key: customModel,
name: 'My Custom Model',
type: 'custom',
upscaler: 'upscayl',
scales: [1],
noise: undefined,
latency: 1,
folder: './models',
files: [
`${customModel}.bin`,
`${customModel}.param`,
],
});
await OpenComicAI.image('./input.png', './output.png', {
model: customModel,
});setDirname() is only needed when the custom model uses a binary outside the package's default runtime location. The upscayl binary must be available for the current platform, and the model name passed to image() or pipeline() must match the key used during registration.
OpenComicAI.setConcurrentDaemons
Set the maximum number of concurrent daemons (upscayl models only), 0 disables daemons.
Daemons help speed up processing loading model only once and not for each image. See comparative performance.
OpenComicAI.setConcurrentDaemons(count: number = 3): voidOpenComicAI.setDaemonIdleTimeout
Set the idle timeout for daemons in milliseconds (upscayl models only).
OpenComicAI.setDaemonIdleTimeout(timeout: number = 60000): voidOpenComicAI.closeAllDaemons
Close all running daemons (upscayl models only).
OpenComicAI.closeAllDaemons(): voidOpenComicAI.setSharp
Set a sharp instance.
OpenComicAI.setSharp(sharp: any): voidOpenComicAI.keepIccProfile
Keep the ICC profile from the input image in the output image. This requires a sharp instance configured with setSharp().
The output is converted to the specified pipeline colourspace before the input ICC profile is applied.
OpenComicAI.keepIccProfile(pipelineColourspace: string = 'rgb16'): voidOpenComicAI.__dirname
Get the base directory for binary paths.
OpenComicAI.__dirname: stringOpenComicAI.models
Object containing all available models organized by type (upscale, descreen, descreen-mask, artifact-removal, panels, and custom).
OpenComicAI.models: Record<ModelType, Record<string, ModelObject>>OpenComicAI.modelsList
Array of all available model keys.
OpenComicAI.modelsList: Model[]OpenComicAI.modelsTypeList
Models organized by type.
OpenComicAI.modelsTypeList: Record<ModelType, Model[]>OpenComicAI.modelsPath
Current path where models are stored.
OpenComicAI.modelsPath: string | undefinedOpenComicAI.binary
Get the path to the binary executable for a model.
OpenComicAI.binary(model: Model): stringOpenComicAI.model
Get detailed information about a specific model.
OpenComicAI.model(model: Model): ModelObjectOpenComicAI.preload
Preload the model to daemon (upscayl models only) or download the model if not available locally.
OpenComicAI.preload(steps: OpenComicAIOptions[], downloading?: Downloading): Promise<void>OpenComicAI.image
Process an image using a single AI model. If no model is specified, the default model is used.
The destination directory is created automatically when it does not exist.
OpenComicAI.image(
source: string,
dest: string,
options?: OpenComicAIOptions,
progress?: ((progress: number) => void) | false
): Promise<string>OpenComicAI.pipeline
Process an image through one or more AI models.
OpenComicAI.pipeline(
source: string,
dest: string,
steps: OpenComicAIOptions[],
progress?: (progress: number) => void,
downloading?: Downloading
): Promise<string>OpenComicAI.closest
Returns the value in the array closest to the target value.
OpenComicAI.closest(array: number[], target: number): numberTypes
Model
type Model =
| 'opencomic-ai-upscale-fast-v3'
| 'opencomic-ai-upscale-balanced-v3'
...Model aliases
The following aliases identify models for specific processing stages:
type ModelUpscale = keyof typeof OpenComicAI.models.upscale;
type ModelArtifactRemoval = keyof typeof OpenComicAI.models['artifact-removal'];
type ModelMask = keyof typeof OpenComicAI.models['descreen-mask'];
type ModelPanels = keyof typeof OpenComicAI.models.panels;
type ModelCustom = string;ModelType
type ModelType =
| 'upscale'
| 'descreen'
| 'descreen-mask'
| 'artifact-removal'
| 'panels'
| 'custom';Upscaler
type Upscaler = 'realcugan' | 'upscayl' | 'waifu2x';Speed
type Speed = 'Very Fast' | 'Fast' | 'Medium' | 'Slow' | 'Very Slow';OpenComicAIOptions
interface OpenComicAIOptions {
model?: Model;
noise?: 0 | 1 | 2 | 3;
scale?: number;
tileSize?: number | 'auto';
maxTileSize?: number;
memorySafePercentage?: number;
gpuId?: string;
threads?: number;
tta?: boolean;
fp32?: boolean;
keepBigHalftone?: OpenComicAIKeepBigHalftone;
}OpenComicAIKeepBigHalftone
Options for preserving large halftone components while descreening an image.
interface OpenComicAIKeepBigHalftone {
model: ModelMask | 'auto';
minSize?: number;
minPixels?: number;
artifactRemoval?: OpenComicAIArtifactRemoval;
}minSize is the minimum component size as a percentage of the image height. minPixels filters out components smaller than the specified number of pixels. artifactRemoval can be used to process the selected regions with an artifact-removal model.
OpenComicAIArtifactRemoval
interface OpenComicAIArtifactRemoval {
model: ModelArtifactRemoval | 'auto';
}OpenComicAIPanels
Options for panel detection.
interface OpenComicAIPanels {
model: ModelPanels | 'auto';
minPixels?: number;
keepAspectRatio?: boolean;
upscale?: OpenComicAIUpscale;
}upscale can be used to upscale the panel mask before detecting its components.
ModelObject
interface ModelObject {
key?: Model;
name: string;
upscaler: Upscaler;
type?: ModelType;
tileSize?: number; // Force tile size for this model, overrides auto tile estimation
tileSizeFromMem128?: number; // Model memory usage in MB measured at tile=128 for auto tile estimation
scales: number[];
noise: number[] | undefined;
latency: number; // From 0.5 (Fastest model) to 10 (Slowest model)
speed?: Speed;
folder: string;
path?: string;
files: string[];
scaleFiles?: Record<number, Model>;
supportCurrentPlatform?: boolean;
}Downloading
interface Downloading {
start?: () => void;
progress?: (progress: number) => void;
end?: () => void;
}Models Info
Artifact removal
Model | Name | Upscaler | Source
------|------|----------|-------
opencomic-ai-artifact-removal-balanced-v3-ps | OpenComic AI Artifact Removal Balanced v3 | upscayl | ollm/opencomic-ai-training
opencomic-ai-artifact-removal-quality-v3-ps | OpenComic AI Artifact Removal Quality v3 | upscayl | ollm/opencomic-ai-training
opencomic-ai-artifact-removal-compact-v2 | OpenComic AI Artifact Removal Fast v2 | upscayl | ollm/opencomic-ai-training
opencomic-ai-artifact-removal-lite-v2 | OpenComic AI Artifact Removal Balanced v2 | upscayl | ollm/opencomic-ai-training
opencomic-ai-artifact-removal-v2 | OpenComic AI Artifact Removal Quality v2 | upscayl | ollm/opencomic-ai-training
opencomic-ai-artifact-removal-compact | OpenComic AI Artifact Removal Fast | upscayl | ollm/opencomic-ai-training
opencomic-ai-artifact-removal-lite | OpenComic AI Artifact Removal Balanced | upscayl | ollm/opencomic-ai-training
opencomic-ai-artifact-removal | OpenComic AI Artifact Removal Quality | upscayl | ollm/opencomic-ai-training
1x_NMKD-Jaywreck3-Lite_320k | NMKD Jaywreck3 Lite | upscayl | NMKD.de
1x_NMKD-Jaywreck3-Soft-Lite_320k | NMKD Jaywreck3 Soft Lite | upscayl | NMKD.de
1x-SaiyaJin-DeJpeg | SaiyaJin DeJpeg | upscayl | OpenModelDB
1x_JPEGDestroyerV2_96000G | JPEG Destroyer V2 | upscayl | Hugging Face
Descreen
Model | Name | Upscaler | Source
------|------|----------|-------
opencomic-ai-descreen-hard-fast-v3-256 | OpenComic AI Descreen Hard Fast v3 | upscayl | ollm/opencomic-ai-training
opencomic-ai-descreen-hard-balanced-v3-256 | OpenComic AI Descreen Hard Balanced v3 | upscayl | ollm/opencomic-ai-training
opencomic-ai-descreen-hard-compact-v2 | OpenComic AI Descreen Hard Fast v2 | upscayl | ollm/opencomic-ai-training
opencomic-ai-descreen-hard-lite-v2 | OpenComic AI Descreen Hard Balanced v2 | upscayl | ollm/opencomic-ai-training
opencomic-ai-descreen-hard-v2 | OpenComic AI Descreen Hard Quality v2 | upscayl | ollm/opencomic-ai-training
opencomic-ai-descreen-hard-compact | OpenComic AI Descreen Hard Fast | upscayl | ollm/opencomic-ai-training
opencomic-ai-descreen-hard-lite | OpenComic AI Descreen Hard Balanced | upscayl | ollm/opencomic-ai-training
opencomic-ai-descreen-hard | OpenComic AI Descreen Hard Quality | upscayl | ollm/opencomic-ai-training
1x_halftone_patch_060000_G | Halftone Patch 060000 G | upscayl | NMKD.de
1x_wtp_descreenton_compact | WTP DescreenTon Compact | upscayl | OpenModelDB
Upscale
Model | Name | Upscaler | Source
------|------|----------|-------
opencomic-ai-upscale-fast-v3 | OpenComic AI Upscale Fast v3 | upscayl | ollm/opencomic-ai-training
opencomic-ai-upscale-balanced-v3 | OpenComic AI Upscale Balanced v3 | upscayl | ollm/opencomic-ai-training
opencomic-ai-upscale-compact-v2 | OpenComic AI Upscale Fast v2 | upscayl | ollm/opencomic-ai-training
opencomic-ai-upscale-lite-v2 | OpenComic AI Upscale Balanced v2 | upscayl | ollm/opencomic-ai-training
opencomic-ai-upscale-v2 | OpenComic AI Upscale Quality v2 | upscayl | ollm/opencomic-ai-training
opencomic-ai-upscale-compact | OpenComic AI Upscale Fast | upscayl | ollm/opencomic-ai-training
opencomic-ai-upscale-lite | OpenComic AI Upscale Balanced | upscayl | ollm/opencomic-ai-training
opencomic-ai-upscale | OpenComic AI Upscale Quality | upscayl | ollm/opencomic-ai-training
realcugan | RealCUGAN | realcugan | Moebytes/waifu2x
realesr-animevideov3 | RealESR AnimeVideo v3 | upscayl | xinntao/Real-ESRGAN
realesrgan-x4plus | RealESRGAN x4 Plus | upscayl | xinntao/Real-ESRGAN
realesrgan-x4plus-anime | RealESRGAN x4 Plus Anime | upscayl | xinntao/Real-ESRGAN
realesrnet-x4plus | RealESRNet x4 Plus | upscayl | xinntao/Real-ESRGAN
waifu2x-models-cunet | Waifu2x CUnet | waifu2x | Moebytes/waifu2x
waifu2x-models-upconv | Waifu2x UpConv | waifu2x | Moebytes/waifu2x
4x-WTP-ColorDS | WTP ColorDS | upscayl | OpenModelDB
remacri-4x | Remacri | upscayl | upscayl/upscayl
ultramix-balanced-4x | Ultramix Balanced | upscayl | upscayl/upscayl
ultrasharp-4x | Ultrasharp | upscayl | upscayl/upscayl
4xInt-RemAnime | Int-RemAnime | upscayl | Phhofm/models
AI-Forever_x4plus | AI-Forever x4plus | upscayl | Hugging Face
4xNomosWebPhoto_esrgan | Nomos Web Photo ESRGAN | upscayl | OpenModelDB
4xHFA2k | HFA2k | upscayl | upscayl/custom-models
4xLSDIRCompactC3 | LSDIR Compact C3 | upscayl | upscayl/custom-models
4xLSDIRplusC | LSDIR Plus C | upscayl | upscayl/custom-models
4x_NMKD-Siax_200k | NMKD Siax | upscayl | upscayl/custom-models
4xNomos8kSC | Nomos 8k SC | upscayl | upscayl/custom-models
RealESRGAN_General_WDN_x4_v3 | RealESRGAN General WDN v3 | upscayl | upscayl/custom-models
RealESRGAN_General_x4_v3 | RealESRGAN General v3 | upscayl | upscayl/custom-models
uniscale_restore_x4 | Uniscale Restore x4 | upscayl | upscayl/custom-models
unknown-2.0.1 | Unknown 2.0.1 | upscayl | upscayl/custom-models
Daemon comparative performance
Table (10 images 512x512px)
Model | Disabled | Enabled | Disabled vs Enabled -------------------------------|-----------------------|----------------------|-------- OpenComic AI Upscale Lite | 52.087s | 7.646s | 6.81x RealESRGAN x4 Plus | 73.273s | 23.199s | 3.16x
OpenComic AI Upscale Lite
Disabled
Processing image 1/10 for model: OpenComic AI Upscale Lite: 2.931s
Processing image 2/10 for model: OpenComic AI Upscale Lite: 4.464s
Processing image 3/10 for model: OpenComic AI Upscale Lite: 5.594s
Processing image 4/10 for model: OpenComic AI Upscale Lite: 5.561s
Processing image 5/10 for model: OpenComic AI Upscale Lite: 5.521s
Processing image 6/10 for model: OpenComic AI Upscale Lite: 5.531s
Processing image 7/10 for model: OpenComic AI Upscale Lite: 5.534s
Processing image 8/10 for model: OpenComic AI Upscale Lite: 5.555s
Processing image 9/10 for model: OpenComic AI Upscale Lite: 5.496s
Processing image 10/10 for model: OpenComic AI Upscale Lite: 5.898s
Model: OpenComic AI Upscale Lite, Latency: 52.087sEnabled
Preloading model... OpenComic AI Upscale Lite
Preload model: OpenComic AI Upscale Lite: 473.897ms
Processing image 1/10 for model: OpenComic AI Upscale Lite: 725.474ms
Processing image 2/10 for model: OpenComic AI Upscale Lite: 716.566ms
Processing image 3/10 for model: OpenComic AI Upscale Lite: 716.221ms
Processing image 4/10 for model: OpenComic AI Upscale Lite: 715.214ms
Processing image 5/10 for model: OpenComic AI Upscale Lite: 717.894ms
Processing image 6/10 for model: OpenComic AI Upscale Lite: 715.236ms
Processing image 7/10 for model: OpenComic AI Upscale Lite: 716.296ms
Processing image 8/10 for model: OpenComic AI Upscale Lite: 714.025ms
Processing image 9/10 for model: OpenComic AI Upscale Lite: 718.653ms
Processing image 10/10 for model: OpenComic AI Upscale Lite: 714.792ms
Model: OpenComic AI Upscale Lite, Latency: 7.646sRealESRGAN x4 Plus
Disabled
Processing image 1/10 for model: RealESRGAN x4 Plus: 6.473s
Processing image 2/10 for model: RealESRGAN x4 Plus: 7.809s
Processing image 3/10 for model: RealESRGAN x4 Plus: 7.690s
Processing image 4/10 for model: RealESRGAN x4 Plus: 7.470s
Processing image 5/10 for model: RealESRGAN x4 Plus: 6.620s
Processing image 6/10 for model: RealESRGAN x4 Plus: 7.390s
Processing image 7/10 for model: RealESRGAN x4 Plus: 7.423s
Processing image 8/10 for model: RealESRGAN x4 Plus: 7.541s
Processing image 9/10 for model: RealESRGAN x4 Plus: 7.536s
Processing image 10/10 for model: RealESRGAN x4 Plus: 7.321s
Model: RealESRGAN x4 Plus, Latency: 73.273sEnabled
Preloading model... RealESRGAN x4 Plus
Preload model: RealESRGAN x4 Plus: 1.165s
Processing image 1/10 for model: RealESRGAN x4 Plus: 2.217s
Processing image 2/10 for model: RealESRGAN x4 Plus: 2.196s
Processing image 3/10 for model: RealESRGAN x4 Plus: 2.203s
Processing image 4/10 for model: RealESRGAN x4 Plus: 2.191s
Processing image 5/10 for model: RealESRGAN x4 Plus: 2.200s
Processing image 6/10 for model: RealESRGAN x4 Plus: 2.203s
Processing image 7/10 for model: RealESRGAN x4 Plus: 2.216s
Processing image 8/10 for model: RealESRGAN x4 Plus: 2.222s
Processing image 9/10 for model: RealESRGAN x4 Plus: 2.188s
Processing image 10/10 for model: RealESRGAN x4 Plus: 2.194s
Model: RealESRGAN x4 Plus, Latency: 23.199sCredits
This project uses the following AI models and upscalers:
Related Projects
Citation (opencomic-ai-training)
If you use this project, please cite it as follows.
@software{opencomic_ai,
author = {Llopart Mora, Oleguer},
title = {{OpenComic AI}},
year = {2026},
version = {2.0},
doi = {10.5281/zenodo.20802370},
url = {https://doi.org/10.5281/zenodo.20802370}
}Release models citation. To see the differences between versions, you can check the CHANGELOG.md file.
OpenComic AI v3.0
@software{opencomic_ai_models_v3_0,
author = {Llopart Mora, Oleguer},
title = {{OpenComic AI v3.0 Models}},
year = {2026},
version = {3.0},
doi = {10.5281/zenodo.23245460},
url = {https://doi.org/10.5281/zenodo.23245460}
}OpenComic AI v2.0
@software{opencomic_ai_models_v2_0,
author = {Llopart Mora, Oleguer},
title = {{OpenComic AI v2.0 Models}},
year = {2026},
version = {2.0},
doi = {10.5281/zenodo.22967095},
url = {https://doi.org/10.5281/zenodo.22967095}
}OpenComic AI v1.0
@software{opencomic_ai_models_v1_0,
author = {Llopart Mora, Oleguer},
title = {{OpenComic AI v1.0 Models}},
year = {2026},
version = {1.0.1},
doi = {10.5281/zenodo.20802371},
url = {https://doi.org/10.5281/zenodo.20802371}
}License
| Component | License | |---|---| | Source code | MIT | | OpenComic AI model weights | CC BY 4.0 |
The source code of this repository is licensed under the MIT License.
OpenComic AI model weights are licensed under the CC BY 4.0.
See LICENSE and LICENSE_MODELS for details.
