jbilcke-hf HF staff commited on
Commit
bdccaf0
β€’
1 Parent(s): ec194c9

try 3 servers

Browse files
src/production/renderImage.mts CHANGED
@@ -26,8 +26,7 @@ export async function renderImage(
26
 
27
  // console.log(`calling generateImageAsBase64 with: `, JSON.stringify(params, null, 2))
28
 
29
-
30
- // first we generate a quick low quality version
31
  try {
32
  response.assetUrl = await generateImageAsBase64(params)
33
  // console.log("successful generation!", response.assetUrl.slice(0, 30))
@@ -43,10 +42,18 @@ export async function renderImage(
43
  throw new Error(`the generated image is empty`)
44
  }
45
  } catch (err) {
46
- console.error(`failed to generate the image, although ${err}`)
47
- response.error = `failed to render scene: ${err}`
48
- response.status = "error"
49
- response.assetUrl = ""
 
 
 
 
 
 
 
 
50
  }
51
  }
52
 
 
26
 
27
  // console.log(`calling generateImageAsBase64 with: `, JSON.stringify(params, null, 2))
28
 
29
+ // we try at least 3 different servers
 
30
  try {
31
  response.assetUrl = await generateImageAsBase64(params)
32
  // console.log("successful generation!", response.assetUrl.slice(0, 30))
 
42
  throw new Error(`the generated image is empty`)
43
  }
44
  } catch (err) {
45
+ try {
46
+ response.assetUrl = await generateImageAsBase64(params)
47
+ // console.log("successful generation!", response.assetUrl.slice(0, 30))
48
+ if (!response.assetUrl?.length) {
49
+ throw new Error(`the generated image is empty`)
50
+ }
51
+ } catch (err) {
52
+ console.error(`failed to generate the image, although ${err}`)
53
+ response.error = `failed to render scene: ${err}`
54
+ response.status = "error"
55
+ response.assetUrl = ""
56
+ }
57
  }
58
  }
59
 
src/providers/image-generation/generateImageSDXL.mts CHANGED
@@ -3,6 +3,10 @@ import { client } from "@gradio/client"
3
  import { generateSeed } from "../../utils/misc/generateSeed.mts"
4
  import { getValidNumber } from "../../utils/validators/getValidNumber.mts"
5
 
 
 
 
 
6
  // note: to reduce costs I use the small A10s (not the large)
7
  // anyway, we will soon not need to use this cloud anymore
8
  // since we will be able to leverage the Inference API
 
3
  import { generateSeed } from "../../utils/misc/generateSeed.mts"
4
  import { getValidNumber } from "../../utils/validators/getValidNumber.mts"
5
 
6
+ // TODO add a system to mark failed instances as "unavailable" for a couple of minutes
7
+
8
+
9
+
10
  // note: to reduce costs I use the small A10s (not the large)
11
  // anyway, we will soon not need to use this cloud anymore
12
  // since we will be able to leverage the Inference API