Spaces:
Paused
Paused
Update run/gradio_ootd.py
Browse files- run/gradio_ootd.py +18 -5
run/gradio_ootd.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
from flask import Flask, request, jsonify
|
2 |
import torch
|
3 |
from PIL import Image, ImageOps
|
4 |
-
|
5 |
from utils_ootd import get_mask_location
|
6 |
from preprocess.openpose.run_openpose import OpenPose
|
7 |
from preprocess.humanparsing.run_parsing import Parsing
|
@@ -69,7 +69,14 @@ def process_hd():
|
|
69 |
seed=seed,
|
70 |
)
|
71 |
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
@app.route("/process_dc", methods=["POST"])
|
75 |
def process_dc():
|
@@ -120,8 +127,14 @@ def process_dc():
|
|
120 |
image_scale=image_scale,
|
121 |
seed=seed,
|
122 |
)
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
if __name__ == "__main__":
|
127 |
app.run(host="0.0.0.0", port=7860)
|
|
|
1 |
+
from flask import Flask, request, jsonify , send_file
|
2 |
import torch
|
3 |
from PIL import Image, ImageOps
|
4 |
+
import base64
|
5 |
from utils_ootd import get_mask_location
|
6 |
from preprocess.openpose.run_openpose import OpenPose
|
7 |
from preprocess.humanparsing.run_parsing import Parsing
|
|
|
69 |
seed=seed,
|
70 |
)
|
71 |
|
72 |
+
base64_images = []
|
73 |
+
for img in images:
|
74 |
+
buffered = BytesIO()
|
75 |
+
img.save(buffered, format="JPEG")
|
76 |
+
img_str = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
77 |
+
base64_images.append(img_str)
|
78 |
+
|
79 |
+
return jsonify(images=base64_images)
|
80 |
|
81 |
@app.route("/process_dc", methods=["POST"])
|
82 |
def process_dc():
|
|
|
127 |
image_scale=image_scale,
|
128 |
seed=seed,
|
129 |
)
|
130 |
+
base64_images = []
|
131 |
+
for img in images:
|
132 |
+
buffered = BytesIO()
|
133 |
+
img.save(buffered, format="JPEG")
|
134 |
+
img_str = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
135 |
+
base64_images.append(img_str)
|
136 |
+
|
137 |
+
return jsonify(images=base64_images)
|
138 |
|
139 |
if __name__ == "__main__":
|
140 |
app.run(host="0.0.0.0", port=7860)
|