Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
72cec5c
1
Parent(s):
c3d5145
replacing the URLs of the various servers
Browse files
.env
CHANGED
@@ -26,24 +26,7 @@ VC_STORAGE_PATH="/data/"
|
|
26 |
#VC_INFERENCE_ENDPOINT_URL="<USE YOUR OWN>"
|
27 |
|
28 |
#--------------------- SDXL INFERENCE SERVERS ---------------------
|
29 |
-
|
30 |
-
VC_SDXL_SPACE_API_URL_2="https://jbilcke-hf-image-server-2.hf.space"
|
31 |
-
VC_SDXL_SPACE_API_URL_3="https://jbilcke-hf-image-server-3.hf.space"
|
32 |
-
VC_SDXL_SPACE_API_URL_4="https://jbilcke-hf-image-server-4.hf.space"
|
33 |
-
VC_SDXL_SPACE_API_URL_5="https://jbilcke-hf-image-server-5.hf.space"
|
34 |
-
VC_SDXL_SPACE_API_URL_6="https://jbilcke-hf-image-server-6.hf.space"
|
35 |
-
VC_SDXL_SPACE_API_URL_7="https://jbilcke-hf-image-server-7.hf.space"
|
36 |
-
VC_SDXL_SPACE_API_URL_8="https://jbilcke-hf-image-server-8.hf.space"
|
37 |
-
VC_SDXL_SPACE_API_URL_9="https://jbilcke-hf-image-server-9.hf.space"
|
38 |
-
VC_SDXL_SPACE_API_URL_10="https://jbilcke-hf-image-server-10.hf.space"
|
39 |
-
VC_SDXL_SPACE_API_URL_11="https://jbilcke-hf-image-server-11.hf.space"
|
40 |
-
VC_SDXL_SPACE_API_URL_12="https://jbilcke-hf-image-server-12.hf.space"
|
41 |
-
VC_SDXL_SPACE_API_URL_13="https://jbilcke-hf-image-server-13.hf.space"
|
42 |
-
VC_SDXL_SPACE_API_URL_14="https://jbilcke-hf-image-server-14.hf.space"
|
43 |
-
VC_SDXL_SPACE_API_URL_15="https://jbilcke-hf-image-server-15.hf.space"
|
44 |
-
VC_SDXL_SPACE_API_URL_16="https://jbilcke-hf-image-server-16.hf.space"
|
45 |
-
VC_SDXL_SPACE_API_URL_17="https://jbilcke-hf-image-server-17.hf.space"
|
46 |
-
VC_SDXL_SPACE_API_URL_18="https://jbilcke-hf-image-server-18.hf.space"
|
47 |
|
48 |
#----------------- ZEROSCOPE INFERENCE SERVERS -------------------
|
49 |
VC_ZEROSCOPE_SPACE_API_URL_1="https://jbilcke-hf-video-server-1.hf.space"
|
@@ -53,14 +36,6 @@ VC_ZEROSCOPE_SPACE_API_URL_4="https://jbilcke-hf-video-server-4.hf.space"
|
|
53 |
|
54 |
#----------------- HOTSHOT-XL INFERENCE SERVERS -------------------
|
55 |
VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_1="https://jbilcke-hf-hotshot-xl-server-1.hf.space"
|
56 |
-
VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_2="https://jbilcke-hf-hotshot-xl-server-2.hf.space"
|
57 |
-
VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_3="https://jbilcke-hf-hotshot-xl-server-3.hf.space"
|
58 |
-
VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_4="https://jbilcke-hf-hotshot-xl-server-4.hf.space"
|
59 |
-
VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_5="https://jbilcke-hf-hotshot-xl-server-5.hf.space"
|
60 |
-
VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_6="https://jbilcke-hf-hotshot-xl-server-6.hf.space"
|
61 |
-
VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_7="https://jbilcke-hf-hotshot-xl-server-7.hf.space"
|
62 |
-
VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_8="https://jbilcke-hf-hotshot-xl-server-8.hf.space"
|
63 |
-
|
64 |
|
65 |
#----------------- HOTSHOT-XL REPLICATE CONFIG --------------------
|
66 |
VC_HOTSHOT_XL_REPLICATE_MODEL="cloneofsimo/hotshot-xl-lora-controlnet"
|
@@ -78,11 +53,7 @@ VC_SEGMENTATION_MODULE_SPACE_API_URL="https://jbilcke-hf-image-segmentation.hf.s
|
|
78 |
VC_SDXL_360_SPACE_API_URL_1="https://jbilcke-hf-360-server-1.hf.space"
|
79 |
|
80 |
#----------------- IMAGE UPSCALING SERVERS -----------------------
|
81 |
-
|
82 |
-
VC_UPSCALING_SPACE_API_URL_2="https://jbilcke-hf-upscaling-server-2.hf.space"
|
83 |
-
VC_UPSCALING_SPACE_API_URL_3="https://jbilcke-hf-upscaling-server-3.hf.space"
|
84 |
-
VC_UPSCALING_SPACE_API_URL_4="https://jbilcke-hf-upscaling-server-4.hf.space"
|
85 |
-
#VC_UPSCALING_SPACE_API_URL_5="https://jbilcke-hf-upscaling-server-5.hf.space"
|
86 |
|
87 |
#----------------- VIDEO UPSCALING SERVERS -----------------------
|
88 |
VC_VIDEO_UPSCALE_SPACE_API_URL_1="https://jbilcke-hf-video-upscaling-server-1.hf.space"
|
|
|
26 |
#VC_INFERENCE_ENDPOINT_URL="<USE YOUR OWN>"
|
27 |
|
28 |
#--------------------- SDXL INFERENCE SERVERS ---------------------
|
29 |
+
VC_SDXL_SPACE_API_URL="https://jbilcke-hf-image-server.hf.space"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
#----------------- ZEROSCOPE INFERENCE SERVERS -------------------
|
32 |
VC_ZEROSCOPE_SPACE_API_URL_1="https://jbilcke-hf-video-server-1.hf.space"
|
|
|
36 |
|
37 |
#----------------- HOTSHOT-XL INFERENCE SERVERS -------------------
|
38 |
VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_1="https://jbilcke-hf-hotshot-xl-server-1.hf.space"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
#----------------- HOTSHOT-XL REPLICATE CONFIG --------------------
|
41 |
VC_HOTSHOT_XL_REPLICATE_MODEL="cloneofsimo/hotshot-xl-lora-controlnet"
|
|
|
53 |
VC_SDXL_360_SPACE_API_URL_1="https://jbilcke-hf-360-server-1.hf.space"
|
54 |
|
55 |
#----------------- IMAGE UPSCALING SERVERS -----------------------
|
56 |
+
VC_UPSCALING_SPACE_API_URL="https://jbilcke-hf-upscaling-server.hf.space"
|
|
|
|
|
|
|
|
|
57 |
|
58 |
#----------------- VIDEO UPSCALING SERVERS -----------------------
|
59 |
VC_VIDEO_UPSCALE_SPACE_API_URL_1="https://jbilcke-hf-video-upscaling-server-1.hf.space"
|
src/providers/image-generation/generateImageSDXL.mts
CHANGED
@@ -9,27 +9,7 @@ import { getValidNumber } from "../../utils/validators/getValidNumber.mts"
|
|
9 |
// note: to reduce costs I use the small A10s (not the large)
|
10 |
// anyway, we will soon not need to use this cloud anymore
|
11 |
// since we will be able to leverage the Inference API
|
12 |
-
const
|
13 |
-
`${process.env.VC_SDXL_SPACE_API_URL_1 || ""}`,
|
14 |
-
`${process.env.VC_SDXL_SPACE_API_URL_2 || ""}`,
|
15 |
-
`${process.env.VC_SDXL_SPACE_API_URL_3 || ""}`,
|
16 |
-
`${process.env.VC_SDXL_SPACE_API_URL_4 || ""}`,
|
17 |
-
`${process.env.VC_SDXL_SPACE_API_URL_5 || ""}`,
|
18 |
-
`${process.env.VC_SDXL_SPACE_API_URL_6 || ""}`,
|
19 |
-
`${process.env.VC_SDXL_SPACE_API_URL_7 || ""}`,
|
20 |
-
`${process.env.VC_SDXL_SPACE_API_URL_8 || ""}`,
|
21 |
-
`${process.env.VC_SDXL_SPACE_API_URL_9 || ""}`,
|
22 |
-
`${process.env.VC_SDXL_SPACE_API_URL_10 || ""}`,
|
23 |
-
`${process.env.VC_SDXL_SPACE_API_URL_11 || ""}`,
|
24 |
-
`${process.env.VC_SDXL_SPACE_API_URL_12 || ""}`,
|
25 |
-
`${process.env.VC_SDXL_SPACE_API_URL_13 || ""}`,
|
26 |
-
`${process.env.VC_SDXL_SPACE_API_URL_14 || ""}`,
|
27 |
-
`${process.env.VC_SDXL_SPACE_API_URL_15 || ""}`,
|
28 |
-
`${process.env.VC_SDXL_SPACE_API_URL_16 || ""}`,
|
29 |
-
`${process.env.VC_SDXL_SPACE_API_URL_17 || ""}`,
|
30 |
-
`${process.env.VC_SDXL_SPACE_API_URL_18 || ""}`,
|
31 |
-
].filter(instance => instance?.length > 0)
|
32 |
-
|
33 |
const secretToken = `${process.env.VC_MICROSERVICE_SECRET_TOKEN || ""}`
|
34 |
|
35 |
// console.log("DEBUG:", JSON.stringify({ instances, secretToken }, null, 2))
|
@@ -61,9 +41,6 @@ export async function generateImageSDXLAsBase64(options: {
|
|
61 |
const nbSteps = getValidNumber(options?.nbSteps, 5, 100, 20)
|
62 |
// console.log("SEED:", seed)
|
63 |
|
64 |
-
const instance = instances.shift()
|
65 |
-
instances.push(instance)
|
66 |
-
|
67 |
const positive = [
|
68 |
|
69 |
// oh well.. is it too late to move this to the bottom?
|
|
|
9 |
// note: to reduce costs I use the small A10s (not the large)
|
10 |
// anyway, we will soon not need to use this cloud anymore
|
11 |
// since we will be able to leverage the Inference API
|
12 |
+
const instance = `${process.env.VC_SDXL_SPACE_API_URL || ""}`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
const secretToken = `${process.env.VC_MICROSERVICE_SECRET_TOKEN || ""}`
|
14 |
|
15 |
// console.log("DEBUG:", JSON.stringify({ instances, secretToken }, null, 2))
|
|
|
41 |
const nbSteps = getValidNumber(options?.nbSteps, 5, 100, 20)
|
42 |
// console.log("SEED:", seed)
|
43 |
|
|
|
|
|
|
|
44 |
const positive = [
|
45 |
|
46 |
// oh well.. is it too late to move this to the bottom?
|
src/providers/image-upscaling/upscaleImage.mts
CHANGED
@@ -4,13 +4,7 @@ import { client } from "@gradio/client"
|
|
4 |
import { getValidNumber } from "../../utils/validators/getValidNumber.mts"
|
5 |
|
6 |
// we don't use replicas yet, because it ain't easy to get their hostname
|
7 |
-
const
|
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 |
-
`${process.env.VC_UPSCALING_SPACE_API_URL_4 || ""}`,
|
12 |
-
`${process.env.VC_UPSCALING_SPACE_API_URL_5 || ""}`,
|
13 |
-
].filter(instance => instance?.length > 0)
|
14 |
|
15 |
// this doesn't work because of this error.. I think the version of Gradio is too old/young?
|
16 |
// ReferenceError: addEventListener is not defined
|
@@ -27,9 +21,6 @@ export async function upscaleImage(src: string, factor?: number) {
|
|
27 |
return src
|
28 |
}
|
29 |
|
30 |
-
const instance = instances.shift()
|
31 |
-
instances.push(instance)
|
32 |
-
|
33 |
const api = await client(instance, {
|
34 |
hf_token: `${process.env.VC_HF_API_TOKEN}` as any
|
35 |
})
|
|
|
4 |
import { getValidNumber } from "../../utils/validators/getValidNumber.mts"
|
5 |
|
6 |
// we don't use replicas yet, because it ain't easy to get their hostname
|
7 |
+
const instance = `${process.env.VC_UPSCALING_SPACE_API_URL || ""}`
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
// this doesn't work because of this error.. I think the version of Gradio is too old/young?
|
10 |
// ReferenceError: addEventListener is not defined
|
|
|
21 |
return src
|
22 |
}
|
23 |
|
|
|
|
|
|
|
24 |
const api = await client(instance, {
|
25 |
hf_token: `${process.env.VC_HF_API_TOKEN}` as any
|
26 |
})
|
src/providers/video-generation/generateVideoWithHotshotGradioAPI.mts
CHANGED
@@ -1,21 +1,9 @@
|
|
1 |
-
import { client } from "@gradio/client"
|
2 |
-
|
3 |
import { VideoGenerationOptions } from "./types.mts"
|
4 |
import { getNegativePrompt, getPositivePrompt } from "./defaultPrompts.mts"
|
5 |
import { generateSeed } from "../../utils/misc/generateSeed.mts"
|
6 |
|
7 |
// we don't use replicas yet, because it ain't easy to get their hostname
|
8 |
-
const
|
9 |
-
`${process.env.VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_1 || ""}`,
|
10 |
-
//`${process.env.VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_2 || ""}`,
|
11 |
-
//`${process.env.VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_3 || ""}`,
|
12 |
-
//`${process.env.VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_4 || ""}`,
|
13 |
-
//`${process.env.VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_5 || ""}`,
|
14 |
-
//`${process.env.VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_6 || ""}`,
|
15 |
-
//`${process.env.VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_7 || ""}`,
|
16 |
-
//`${process.env.VC_HOTSHOT_XL_GRADIO_SPACE_API_URL_8 || ""}`,
|
17 |
-
].filter(instance => instance?.length > 0)
|
18 |
-
|
19 |
const secretToken = `${process.env.VC_MICROSERVICE_SECRET_TOKEN || ""}`
|
20 |
|
21 |
export const generateVideo = async ({
|
@@ -32,13 +20,6 @@ export const generateVideo = async ({
|
|
32 |
|
33 |
huggingFaceLora = "jbilcke-hf/sdxl-cinematic-2",
|
34 |
}: VideoGenerationOptions) => {
|
35 |
-
|
36 |
-
const instance = instances.shift()
|
37 |
-
instances.push(instance)
|
38 |
-
|
39 |
-
const api = await client(instance, {
|
40 |
-
hf_token: `${process.env.VC_HF_API_TOKEN}` as any
|
41 |
-
})
|
42 |
|
43 |
// pimp the prompt
|
44 |
positivePrompt = getPositivePrompt(positivePrompt, triggerWord)
|
@@ -46,27 +27,43 @@ export const generateVideo = async ({
|
|
46 |
|
47 |
try {
|
48 |
|
49 |
-
const
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
} catch (err) {
|
70 |
throw err
|
71 |
}
|
72 |
-
}
|
|
|
|
|
|
|
1 |
import { VideoGenerationOptions } from "./types.mts"
|
2 |
import { getNegativePrompt, getPositivePrompt } from "./defaultPrompts.mts"
|
3 |
import { generateSeed } from "../../utils/misc/generateSeed.mts"
|
4 |
|
5 |
// we don't use replicas yet, because it ain't easy to get their hostname
|
6 |
+
const instance = `${process.env.VC_HOTSHOT_XL_GRADIO_SPACE_API_URL || ""}`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
const secretToken = `${process.env.VC_MICROSERVICE_SECRET_TOKEN || ""}`
|
8 |
|
9 |
export const generateVideo = async ({
|
|
|
20 |
|
21 |
huggingFaceLora = "jbilcke-hf/sdxl-cinematic-2",
|
22 |
}: VideoGenerationOptions) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
// pimp the prompt
|
25 |
positivePrompt = getPositivePrompt(positivePrompt, triggerWord)
|
|
|
27 |
|
28 |
try {
|
29 |
|
30 |
+
const res = await fetch(instance + (instance.endsWith("/") ? "" : "/") + "api/predict", {
|
31 |
+
method: "POST",
|
32 |
+
headers: {
|
33 |
+
"Content-Type": "application/json",
|
34 |
+
// Authorization: `Bearer ${token}`,
|
35 |
+
},
|
36 |
+
body: JSON.stringify({
|
37 |
+
fn_index: 1, // <- important!
|
38 |
+
data: [
|
39 |
+
secretToken,
|
40 |
+
positivePrompt,
|
41 |
+
negativePrompt,
|
42 |
+
huggingFaceLora,
|
43 |
+
size,
|
44 |
+
generateSeed(),
|
45 |
+
nbSteps,
|
46 |
+
nbFrames,
|
47 |
+
videoDuration,
|
48 |
+
],
|
49 |
+
}),
|
50 |
+
cache: "no-store",
|
51 |
+
// we can also use this (see https://vercel.com/blog/vercel-cache-api-nextjs-cache)
|
52 |
+
// next: { revalidate: 1 }
|
53 |
+
})
|
54 |
+
|
55 |
+
const { data } = await res.json()
|
56 |
+
|
57 |
+
// console.log("data:", data)
|
58 |
+
// Recommendation: handle errors
|
59 |
+
if (res.status !== 200 || !Array.isArray(data)) {
|
60 |
+
// This will activate the closest `error.js` Error Boundary
|
61 |
+
throw new Error(`Failed to fetch data (status: ${res.status})`)
|
62 |
+
}
|
63 |
+
// console.log("data:", data.slice(0, 50))
|
64 |
+
|
65 |
+
return data[0]
|
66 |
} catch (err) {
|
67 |
throw err
|
68 |
}
|
69 |
+
}
|