Skip to content

Commit cd3754e

Browse files
committed
Fix upload image misreport
1 parent 4ec3df2 commit cd3754e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

superannotate/db/projects.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,8 @@ def get_image_array_to_upload(
639639

640640
def __upload_images_to_aws_thread(
641641
res, img_paths, project, annotation_status, prefix, thread_id, chunksize,
642-
couldnt_upload, uploaded, image_quality_in_editor, from_s3_bucket
642+
couldnt_upload, uploaded, tried_upload, image_quality_in_editor,
643+
from_s3_bucket
643644
):
644645
len_img_paths = len(img_paths)
645646
start_index = thread_id * chunksize
@@ -686,7 +687,6 @@ def __upload_images_to_aws_thread(
686687
couldnt_upload[thread_id].append(path)
687688
continue
688689
else:
689-
uploaded[thread_id].append(path)
690690
uploaded_imgs.append(path)
691691
uploaded_imgs_info[0].append(Path(path).name)
692692
uploaded_imgs_info[1].append(key)
@@ -696,12 +696,15 @@ def __upload_images_to_aws_thread(
696696
uploaded_imgs_info[0], uploaded_imgs_info[1], project,
697697
annotation_status, prefix, uploaded_imgs_info[2]
698698
)
699+
uploaded[thread_id] += uploaded_imgs
699700
uploaded_imgs = []
700701
uploaded_imgs_info = ([], [], [])
702+
tried_upload[thread_id].append(path)
701703
__create_image(
702704
uploaded_imgs_info[0], uploaded_imgs_info[1], project,
703705
annotation_status, prefix, uploaded_imgs_info[2]
704706
)
707+
uploaded[thread_id] += uploaded_imgs
705708

706709

707710
def __create_image(
@@ -809,6 +812,7 @@ def upload_images_to_project(
809812
uploaded = []
810813
for _ in range(_NUM_THREADS):
811814
uploaded.append([])
815+
tried_upload = [[] for _ in range(_NUM_THREADS)]
812816
couldnt_upload = []
813817
for _ in range(_NUM_THREADS):
814818
couldnt_upload.append([])
@@ -826,8 +830,8 @@ def upload_images_to_project(
826830
res = response.json()
827831
prefix = res['filePath']
828832
tqdm_thread = threading.Thread(
829-
target=__tqdm_thread_upload,
830-
args=(len_img_paths, uploaded, couldnt_upload, finish_event),
833+
target=__tqdm_thread_image_upload,
834+
args=(len_img_paths, tried_upload, finish_event),
831835
daemon=True
832836
)
833837
tqdm_thread.start()
@@ -838,8 +842,8 @@ def upload_images_to_project(
838842
target=__upload_images_to_aws_thread,
839843
args=(
840844
res, img_paths, project, annotation_status, prefix, thread_id,
841-
chunksize, couldnt_upload, uploaded, image_quality_in_editor,
842-
from_s3_bucket
845+
chunksize, couldnt_upload, uploaded, tried_upload,
846+
image_quality_in_editor, from_s3_bucket
843847
),
844848
daemon=True
845849
)
@@ -1438,15 +1442,13 @@ def _upload_annotations_from_folder_to_project(
14381442
return (list_of_uploaded, list_of_not_uploaded, list_of_missing_images)
14391443

14401444

1441-
def __tqdm_thread_upload(total_num, uploaded, couldnt_upload, finish_event):
1445+
def __tqdm_thread_image_upload(total_num, tried_upload, finish_event):
14421446
with tqdm(total=total_num) as pbar:
14431447
while True:
14441448
finished = finish_event.wait(_TIME_TO_UPDATE_IN_TQDM)
14451449
if not finished:
14461450
sum_all = 0
1447-
for i in couldnt_upload:
1448-
sum_all += len(i)
1449-
for i in uploaded:
1451+
for i in tried_upload:
14501452
sum_all += len(i)
14511453
pbar.update(sum_all - pbar.n)
14521454
else:

0 commit comments

Comments
 (0)