nami0342 commited on
Commit
eb6ea25
·
1 Parent(s): 50afb04

Update return type

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -34,6 +34,8 @@ from preprocess.humanparsing.run_parsing import Parsing
34
  from preprocess.openpose.run_openpose import OpenPose
35
  from detectron2.data.detection_utils import convert_PIL_to_numpy,_apply_exif_orientation
36
  from torchvision.transforms.functional import to_pil_image
 
 
37
 
38
  # For use ZeroGPU
39
  # device = 'cuda' if torch.cuda.is_available() else 'cpu'
@@ -309,7 +311,13 @@ async def vton_run(
309
  target_cloth = Image.open(io.BytesIO(await upload_cloth.read()))
310
 
311
  results = quick_tryon(target_human, target_cloth, input_prompt)
312
- return results[0]
 
 
 
 
 
 
313
 
314
 
315
  # image_blocks = gr.Blocks().queue()
 
34
  from preprocess.openpose.run_openpose import OpenPose
35
  from detectron2.data.detection_utils import convert_PIL_to_numpy,_apply_exif_orientation
36
  from torchvision.transforms.functional import to_pil_image
37
+ import base64
38
+ from io import BytesIO
39
 
40
  # For use ZeroGPU
41
  # device = 'cuda' if torch.cuda.is_available() else 'cpu'
 
311
  target_cloth = Image.open(io.BytesIO(await upload_cloth.read()))
312
 
313
  results = quick_tryon(target_human, target_cloth, input_prompt)
314
+
315
+ # Convert PIL Image to base64
316
+ buffered = BytesIO()
317
+ results[0].save(buffered, format="PNG")
318
+ img_str = base64.b64encode(buffered.getvalue()).decode()
319
+
320
+ return {"image": img_str}
321
 
322
 
323
  # image_blocks = gr.Blocks().queue()