Added download with train, test, val
This commit is contained in:
@@ -128,17 +128,22 @@ async def download_all(category_id: int, background_tasks: BackgroundTasks, Auth
|
||||
category_signs = c.signs
|
||||
|
||||
# get all the paths of the sign videos
|
||||
paths = []
|
||||
all_videos = []
|
||||
for sign in category_signs:
|
||||
for video in sign.sign_videos:
|
||||
paths.append(video.path)
|
||||
all_videos.append(video)
|
||||
|
||||
zip_path = f"/tmp/{datetime.datetime.now().timestamp()}.zip"
|
||||
|
||||
# create the zip file
|
||||
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED, False) as zip_file:
|
||||
for path in paths:
|
||||
zip_file.write(f"{settings.DATA_PATH}/{path}", os.path.basename(path))
|
||||
for video in all_videos:
|
||||
splitted = os.path.basename(video.path).split("!")
|
||||
# insert the dataset name at index 1
|
||||
splitted.insert(1, video.dataset)
|
||||
# join the splitted list to a string
|
||||
new_name = "!".join(splitted)
|
||||
zip_file.write(f"{settings.DATA_PATH}/{video.path}", new_name)
|
||||
|
||||
background_tasks.add_task(delete_zip_file, zip_path)
|
||||
# serve the zip file as the response
|
||||
|
||||
Reference in New Issue
Block a user