opencomic-ai-bin
v1.0.6
Published
Upscale and dehalftone images using AI models like Real-CUGAN, Real-ESRGAN, Waifu2x and Upscayl.
Downloads
841
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';
(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');
await OpenComicAI.pipeline('./input.jpg', './output.jpg', [
{
model: '1x_halftone_patch_060000_G',
},
{
model: 'realcugan',
scale: 4,
noise: 0,
}
], (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.__dirname
Get the base directory for binary paths.
OpenComicAI.__dirname: stringOpenComicAI.models
Object containing all available models organized by type (upscale, descreen, artifact-removal).
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.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 =
| 'realcugan'
| 'realesr-animevideov3'
| 'realesrgan-x4plus'
...ModelType
type ModelType = 'upscale' | 'descreen' | 'artifact-removal';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;
gpuId?: string;
threads?: number;
tta?: boolean;
}ModelObject
interface ModelObject {
key?: Model;
name: string;
upscaler: Upscaler;
type?: ModelType;
scales: number[];
noise: number[] | undefined;
latency: number; // From 0.5 (Fatest model) to 10 (Slowest model)
speed?: Speed;
folder: string;
path?: string;
files: string[];
supportCurrentPlatform?: boolean;
}Downloading
interface Downloading {
start?: () => void;
progress?: (progress: number) => void;
end?: () => void;
}Models Info
Artifact removal
Model | Name | Upscaler | Source
------|------|----------|-------
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
------|------|----------|-------
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
------|------|----------|-------
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
Credits
This project uses the following AI models and upscalers:
