본문 바로가기
딥러닝

kinetics 600 데이터셋 비디오 특정클래스만 다운받기

by jennyiscoding 2024. 12. 11.

경로:

https://github.com/cvdfoundation/kinetics-dataset/blob/main/k600_downloader.sh

 

kinetics-dataset/k600_downloader.sh at main · cvdfoundation/kinetics-dataset

Contribute to cvdfoundation/kinetics-dataset development by creating an account on GitHub.

github.com

 

안에 내용:

#!/bin/bash

# Download directories vars
root_dl="k600"
root_dl_targz="k600_targz"

# Make root directories
[ ! -d $root_dl ] && mkdir $root_dl
[ ! -d $root_dl_targz ] && mkdir $root_dl_targz

# Download train tars, will resume
curr_dl=${root_dl_targz}/train
url=https://s3.amazonaws.com/kinetics/600/train/k600_train_path.txt
[ ! -d $curr_dl ] && mkdir -p $curr_dl
wget -c -i $url -P $curr_dl

# Download validation tars, will resume
curr_dl=${root_dl_targz}/val
url=https://s3.amazonaws.com/kinetics/600/val/k600_val_path.txt
[ ! -d $curr_dl ] && mkdir -p $curr_dl
wget -c -i $url -P $curr_dl

# Download test tars, will resume
curr_dl=${root_dl_targz}/test
url=https://s3.amazonaws.com/kinetics/600/test/k600_test_path.txt
[ ! -d $curr_dl ] && mkdir -p $curr_dl
wget -c -i $url -P $curr_dl

# Download annotations csv files
curr_dl=${root_dl}/annotations
url_tr=https://s3.amazonaws.com/kinetics/600/annotations/train.txt
url_v=https://s3.amazonaws.com/kinetics/600/annotations/val.txt
url_t=https://s3.amazonaws.com/kinetics/600/annotations/test.csv
url_ht=https://s3.amazonaws.com/kinetics/600/annotations/kinetics600_holdout_test.csv
[ ! -d $curr_dl ] && mkdir -p $curr_dl
wget -c $url_tr -P $curr_dl
wget -c $url_v -P $curr_dl
wget -c $url_t -P $curr_dl
wget -c $url_ht -P $curr_dl

# Download readme
url=http://s3.amazonaws.com/kinetics/600/readme.md
wget -c $url -P $root_dl

# Downloads complete
echo -e "\nDownloads complete! Now run extractor, k600_extractor.sh"

 

여기에 가보면 ->https://s3.amazonaws.com/kinetics/600/train/k600_train_path.txt

경로와 파일의 종류들이 나온다. 

 

falling off chair, falling off bike, punching person (boxing)를 detection할꺼니까 이걸 치고 다운받아본다. 

train용:

https://s3.amazonaws.com/kinetics/600/train/falling off chair.tar.gz
https://s3.amazonaws.com/kinetics/600/train/falling off chair.tar.gz
https://s3.amazonaws.com/kinetics/600/train/punching person (boxing).tar.gz

 

valid용:

https://s3.amazonaws.com/kinetics/600/val/falling off bike.tar.gz
https://s3.amazonaws.com/kinetics/600/val/falling off chair.tar.
https://s3.amazonaws.com/kinetics/600/val/punching person (boxing).tar.gz

 

이것만 다운받으면 된다! 

 

다운받기 위해 만든 코드(k600_downloader_fall.sh)

# Download directories vars
root_dl="k600"
root_dl_targz="k600_targz"

# Make root directories
[ ! -d $root_dl ] && mkdir $root_dl
[ ! -d $root_dl_targz ] && mkdir $root_dl_targz

# Function to download files
download_tars() {
	local TARGET_DIR=$1      # 다운로드 대상 디렉토리
	local URL_FILE=$2        # 다운로드 URL이 포함된 파일

	# URL 파일이 존재하는지 확인
	if [ ! -f "$URL_FILE" ]; then
		echo "Error: URL file '$URL_FILE' not found."
		exit 1
	fi

	# 다운로드 디렉토리 생성
	[ ! -d "$TARGET_DIR" ] && mkdir -p "$TARGET_DIR"

	# 다운로드 실행
	echo "Downloading files listed in '$URL_FILE' to '$TARGET_DIR'..."
	wget -c -i "$URL_FILE" -P "$TARGET_DIR"

	if [ $? -eq 0 ]; then
		echo "Download completed successfully for '$URL_FILE'."
	else
		echo "Error: Download failed for '$URL_FILE'."
		exit 1
	fi
}

# Download train tars (falling-related classes)
TRAIN_URL_FILE="./k600_dataset_train_fall.txt" # 총 849 MB
TRAIN_DIR="${ROOT_DIR_TARGZ}/train"
download_tars "$TRAIN_DIR" "$TRAIN_URL_FILE"

# Download validation tars (falling-related classes)
VAL_URL_FILE="./k600_dataset_valid_fall.txt" # 39 MB
VAL_DIR="${ROOT_DIR_TARGZ}/val"
download_tars "$VAL_DIR" "$VAL_URL_FILE"

echo "All downloads completed successfully."

# 현재 남은 용량: 522 GB
# df- h로 확인함

 

실행방법: ./k600_downloader_fall.sh

 

k600_dataset_train_fall.txt는

https://s3.amazonaws.com/kinetics/600/train/falling off chair.tar.gz
https://s3.amazonaws.com/kinetics/600/train/falling off chair.tar.gz
https://s3.amazonaws.com/kinetics/600/train/punching person (boxing).tar.gz