Spaces:
Runtime error
Runtime error
Commit Β·
1ec0842
1
Parent(s): 0a0844b
update: revert to image upload
Browse files
app.py
CHANGED
|
@@ -23,6 +23,15 @@ def clear_func():
|
|
| 23 |
gc.collect()
|
| 24 |
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
@spaces.GPU
|
| 27 |
def clothing_try_on(image, mask):
|
| 28 |
jewellery_mask = Image.fromarray(
|
|
@@ -76,7 +85,7 @@ def clothing_try_on(image, mask):
|
|
| 76 |
|
| 77 |
def base64_to_image(base64_str):
|
| 78 |
image_data = base64.b64decode(base64_str)
|
| 79 |
-
image = Image.open(BytesIO(image_data))
|
| 80 |
return image
|
| 81 |
|
| 82 |
|
|
@@ -95,7 +104,6 @@ def clothing_try_on_base64(input_image_base64, mask_image_base64):
|
|
| 95 |
return image_to_base64(output_image)
|
| 96 |
|
| 97 |
|
| 98 |
-
|
| 99 |
def launch_interface_base64():
|
| 100 |
with gr.Blocks() as interface:
|
| 101 |
with gr.Row():
|
|
@@ -106,8 +114,9 @@ def launch_interface_base64():
|
|
| 106 |
submit = gr.Button("Apply")
|
| 107 |
|
| 108 |
submit.click(fn=clothing_try_on_base64, inputs=[inputImage, maskImage], outputs=[outputOne])
|
|
|
|
| 109 |
interface.launch(debug=True)
|
| 110 |
|
| 111 |
|
| 112 |
if __name__ == "__main__":
|
| 113 |
-
launch_interface_base64()
|
|
|
|
| 23 |
gc.collect()
|
| 24 |
|
| 25 |
|
| 26 |
+
def process_mask(mask):
|
| 27 |
+
mask = mask.convert("L")
|
| 28 |
+
mask = np.array(mask)
|
| 29 |
+
|
| 30 |
+
mask = np.where(mask > 128, 255, 0).astype(np.uint8)
|
| 31 |
+
|
| 32 |
+
return Image.fromarray(mask)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
@spaces.GPU
|
| 36 |
def clothing_try_on(image, mask):
|
| 37 |
jewellery_mask = Image.fromarray(
|
|
|
|
| 85 |
|
| 86 |
def base64_to_image(base64_str):
|
| 87 |
image_data = base64.b64decode(base64_str)
|
| 88 |
+
image = Image.open(BytesIO(image_data))
|
| 89 |
return image
|
| 90 |
|
| 91 |
|
|
|
|
| 104 |
return image_to_base64(output_image)
|
| 105 |
|
| 106 |
|
|
|
|
| 107 |
def launch_interface_base64():
|
| 108 |
with gr.Blocks() as interface:
|
| 109 |
with gr.Row():
|
|
|
|
| 114 |
submit = gr.Button("Apply")
|
| 115 |
|
| 116 |
submit.click(fn=clothing_try_on_base64, inputs=[inputImage, maskImage], outputs=[outputOne])
|
| 117 |
+
|
| 118 |
interface.launch(debug=True)
|
| 119 |
|
| 120 |
|
| 121 |
if __name__ == "__main__":
|
| 122 |
+
launch_interface_base64()
|