Skip to content

Commit

Permalink
Fix entry points
Browse files Browse the repository at this point in the history
  • Loading branch information
thekevinscott committed Oct 5, 2023
1 parent 1c74d5f commit c839694
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 3 deletions.
1 change: 1 addition & 0 deletions models/default-model/src/umd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default, } from '.';
2 changes: 1 addition & 1 deletion models/default-model/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../tsconfig.cjs.json",
"include": [
"./src/index.ts",
"./src/cjs.ts",
]
}
2 changes: 1 addition & 1 deletion models/default-model/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../tsconfig.esm.json",
"include": [
"./src/index.ts",
"./src/esm.ts",
]
}
2 changes: 1 addition & 1 deletion models/default-model/tsconfig.umd.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../tsconfig.umd.json",
"include": [
"./src/index.ts",
"./src/umd.ts",
]
}
12 changes: 12 additions & 0 deletions packages/shared/src/esrgan/esrgan.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { Meta, ModelDefinition } from '../types';
import type { Tensor4D } from '@tensorflow/tfjs-core';
export type Inputs = Tensor4D | Tensor4D[];
export type Scale = 2 | 3 | 4 | 8;
export declare const getESRGANModelDefinition: ({ scale, name, version, meta: { architecture, ...meta }, path: modelPath, }: {
name: string;
version: string;
scale: Scale;
meta: Meta;
path?: string | undefined;
}) => ModelDefinition;
//# sourceMappingURL=esrgan.d.ts.map
1 change: 1 addition & 0 deletions packages/shared/src/esrgan/esrgan.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 123 additions & 0 deletions packages/shared/src/esrgan/esrgan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getESRGANModelDefinition = void 0;
var isTensorArray = function (inputs) {
return Array.isArray(inputs);
};
var getInput = function (inputs) {
if (isTensorArray(inputs)) {
return inputs[0];
}
return inputs;
};
var getESRGANModelDefinition = function (_a) {
var scale = _a.scale, name = _a.name, version = _a.version, _b = _a.meta, architecture = _b.architecture, meta = __rest(_b, ["architecture"]), modelPath = _a.path;
var path = modelPath || "models/".concat(scale, "x/model.json");
if (architecture === 'rdn') {
return {
scale: scale,
modelType: 'layers',
_internals: {
path: path,
name: name,
version: version,
},
meta: __assign({ architecture: architecture }, meta),
inputRange: [0, 255,],
outputRange: [0, 255,],
};
}
var setup = function (tf) {
var Layer = tf.layers.Layer;
var BETA = 0.2;
var MultiplyBeta = (function (_super) {
__extends(MultiplyBeta, _super);
function MultiplyBeta() {
var _this = _super.call(this, {}) || this;
_this.beta = BETA;
return _this;
}
MultiplyBeta.prototype.call = function (inputs) {
return tf.mul(getInput(inputs), this.beta);
};
MultiplyBeta.className = 'MultiplyBeta';
return MultiplyBeta;
}(Layer));
var getPixelShuffle = function (_scale) {
var PixelShuffle = (function (_super) {
__extends(PixelShuffle, _super);
function PixelShuffle() {
var _this = _super.call(this, {}) || this;
_this.scale = _scale;
return _this;
}
PixelShuffle.prototype.computeOutputShape = function (inputShape) {
return [inputShape[0], inputShape[1], inputShape[2], 3,];
};
PixelShuffle.prototype.call = function (inputs) {
return tf.depthToSpace(getInput(inputs), this.scale, 'NHWC');
};
PixelShuffle.className = "PixelShuffle".concat(scale, "x");
return PixelShuffle;
}(Layer));
return PixelShuffle;
};
[
MultiplyBeta,
getPixelShuffle(scale),
].forEach(function (layer) {
tf.serialization.registerClass(layer);
});
};
return {
setup: setup,
scale: scale,
modelType: 'layers',
_internals: {
path: path,
name: name,
version: version,
},
meta: __assign({ architecture: architecture }, meta),
inputRange: [0, 1,],
outputRange: [0, 1,],
};
};
exports.getESRGANModelDefinition = getESRGANModelDefinition;
53 changes: 53 additions & 0 deletions packages/shared/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as tf from '@tensorflow/tfjs-core';
import type * as tfBrowser from '@tensorflow/tfjs';
import type * as tfNode from '@tensorflow/tfjs-node';
import type * as tfNodeGpu from '@tensorflow/tfjs-node-gpu';
import { Tensor, Tensor4D } from '@tensorflow/tfjs-core';
export type TF = typeof tfBrowser | typeof tfNode | typeof tfNodeGpu;
export type TFN = typeof tfNode | typeof tfNodeGpu;
export type OpExecutor = tfBrowser.OpExecutor | tfNode.OpExecutor | tfNodeGpu.OpExecutor;
export type GraphModel = tfBrowser.GraphModel | tfNode.GraphModel | tfNodeGpu.GraphModel;
export type ProcessFn<T extends Tensor> = (t: T) => T;
export interface ModelConfigurationInternals {
name: string;
version: string;
path: string;
}
export type Range = [number, number];
type MetaValue = string | number | Meta | null | undefined | boolean;
export type Meta = {
[key: string]: MetaValue;
};
export type ModelType = 'graph' | 'layers';
export type PreProcess = ProcessFn<Tensor4D>;
export type PostProcess = ProcessFn<Tensor4D>;
export type FixedShape4D = [null | number, number, number, number];
export type DynamicShape4D = [null | number, null, null, number];
export type Shape4D = FixedShape4D | DynamicShape4D;
export type Setup = (tf: TF) => (void | Promise<void>);
export type Teardown = (tf: TF) => (void | Promise<void>);
export interface ModelDefinition {
modelType?: ModelType;
path?: string;
scale?: number;
channels?: 3;
_internals?: ModelConfigurationInternals;
preprocess?: PreProcess;
postprocess?: PostProcess;
inputRange?: Range;
outputRange?: Range;
divisibilityFactor?: number;
meta?: Meta;
setup?: Setup;
teardown?: Teardown;
}
export type ModelDefinitionFn = (tf: TF) => ModelDefinition;
export type ModelDefinitionObjectOrFn = ModelDefinitionFn | ModelDefinition;
export type IsTensor<T extends tf.Tensor> = (pixels: Tensor) => pixels is T;
export declare enum MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE {
UNDEFINED = "undefined",
INVALID_MODEL_TYPE = "invalidModelType",
MISSING_PATH = "missingPath"
}
export {};
//# sourceMappingURL=types.d.ts.map
1 change: 1 addition & 0 deletions packages/shared/src/types.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/shared/src/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE = void 0;
var MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE;
(function (MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE) {
MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE["UNDEFINED"] = "undefined";
MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE["INVALID_MODEL_TYPE"] = "invalidModelType";
MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE["MISSING_PATH"] = "missingPath";
})(MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE || (exports.MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE = MODEL_DEFINITION_VALIDATION_CHECK_ERROR_TYPE = {}));

0 comments on commit c839694

Please sign in to comment.