Spaces:
Runtime error
Runtime error
update app.py
Browse files
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":
|
| 35 |
-
{"image":
|
| 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 |
)
|