wrapture 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +4 -0
- package/.editorconfig +10 -0
- package/.eslintrc +0 -0
- package/.github/FUNDING.yml +4 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/dependabot.yml +25 -0
- package/.github/labeler.yml +72 -0
- package/.github/labels.yml +24 -0
- package/.github/workflows/auto-assign.yml +19 -0
- package/.github/workflows/check.yml +72 -0
- package/.github/workflows/label.yml +16 -0
- package/.github/workflows/publish.yml +66 -0
- package/.github/workflows/triage.yml +18 -0
- package/.markdownlint.json +7 -0
- package/.prettierrc +7 -0
- package/.release-it.json +67 -0
- package/CHANGELOG.md +8 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +200 -0
- package/LICENSE +21 -0
- package/README.md +182 -0
- package/SECURITY.md +16 -0
- package/api/README.md +35 -0
- package/api/utils/convert.md +96 -0
- package/api/utils/generate-wrapper.md +91 -0
- package/api/wrapture.md +31 -0
- package/bin/wrapture.js +148 -0
- package/custom-typedoc-plugin.js +55 -0
- package/eslint.config.mjs +16 -0
- package/package.json +74 -0
- package/public/docs/README.md +1 -0
- package/python/convert.py +72 -0
- package/python/scripts/basic_model.py +20 -0
- package/scripts/test.ts +11 -0
- package/src/utils/__tests__/convert.unit.ts +47 -0
- package/src/utils/__tests__/generate-wrapper.unit.ts +29 -0
- package/src/utils/convert.ts +98 -0
- package/src/utils/generate-wrapper.ts +107 -0
- package/src/wrapture.ts +51 -0
- package/test/fixtures/basic_model.pt +0 -0
- package/tsconfig.json +27 -0
- package/tsup.config.ts +14 -0
- package/typedoc.json +33 -0
package/src/wrapture.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/* global process */
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
|
|
9
|
+
import { convert } from './utils/convert.js';
|
|
10
|
+
import { generateWrapper } from './utils/generate-wrapper.js';
|
|
11
|
+
|
|
12
|
+
const program = new Command();
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.name('wrapture')
|
|
16
|
+
.description('🌀 One-click model exporter: from PyTorch to Web-ready JS/TS')
|
|
17
|
+
.version('0.1.0')
|
|
18
|
+
.requiredOption('-i, --input <file>', 'Path to the PyTorch model (.pt)')
|
|
19
|
+
.requiredOption(
|
|
20
|
+
'-o, --output <dir>',
|
|
21
|
+
'Output directory for the wrapped model'
|
|
22
|
+
)
|
|
23
|
+
.option('--quantize', 'Apply quantization to reduce model size')
|
|
24
|
+
.option('--format <type>', 'Export format: onnx (default)', 'onnx')
|
|
25
|
+
.option(
|
|
26
|
+
'--backend <backend>',
|
|
27
|
+
'Inference backend: webgpu | wasm | cpu',
|
|
28
|
+
'webgpu'
|
|
29
|
+
)
|
|
30
|
+
.action(async (opts) => {
|
|
31
|
+
const input = path.resolve(opts.input);
|
|
32
|
+
const output = path.resolve(opts.output);
|
|
33
|
+
|
|
34
|
+
if (!existsSync(input)) {
|
|
35
|
+
console.error(chalk.red(`Input file not found: ${input}`));
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log(chalk.cyan('✨ Wrapture: Exporting model...'));
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
await convert(input, output, opts);
|
|
43
|
+
await generateWrapper(output, opts);
|
|
44
|
+
console.log(chalk.green('✅ Done! Your model is wrapped and ready.'));
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.error(chalk.red('❌ Failed to export model:'), err);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
program.parse(process.argv);
|
|
Binary file
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"outDir": "bin",
|
|
5
|
+
"module": "Node16",
|
|
6
|
+
"lib": ["ES2022", "dom", "dom.iterable"],
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationMap": true,
|
|
10
|
+
"declarationDir": "./dts",
|
|
11
|
+
"noImplicitReturns": true,
|
|
12
|
+
"noImplicitThis": true,
|
|
13
|
+
"noImplicitAny": false,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"resolveJsonModule": true
|
|
18
|
+
},
|
|
19
|
+
"exclude": [
|
|
20
|
+
"node_modules",
|
|
21
|
+
"dist",
|
|
22
|
+
"bin",
|
|
23
|
+
"scripts",
|
|
24
|
+
"dts",
|
|
25
|
+
"**/__tests__/**"
|
|
26
|
+
]
|
|
27
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable import/no-unused-modules */
|
|
2
|
+
import { defineConfig } from 'tsup';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
entry: ['src/wrapture.ts'],
|
|
6
|
+
format: ['esm'],
|
|
7
|
+
target: 'node16',
|
|
8
|
+
outDir: 'bin',
|
|
9
|
+
clean: true,
|
|
10
|
+
tsconfig: './tsconfig.json',
|
|
11
|
+
banner: {
|
|
12
|
+
js: '#!/usr/bin/env node'
|
|
13
|
+
}
|
|
14
|
+
});
|
package/typedoc.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://typedoc-plugin-markdown.org/schema.json",
|
|
3
|
+
"plugin": [
|
|
4
|
+
"typedoc-plugin-markdown",
|
|
5
|
+
"typedoc-plugin-remark",
|
|
6
|
+
"typedoc-plugin-mdn-links",
|
|
7
|
+
"typedoc-plugin-rename-defaults",
|
|
8
|
+
"./custom-typedoc-plugin.js"
|
|
9
|
+
],
|
|
10
|
+
"out": "./api",
|
|
11
|
+
|
|
12
|
+
"outputFileStrategy": "modules",
|
|
13
|
+
"interfacePropertiesFormat": "table",
|
|
14
|
+
"classPropertiesFormat": "table",
|
|
15
|
+
"enumMembersFormat": "table",
|
|
16
|
+
"typeDeclarationFormat": "htmlTable",
|
|
17
|
+
"propertyMembersFormat": "table",
|
|
18
|
+
"theme": "custom-markdown-theme",
|
|
19
|
+
"parametersFormat": "table",
|
|
20
|
+
"entryPoints": ["src"],
|
|
21
|
+
"entryPointStrategy": "expand",
|
|
22
|
+
"readme": "./public/docs/README.md",
|
|
23
|
+
"gitRevision": "main",
|
|
24
|
+
"githubPages": false,
|
|
25
|
+
"mergeReadme": true,
|
|
26
|
+
"useCodeBlocks": true,
|
|
27
|
+
"expandObjects": true,
|
|
28
|
+
"remarkPlugins": [
|
|
29
|
+
"unified-prettier",
|
|
30
|
+
["remark-github", { "repository": "https://github.com/phun-ky/wrapture" }],
|
|
31
|
+
["remark-toc", { "heading": "Table of Contents", "maxDepth": 3 }]
|
|
32
|
+
]
|
|
33
|
+
}
|