Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ollm/opencomic-ai-models/llms.txt

Use this file to discover all available pages before exploring further.

By the end of this guide you will have opencomic-ai-models installed, the absolute path to the bundled models/ directory resolved in your code, and a working Node.js snippet that passes that path to an upscaler binary to enhance a comic page image. The only public API you need is OpenComicAIModels.path — a single string property that does all the heavy lifting of locating the model files on disk.
1
Install the package
2
Run the following command in your project root to install opencomic-ai-models from GitHub:
3
npm install github:ollm/opencomic-ai-models
4
npm will fetch the repository, run the Rollup build step automatically via the prepare lifecycle hook, and place the compiled output and model weights under node_modules/opencomic-ai-models/.
5
Import the package
6
ESM (TypeScript / modern JS)
import OpenComicAIModels from 'opencomic-ai-models';
Use this form in any project with "type": "module" in its package.json, or in a .mjs / .mts file.
CJS (CommonJS)
const OpenComicAIModels = require('opencomic-ai-models');
Use this form in projects that use require(), such as older Node.js scripts or projects without "type": "module".
7
Both forms load the same underlying data and expose the identical path property — pick whichever matches your project’s module system.
8
Read the path property
9
Access OpenComicAIModels.path to get the absolute filesystem path to the models/ directory:
10
import OpenComicAIModels from 'opencomic-ai-models';

const modelsPath: string = OpenComicAIModels.path;

console.log(modelsPath);
// → /home/user/my-project/node_modules/opencomic-ai-models/models
11
The path is resolved at module-load time using path.join relative to the package’s own __dirname (or import.meta.dirname in ESM), so it is always accurate regardless of where your project lives on disk.
12
Pass the path to an upscaler binary
13
With modelsPath in hand you can invoke any compatible upscaler binary. The example below uses Node.js’s built-in child_process.execFile to call the upscayl-bin executable with the realesrgan-x4plus-anime model — a popular x4 upscale model for anime-style comic art:
14
import { execFile } from 'node:child_process';
import path from 'node:path';
import OpenComicAIModels from 'opencomic-ai-models';

const modelsPath: string = OpenComicAIModels.path;

// Paths for input and output images
const inputImage = path.resolve('input.png');
const outputImage = path.resolve('output.png');

// Model ID to use — must correspond to a subdirectory inside modelsPath
const modelId = 'realesrgan-x4plus-anime';

// Path to your upscayl-bin executable (adjust to your system)
const upscaylBin = '/usr/local/bin/upscayl-bin';

execFile(
  upscaylBin,
  [
    '-i', inputImage,
    '-o', outputImage,
    '-m', modelsPath,   // <-- pass the resolved models directory
    '-n', modelId,      // <-- specify the model by ID
    '-s', '4',          // scale factor
    '-f', 'png',        // output format
  ],
  (error, stdout, stderr) => {
    if (error) {
      console.error('Upscaling failed:', error.message);
      console.error(stderr);
      process.exit(1);
    }
    console.log('Upscaling complete →', outputImage);
    console.log(stdout);
  }
);
15
The key arguments are -m modelsPath (the directory containing all model subdirectories) and -n modelId (the specific model to use). The upscaler binary locates the model files inside modelsPath/realesrgan-x4plus-anime/ at runtime.
16
Not sure which model ID to use? The Upscale Models, Artifact Removal, and Descreen pages list every bundled model with its ID, display name, compatible upscaler backend, and original source. For general anime and manga upscaling realesrgan-x4plus-anime is a solid default; for removing JPEG compression artifacts before upscaling, combine it with a pass using opencomic-ai-artifact-removal.

Complete Example

Here is a self-contained TypeScript file that brings together all four steps above:
// upscale.ts
import { execFile } from 'node:child_process';
import path from 'node:path';
import OpenComicAIModels from 'opencomic-ai-models';

const modelsPath: string = OpenComicAIModels.path;
const inputImage = path.resolve(process.argv[2] ?? 'input.png');
const outputImage = path.resolve(process.argv[3] ?? 'output.png');
const modelId = 'realesrgan-x4plus-anime';
const upscaylBin = process.env.UPSCAYL_BIN ?? 'upscayl-bin';

console.log(`Models directory : ${modelsPath}`);
console.log(`Input            : ${inputImage}`);
console.log(`Output           : ${outputImage}`);
console.log(`Model            : ${modelId}`);

execFile(
  upscaylBin,
  ['-i', inputImage, '-o', outputImage, '-m', modelsPath, '-n', modelId, '-s', '4', '-f', 'png'],
  (error, stdout, stderr) => {
    if (error) {
      console.error('Error:', error.message);
      if (stderr) console.error(stderr);
      process.exit(1);
    }
    console.log('Done:', outputImage);
    if (stdout) console.log(stdout);
  }
);
Run it with:
npx ts-node upscale.ts page-001.png page-001-upscaled.png
Set the UPSCAYL_BIN environment variable to the full path of your upscayl-bin executable if it is not on your PATH.

Build docs developers (and LLMs) love