novelai-python icon indicating copy to clipboard operation
novelai-python copied to clipboard

Feature: Add cost calculation for upscale enhancement

Open misskey opened this issue 1 year ago • 3 comments

misskey avatar Feb 28 '25 09:02 misskey

#21 duplicate

sudoskys avatar Feb 28 '25 09:02 sudoskys

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...

sudoskys avatar Feb 28 '25 10:02 sudoskys

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;
}

sudoskys avatar Mar 04 '25 11:03 sudoskys