jbilcke-hf HF staff commited on
Commit
72947d4
β€’
1 Parent(s): 49c4208

fix SDXL rendering

Browse files
Files changed (1) hide show
  1. src/app/engine/render.ts +13 -4
src/app/engine/render.ts CHANGED
@@ -99,6 +99,13 @@ export async function newRender({
99
  ? huggingFaceInferenceEndpointUrl
100
  : `https://api-inference.huggingface.co/models/${huggingFaceInferenceApiModel}`
101
 
 
 
 
 
 
 
 
102
  const res = await fetch(url, {
103
  method: "POST",
104
  headers: {
@@ -132,11 +139,13 @@ export async function newRender({
132
  // This will activate the closest `error.js` Error Boundary
133
  throw new Error('Failed to fetch data')
134
  }
135
-
136
- // the result is a JSON-encoded string
137
- const response = await res.json() as string
138
- const assetUrl = `data:image/png;base64,${response}`
139
 
 
 
 
 
 
 
140
  return {
141
  renderId: uuidv4(),
142
  status: "completed",
 
99
  ? huggingFaceInferenceEndpointUrl
100
  : `https://api-inference.huggingface.co/models/${huggingFaceInferenceApiModel}`
101
 
102
+ console.log(`calling ${url} with params: `, {
103
+ num_inference_steps: 25,
104
+ guidance_scale: 8,
105
+ width,
106
+ height,
107
+ })
108
+
109
  const res = await fetch(url, {
110
  method: "POST",
111
  headers: {
 
139
  // This will activate the closest `error.js` Error Boundary
140
  throw new Error('Failed to fetch data')
141
  }
 
 
 
 
142
 
143
+ const blob = await res.arrayBuffer()
144
+
145
+ const contentType = res.headers.get('content-type')
146
+
147
+ const assetUrl = `data:${contentType};base64,${Buffer.from(blob).toString('base64')}`
148
+
149
  return {
150
  renderId: uuidv4(),
151
  status: "completed",