Spaces:
Paused
Paused
Julian Bilcke
commited on
Commit
·
b785e1d
1
Parent(s):
c4b02b2
let's upse more image upscaling servers for the load
Browse files- src/production/renderImage.mts +1 -0
- src/types.mts +5 -0
- src/utils/generateImageSDXL.mts +7 -0
- src/utils/parseRenderRequest.mts +4 -0
- src/utils/upscaleImage.mts +2 -1
src/production/renderImage.mts
CHANGED
|
@@ -17,6 +17,7 @@ export async function renderImage(
|
|
| 17 |
|
| 18 |
const params = {
|
| 19 |
positivePrompt: request.prompt,
|
|
|
|
| 20 |
seed: request.seed,
|
| 21 |
nbSteps: request.nbSteps,
|
| 22 |
width: request.width,
|
|
|
|
| 17 |
|
| 18 |
const params = {
|
| 19 |
positivePrompt: request.prompt,
|
| 20 |
+
negativePrompt: request.negativePrompt,
|
| 21 |
seed: request.seed,
|
| 22 |
nbSteps: request.nbSteps,
|
| 23 |
width: request.width,
|
src/types.mts
CHANGED
|
@@ -276,6 +276,9 @@ export type CacheMode = "use" | "renew" | "ignore"
|
|
| 276 |
export interface RenderRequest {
|
| 277 |
prompt: string
|
| 278 |
|
|
|
|
|
|
|
|
|
|
| 279 |
// whether to use video segmentation
|
| 280 |
// disabled (default)
|
| 281 |
// firstframe: we only analyze the first frame
|
|
@@ -303,6 +306,8 @@ export interface RenderRequest {
|
|
| 303 |
projection: ProjectionMode
|
| 304 |
|
| 305 |
cache: CacheMode
|
|
|
|
|
|
|
| 306 |
}
|
| 307 |
|
| 308 |
export interface ImageSegmentationRequest {
|
|
|
|
| 276 |
export interface RenderRequest {
|
| 277 |
prompt: string
|
| 278 |
|
| 279 |
+
// unused for now
|
| 280 |
+
negativePrompt: string
|
| 281 |
+
|
| 282 |
// whether to use video segmentation
|
| 283 |
// disabled (default)
|
| 284 |
// firstframe: we only analyze the first frame
|
|
|
|
| 306 |
projection: ProjectionMode
|
| 307 |
|
| 308 |
cache: CacheMode
|
| 309 |
+
|
| 310 |
+
wait: boolean // wait until the job is completed
|
| 311 |
}
|
| 312 |
|
| 313 |
export interface ImageSegmentationRequest {
|
src/utils/generateImageSDXL.mts
CHANGED
|
@@ -24,6 +24,10 @@ export async function generateImageSDXLAsBase64(options: {
|
|
| 24 |
if (!positivePrompt) {
|
| 25 |
throw new Error("missing prompt")
|
| 26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
const negativePrompt = options?.negativePrompt || ""
|
| 28 |
|
| 29 |
// we treat 0 as meaning "random seed"
|
|
@@ -38,9 +42,12 @@ export async function generateImageSDXLAsBase64(options: {
|
|
| 38 |
instances.push(instance)
|
| 39 |
|
| 40 |
const positive = [
|
|
|
|
|
|
|
| 41 |
"beautiful",
|
| 42 |
"intricate details",
|
| 43 |
positivePrompt,
|
|
|
|
| 44 |
"award winning",
|
| 45 |
"high resolution"
|
| 46 |
].filter(word => word)
|
|
|
|
| 24 |
if (!positivePrompt) {
|
| 25 |
throw new Error("missing prompt")
|
| 26 |
}
|
| 27 |
+
|
| 28 |
+
// the negative prompt CAN be missing, since we use a trick
|
| 29 |
+
// where we make the interface mandatory in the TS doc,
|
| 30 |
+
// but browsers might send something partial
|
| 31 |
const negativePrompt = options?.negativePrompt || ""
|
| 32 |
|
| 33 |
// we treat 0 as meaning "random seed"
|
|
|
|
| 42 |
instances.push(instance)
|
| 43 |
|
| 44 |
const positive = [
|
| 45 |
+
|
| 46 |
+
// oh well.. is it too late to move this to the bottom?
|
| 47 |
"beautiful",
|
| 48 |
"intricate details",
|
| 49 |
positivePrompt,
|
| 50 |
+
|
| 51 |
"award winning",
|
| 52 |
"high resolution"
|
| 53 |
].filter(word => word)
|
src/utils/parseRenderRequest.mts
CHANGED
|
@@ -9,6 +9,9 @@ export function parseRenderRequest(request: RenderRequest) {
|
|
| 9 |
try {
|
| 10 |
request.nbFrames = getValidNumber(request.nbFrames, 1, 24, 16)
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
const isVideo = request?.nbFrames === 1
|
| 13 |
|
| 14 |
// note that we accept a seed of 0
|
|
@@ -27,6 +30,7 @@ export function parseRenderRequest(request: RenderRequest) {
|
|
| 27 |
request.height = getValidNumber(request.height, 256, 720, 320)
|
| 28 |
}
|
| 29 |
|
|
|
|
| 30 |
request.cache = request?.cache || "ignore"
|
| 31 |
} catch (err) {
|
| 32 |
console.error(`failed to parse the render request: ${err}`)
|
|
|
|
| 9 |
try {
|
| 10 |
request.nbFrames = getValidNumber(request.nbFrames, 1, 24, 16)
|
| 11 |
|
| 12 |
+
// wait! if we uncomment this, this will invalidate all the images already in cache..
|
| 13 |
+
// request.negativePrompt = request.negativePrompt || ""
|
| 14 |
+
|
| 15 |
const isVideo = request?.nbFrames === 1
|
| 16 |
|
| 17 |
// note that we accept a seed of 0
|
|
|
|
| 30 |
request.height = getValidNumber(request.height, 256, 720, 320)
|
| 31 |
}
|
| 32 |
|
| 33 |
+
request.wait = request?.wait || false
|
| 34 |
request.cache = request?.cache || "ignore"
|
| 35 |
} catch (err) {
|
| 36 |
console.error(`failed to parse the render request: ${err}`)
|
src/utils/upscaleImage.mts
CHANGED
|
@@ -6,7 +6,8 @@ import { getValidNumber } from "./getValidNumber.mts"
|
|
| 6 |
// we don't use replicas yet, because it ain't easy to get their hostname
|
| 7 |
const instances: string[] = [
|
| 8 |
`${process.env.VC_UPSCALING_SPACE_API_URL_1 || ""}`,
|
| 9 |
-
|
|
|
|
| 10 |
].filter(instance => instance?.length > 0)
|
| 11 |
|
| 12 |
// this doesn't work because of this error.. I think the version of Gradio is too old/young?
|
|
|
|
| 6 |
// we don't use replicas yet, because it ain't easy to get their hostname
|
| 7 |
const instances: string[] = [
|
| 8 |
`${process.env.VC_UPSCALING_SPACE_API_URL_1 || ""}`,
|
| 9 |
+
`${process.env.VC_UPSCALING_SPACE_API_URL_2 || ""}`,
|
| 10 |
+
`${process.env.VC_UPSCALING_SPACE_API_URL_3 || ""}`,
|
| 11 |
].filter(instance => instance?.length > 0)
|
| 12 |
|
| 13 |
// this doesn't work because of this error.. I think the version of Gradio is too old/young?
|