novelai-python
novelai-python copied to clipboard
Feature: Add cost calculation for upscale enhancement
#21 duplicate
The calculation of this function consists of certain functions. After Novelai V4 is officially released, I will try to add it ———
Of course, I've been busy with work lately...
What we know is that there is only one pricing function. But unfortunately I can't guess the logic, and astrology has no results.
let IMAGE_PRICE_TIERS = [
[1048576, 7], // 1024x1024
[786432, 5], // 887x887
[524288, 3], // 724x724
[409600, 2], // 640x640
[262144, 1] // 512x512
];
export function calculateImagePrice(width: number, height: number, userContext: any) {
let totalPixels = width * height;
if (totalPixels <= 409600 &&
userContext.subscription.tier >= 3 &&
isValidSubscription(userContext.subscription)) {
return 0;
}
let price = -3;
for (let [pixelThreshold, priceCredits] of IMAGE_PRICE_TIERS) {
if (totalPixels <= pixelThreshold) {
price = priceCredits;
}
}
return price;
}