Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,867 Bytes
955ce73 44fe180 30c1ba0 44fe180 198274c 44fe180 95bbb7f b785e1d 44fe180 c4b02b2 95bbb7f c4b02b2 4872066 058800c 30c1ba0 44fe180 cb7d06b 44fe180 30c1ba0 44fe180 30c1ba0 44fe180 eff8217 96f407e c4b02b2 44fe180 c4b02b2 30c1ba0 44fe180 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import { RenderRequest } from "../../types.mts"
import { generateSeed } from "../misc/generateSeed.mts"
import { getValidBoolean } from "../validators/getValidBoolean.mts"
import { getValidNumber } from "../validators/getValidNumber.mts"
export function parseRenderRequest(request: RenderRequest) {
// console.log("parseRenderRequest: "+JSON.stringify(request, null, 2))
try {
// we are large on the values here, since each model will have their own limits
// we just want pseudo-valid numbers
request.nbFrames = getValidNumber(request.nbFrames, 1, 2147483647, 1)
request.nbFPS = getValidNumber(request.nbFPS, 1, 2147483647, 1)
request.negativePrompt = request.negativePrompt || ""
const isVideo = request?.nbFrames === 1
// note that we accept a seed of 0
// (this ensure we are able to cache the whole request by signing it)
request.seed = getValidNumber(request.seed, 0, 2147483647, 0)
// but obviously we will treat 0 as the random seed at a later stage
request.upscalingFactor = getValidNumber(request.upscalingFactor, 0, 4, 0)
request.nbSteps = getValidNumber(request.nbSteps, 1, 50, 10)
request.analyze = request?.analyze ? true : false
if (isVideo) {
request.width = getValidNumber(request.width, 256, 2048, 576)
request.height = getValidNumber(request.height, 256, 2048, 320)
} else {
request.width = getValidNumber(request.width, 256, 2048, 1024)
request.height = getValidNumber(request.height, 256, 2048, 1024)
}
request.turbo = getValidBoolean(request.turbo, false)
request.wait = getValidBoolean(request?.wait, false)
request.cache = request?.cache || "ignore"
} catch (err) {
console.error(`failed to parse the render request: ${err}`)
}
// console.log("parsed request: "+JSON.stringify(request, null, 2))
return request
} |