Skip to content

Commit e464097

Browse files
committed
public links name column dtype fix
1 parent 7fc7034 commit e464097

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

superannotate/db/projects.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def _get_video_frames_count(video_path):
223223
return total_num_of_frames
224224

225225

226-
def _get_video_fps_ration(target_fps,video,ratio):
226+
def _get_video_fps_ration(target_fps, video, ratio):
227227
"""
228228
Get video fps / target fps ratio
229229
"""
@@ -232,7 +232,7 @@ def _get_video_fps_ration(target_fps,video,ratio):
232232
logger.warning(
233233
"Video frame rate %s smaller than target frame rate %s. Cannot change frame rate.",
234234
video_fps, target_fps
235-
)
235+
)
236236
else:
237237
logger.info(
238238
"Changing video frame rate from %s to target frame rate %s.",
@@ -241,22 +241,24 @@ def _get_video_fps_ration(target_fps,video,ratio):
241241
ratio = video_fps / target_fps
242242
return ratio
243243

244-
def _get_available_image_counts(project,folder):
244+
245+
def _get_available_image_counts(project, folder):
245246
if folder:
246247
folder_id = folder["id"]
247248
else:
248249
folder_id = get_project_root_folder_id(project)
249-
params = {'team_id': project['team_id'] , 'folder_id' : folder_id }
250-
res = _get_upload_auth_token(params=params,project_id=project['id'])
250+
params = {'team_id': project['team_id'], 'folder_id': folder_id}
251+
res = _get_upload_auth_token(params=params, project_id=project['id'])
251252
return res['availableImageCount']
252253

254+
253255
def _get_video_rotate_code(video_path):
254256
rotate_code = None
255257
try:
256258
cv2_rotations = {
257-
90 : cv2.ROTATE_90_CLOCKWISE,
258-
180 : cv2.ROTATE_180,
259-
270 :cv2.ROTATE_90_COUNTERCLOCKWISE,
259+
90: cv2.ROTATE_90_CLOCKWISE,
260+
180: cv2.ROTATE_180,
261+
270: cv2.ROTATE_90_COUNTERCLOCKWISE,
260262
}
261263

262264
meta_dict = ffmpeg.probe(str(video_path))
@@ -278,14 +280,17 @@ def _get_video_rotate_code(video_path):
278280
return rotate_code
279281

280282

281-
def _extract_frames_from_video(start_time,end_time,ratio,video,video_path,tempdir,limit,rotate_code,total_num_of_frames):
283+
def _extract_frames_from_video(
284+
start_time, end_time, ratio, video, video_path, tempdir, limit, rotate_code,
285+
total_num_of_frames
286+
):
282287
video_name = Path(video_path).stem
283288
frame_no = 0
284289
frame_no_with_change = 1.0
285290
extracted_frame_no = 1
286291
logger.info("Extracting frames from video to %s.", tempdir.name)
287292
zero_fill_count = len(str(total_num_of_frames))
288-
while extracted_frame_no < (limit + 1) :
293+
while extracted_frame_no < (limit + 1):
289294
success, frame = video.read()
290295
if not success:
291296
break
@@ -347,7 +352,7 @@ def upload_video_to_project(
347352
"""
348353

349354
project, folder = get_project_and_folder_metadata(project)
350-
limit = _get_available_image_counts(project,folder)
355+
limit = _get_available_image_counts(project, folder)
351356

352357
upload_state = common.upload_state_int_to_str(project.get("upload_state"))
353358
if upload_state == "External":
@@ -365,11 +370,12 @@ def upload_video_to_project(
365370
logger.info("Video frame count is %s.", total_num_of_frames)
366371
ratio = 1.0
367372
if target_fps:
368-
ratio = _get_video_fps_ration(target_fps,video,ratio)
373+
ratio = _get_video_fps_ration(target_fps, video, ratio)
369374
tempdir = tempfile.TemporaryDirectory()
370-
extracted_frame_no = _extract_frames_from_video(start_time,end_time,ratio,
371-
video,video_path,tempdir,
372-
limit,rotate_code,total_num_of_frames)
375+
extracted_frame_no = _extract_frames_from_video(
376+
start_time, end_time, ratio, video, video_path, tempdir, limit,
377+
rotate_code, total_num_of_frames
378+
)
373379
logger.info(
374380
"Extracted %s frames from video. Now uploading to platform.",
375381
extracted_frame_no
@@ -855,9 +861,7 @@ def upload_images_to_project(
855861
:rtype: tuple (3 members) of list of strs
856862
"""
857863
project, folder = get_project_and_folder_metadata(project)
858-
folder_name = project["name"] + (
859-
f'/{folder["name"]}' if folder else ""
860-
)
864+
folder_name = project["name"] + (f'/{folder["name"]}' if folder else "")
861865
upload_state = common.upload_state_int_to_str(project.get("upload_state"))
862866
if upload_state == "External":
863867
raise SABaseException(
@@ -897,19 +901,18 @@ def upload_images_to_project(
897901
if len_img_paths == 0:
898902
return ([], [], duplicate_images)
899903

900-
901904
if folder:
902905
folder_id = folder["id"]
903906
else:
904907
folder_id = get_project_root_folder_id(project)
905908

906-
params = {'team_id': team_id , 'folder_id' : folder_id }
909+
params = {'team_id': team_id, 'folder_id': folder_id}
907910
uploaded = [[] for _ in range(_NUM_THREADS)]
908911
tried_upload = [[] for _ in range(_NUM_THREADS)]
909912
couldnt_upload = [[] for _ in range(_NUM_THREADS)]
910913
finish_event = threading.Event()
911914

912-
res = _get_upload_auth_token(params=params,project_id=project_id)
915+
res = _get_upload_auth_token(params=params, project_id=project_id)
913916

914917
prefix = res['filePath']
915918
limit = res['availableImageCount']
@@ -929,8 +932,8 @@ def upload_images_to_project(
929932
t = threading.Thread(
930933
target=__upload_images_to_aws_thread,
931934
args=(
932-
res, images_to_upload, project, annotation_status, prefix, thread_id,
933-
chunksize, couldnt_upload, uploaded, tried_upload,
935+
res, images_to_upload, project, annotation_status, prefix,
936+
thread_id, chunksize, couldnt_upload, uploaded, tried_upload,
934937
image_quality_in_editor, from_s3_bucket, folder_id
935938
),
936939
daemon=True
@@ -989,9 +992,7 @@ def attach_image_urls_to_project(
989992
"""
990993

991994
project, folder = get_project_and_folder_metadata(project)
992-
folder_name = project["name"] + (
993-
f'/{folder["name"]}' if folder else ""
994-
)
995+
folder_name = project["name"] + (f'/{folder["name"]}' if folder else "")
995996
upload_state = common.upload_state_int_to_str(project.get("upload_state"))
996997
if upload_state == "Basic":
997998
raise SABaseException(
@@ -1000,7 +1001,7 @@ def attach_image_urls_to_project(
10001001
)
10011002
annotation_status = common.annotation_status_str_to_int(annotation_status)
10021003
team_id, project_id = project["team_id"], project["id"]
1003-
image_data = pd.read_csv(attachments)
1004+
image_data = pd.read_csv(attachments, dtype=str)
10041005
image_data = image_data[~image_data["url"].isnull()]
10051006
existing_names = image_data[~image_data["name"].isnull()]
10061007
duplicate_idx_csv = existing_names.duplicated(subset="name", keep="first")
@@ -1029,8 +1030,7 @@ def attach_image_urls_to_project(
10291030
image_data = pd.DataFrame(image_data, columns=["name", "url"])
10301031
img_names_urls = image_data.values.tolist()
10311032
logger.info(
1032-
"Uploading %s images to project %s.", len(img_names_urls),
1033-
folder_name
1033+
"Uploading %s images to project %s.", len(img_names_urls), folder_name
10341034
)
10351035
if len(img_names_urls) == 0:
10361036
return ([], [], duplicate_images)
@@ -1040,14 +1040,14 @@ def attach_image_urls_to_project(
10401040
else:
10411041
folder_id = get_project_root_folder_id(project)
10421042

1043-
params = {'team_id': team_id , 'folder_id' : folder_id }
1043+
params = {'team_id': team_id, 'folder_id': folder_id}
10441044
uploaded = [[] for _ in range(_NUM_THREADS)]
10451045
tried_upload = [[] for _ in range(_NUM_THREADS)]
10461046
couldnt_upload = [[] for _ in range(_NUM_THREADS)]
10471047
finish_event = threading.Event()
10481048

1049-
res = _get_upload_auth_token(params=params,project_id=project_id)
1050-
1049+
res = _get_upload_auth_token(params=params, project_id=project_id)
1050+
10511051
prefix = res['filePath']
10521052
limit = res['availableImageCount']
10531053
images_to_upload = img_names_urls[:limit]
@@ -1086,7 +1086,7 @@ def attach_image_urls_to_project(
10861086
for f in upload_thread:
10871087
list_of_uploaded.append(str(f))
10881088

1089-
list_of_not_uploaded += [i[0] for i in images_to_skip ]
1089+
list_of_not_uploaded += [i[0] for i in images_to_skip]
10901090
return (list_of_uploaded, list_of_not_uploaded, duplicate_images)
10911091

10921092

0 commit comments

Comments
 (0)