genai
Version:
Universal Generative AI (GenAI) Settings for GenAI applications
91 lines (90 loc) • 3.85 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const GenAIObject_1 = __importDefault(require("./GenAIObject"));
class GenAISetting extends GenAIObject_1.default {
constructor(options = {
currentLayer: null,
name: null,
generationModelName: 'model.ckpt',
docType: 'illustration',
currentPrompt: '',
imageHeight: 1024,
imageWidth: 1024,
consistencyStrength: 0.7,
stylingStrength: 0.7,
negativePrompt: '',
tempLayer: null,
seed: -1,
batchSize: 1,
tags: {},
model_config: 'OpenJourney-Config',
is_cloud_run: true,
isGenerating: false,
promptPrefix: '',
promptSuffix: '',
}) {
super();
this.name = options.name;
this.currentLayer = options.currentLayer;
this.generationModelName = options.generationModelName;
this.prompt = options.prompt;
this.promptPrefix = options.promptPrefix;
this.promptSuffix = options.promptSuffix;
this.imageHeight = options.imageHeight;
this.imageWidth = options.imageHeight;
this.consistencyStrength = options.consistencyStrength;
this.stylingStrength = options.stylingStrength;
this.negativePrompt = options.negativePrompt;
this.tempLayer = options.tempLayer;
this.docType = options.docType;
this.batchSize = options.batchSize;
this.seed = options.seed;
this.model_config = options.model_config;
this.is_cloud_run = options.is_cloud_run;
this.isGenerating = options.isGenerating;
}
hasLayerMask() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.currentLayer.hasMask();
});
}
applyLayerMask() {
return __awaiter(this, void 0, void 0, function* () {
if (yield this.hasLayerMask()) {
yield this.currentLayer.applyMask();
return true;
}
return false;
});
}
duplicateCurrentLayer() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.currentLayer.duplicate();
});
}
getStylingStrength() {
return 20 * this.stylingStrength;
}
/**
* The consistency strength is just the amount of denoising will occur. 30 is the max amount of noise in the API. So we are letting the user
* set the percentage of noise they want to have. The higher the number the more noise, it is confusing so we are inversing that for the user and calling it
* `consistency strength`. So for the most noise, we will set the consistency strength to 0. for the least noise, we will set the consistency strength to 1.
* @returns
*/
getDenoisingStrength() {
return 1 - this.consistencyStrength;
}
}
exports.default = GenAISetting;