English
Inference Endpoints
John6666 commited on
Commit
b62093b
·
verified ·
1 Parent(s): caaa793

Upload handler.py

Browse files
Files changed (1) hide show
  1. handler.py +2 -3
handler.py CHANGED
@@ -56,7 +56,7 @@ def pil_to_base64(image: Image.Image, modelname: str, prompt: str, height: int,
56
  info.add_text("metadata", json.dumps(metadata))
57
  buffered = BytesIO()
58
  image.save(buffered, "PNG", pnginfo=info)
59
- return base64.b64encode(buffered.getvalue())
60
 
61
  def load_te2(repo_id: str, dtype: torch.dtype) -> Any:
62
  if IS_4BIT:
@@ -222,7 +222,6 @@ class EndpointHandler:
222
  end = time.time()
223
  print(f'Elapsed {end - start:.3f} sec. / prompt:"{prompt}" / size:{width}x{height} / steps:{num_inference_steps} / guidance scale:{guidance_scale} / seed:{seed}')
224
 
225
- return image
226
- #return pil_to_base64(image, self.repo_id, prompt, height, width, num_inference_steps, guidance_scale, seed)
227
 
228
 
 
56
  info.add_text("metadata", json.dumps(metadata))
57
  buffered = BytesIO()
58
  image.save(buffered, "PNG", pnginfo=info)
59
+ return base64.b64encode(buffered.getvalue()).decode('ascii')
60
 
61
  def load_te2(repo_id: str, dtype: torch.dtype) -> Any:
62
  if IS_4BIT:
 
222
  end = time.time()
223
  print(f'Elapsed {end - start:.3f} sec. / prompt:"{prompt}" / size:{width}x{height} / steps:{num_inference_steps} / guidance scale:{guidance_scale} / seed:{seed}')
224
 
225
+ return pil_to_base64(image, self.repo_id, prompt, height, width, num_inference_steps, guidance_scale, seed)
 
226
 
227