insideman commited on
Commit
4b786d5
·
verified ·
1 Parent(s): 6eab177

update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import PIL.Image
4
  import io
 
5
 
6
  # Initialize the Hugging Face client
7
  HF_TOKEN = "your_token_here" # Replace with your token
@@ -27,12 +28,16 @@ def virtual_try_on(person_image, garment_image):
27
  person_image.save(person_bytes, format='PNG')
28
  garment_image.save(garment_bytes, format='PNG')
29
 
 
 
 
 
30
  # Make API request
31
  response = client.post(
32
  json={
33
  "inputs": [
34
- {"image": person_bytes.getvalue()},
35
- {"image": garment_bytes.getvalue()}
36
  ]
37
  }
38
  )
 
2
  from huggingface_hub import InferenceClient
3
  import PIL.Image
4
  import io
5
+ import base64
6
 
7
  # Initialize the Hugging Face client
8
  HF_TOKEN = "your_token_here" # Replace with your token
 
28
  person_image.save(person_bytes, format='PNG')
29
  garment_image.save(garment_bytes, format='PNG')
30
 
31
+ # Convert bytes to base64
32
+ person_b64 = base64.b64encode(person_bytes.getvalue()).decode('utf-8')
33
+ garment_b64 = base64.b64encode(garment_bytes.getvalue()).decode('utf-8')
34
+
35
  # Make API request
36
  response = client.post(
37
  json={
38
  "inputs": [
39
+ {"image": person_b64},
40
+ {"image": garment_b64}
41
  ]
42
  }
43
  )