Spaces:
Running
on
Zero
Running
on
Zero
update upload
Browse files- serve/upload.py +13 -13
serve/upload.py
CHANGED
|
@@ -104,19 +104,19 @@ def upload_ssh_all(states, output_dir, data, data_path):
|
|
| 104 |
image_list.append(states[i].output)
|
| 105 |
|
| 106 |
with sftp_client as sftp:
|
| 107 |
-
with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
json_data = json.dumps(data, indent=4)
|
| 121 |
with io.BytesIO(json_data.encode('utf-8')) as json_byte_stream:
|
| 122 |
sftp.putfo(json_byte_stream, data_path)
|
|
|
|
| 104 |
image_list.append(states[i].output)
|
| 105 |
|
| 106 |
with sftp_client as sftp:
|
| 107 |
+
# with concurrent.futures.ThreadPoolExecutor() as executor:
|
| 108 |
+
# futures = [executor.submit(upload_images, i, image_list, output_file_list, sftp_client) for i in range(len(output_file_list))]
|
| 109 |
+
|
| 110 |
+
for i in range(len(output_file_list)):
|
| 111 |
+
if isinstance(image_list[i], str):
|
| 112 |
+
print("get url image")
|
| 113 |
+
image_list[i] = get_image_from_url(image_list[i])
|
| 114 |
+
with io.BytesIO() as image_byte_stream:
|
| 115 |
+
image_list[i] = image_list[i].resize((512, 512), Image.ANTIALIAS)
|
| 116 |
+
image_list[i].save(image_byte_stream, format='JPEG')
|
| 117 |
+
image_byte_stream.seek(0)
|
| 118 |
+
sftp.putfo(image_byte_stream, output_file_list[i])
|
| 119 |
+
print(f"Successfully uploaded image to {output_file_list[i]}")
|
| 120 |
json_data = json.dumps(data, indent=4)
|
| 121 |
with io.BytesIO(json_data.encode('utf-8')) as json_byte_stream:
|
| 122 |
sftp.putfo(json_byte_stream, data_path)
|