Skip to content

Instantly share code, notes, and snippets.

@hu-qi
Last active July 22, 2023 16:14
Show Gist options
  • Save hu-qi/970ef765e7e987c42dd6083ee3273e8b to your computer and use it in GitHub Desktop.
Save hu-qi/970ef765e7e987c42dd6083ee3273e8b to your computer and use it in GitHub Desktop.
The UAV-Human dataset contains 155 action classes, and the action categories are listed below:
import os
import shutil
import json
import tqdm
def copy_files(source_dir='all_rgb',label='smoke'):
# 指定你想要扫描视频的目录
source_dir = './' + source_dir
# 指定你想要复制视频的目录
target_dir = './' + label
label_key = handle_label(label)
print(label_key)
if label_key == None:
return
# Check if source and target directories exist, if not create them
if not os.path.exists(source_dir):
os.makedirs(source_dir)
if not os.path.exists(target_dir):
os.makedirs(target_dir)
# 获取源目录中的所有文件
files = os.listdir(source_dir)
total_files = len(files)
# 遍历源目录中的所有文件
for i, filename in enumerate(tqdm.tqdm(files, desc="Copying files")):
# 检查文件名是否包含'A096'
if label_key in filename:
# 构造完整的文件路径
source = os.path.join(source_dir, filename)
target = os.path.join(target_dir, filename)
# 将文件复制到目标目录
shutil.copy2(source, target)
# 打印复制进度
print(f'复制进度: {((i+1)/total_files)*100:.2f}%')
print('已完成')
def handle_label(label):
# 从 label.json 文件中加载字典
with open('labels.json', 'r') as f:
dict = json.load(f)
key = next((k for k, v in dict.items() if v == label), None)
return key
# 默认创建smoke
# copy_files()
# 创建钓鱼: fishing
copy_files('all_rgb', 'fishing')
{
"A000": "drink",
"A001": "eat_snacks",
"A002": "brush_hair",
"A003": "drop_something",
"A004": "pick_up_something",
"A005": "throw_away_something",
"A006": "sit_down",
"A007": "stand_up",
"A008": "applaud",
"A009": "read",
"A010": "write",
"A011": "put_on_a_coat",
"A012": "take_off_a_coat",
"A013": "put_on_glasses",
"A014": "take_off_glasses",
"A015": "put_on_a_hat",
"A016": "take_off_a_hat",
"A017": "throw_away_a_hat",
"A018": "cheer",
"A019": "wave_hands",
"A020": "kick_something",
"A021": "reach_into_pockets",
"A022": "jump_on_single_leg",
"A023": "jump_on_two_legs",
"A024": "make_a_phone_call",
"A025": "play_with_cell_phones",
"A026": "point_somewhere",
"A027": "look_at_the_watch",
"A028": "rub_hands",
"A029": "bow",
"A030": "shake_head",
"A031": "salute",
"A032": "cross_palms_together",
"A033": "cross_arms_in_front_to_say_no",
"A034": "wear_headphones",
"A035": "take_off_headphones",
"A036": "make_a_shh_sign",
"A037": "touch_the_hair",
"A038": "thumb_up",
"A039": "thumb_down",
"A040": "make_an_OK_sign",
"A041": "make_a_victory_sign",
"A042": "punch_with_fists",
"A043": "figure_snap",
"A044": "open_the_bottle",
"A045": "smell",
"A046": "squat",
"A047": "apply_cream_to_face",
"A048": "apply_cream_to_hands",
"A049": "grasp_a_bag",
"A050": "put_down_a_bag",
"A051": "put_something_into_a_bag",
"A052": "take_something_out_of_a_bag",
"A053": "open_a_box",
"A054": "move_a_box",
"A055": "put_up_hands",
"A056": "put_hands_on_hips",
"A057": "wrap_arms_around",
"A058": "shake_arms",
"A059": "step_on_the_spot_walk",
"A060": "kick_aside",
"A061": "kick_backward",
"A062": "cough",
"A063": "sneeze",
"A064": "yawn",
"A065": "blow_nose",
"A066": "stagger",
"A067": "headache",
"A068": "chest_discomfort",
"A069": "backache",
"A070": "neck-ache",
"A071": "vomit",
"A072": "use_a_fan",
"A073": "stretch_body",
"A074": "punching_someone",
"A075": "kicking_someone",
"A076": "pushing_someone",
"A077": "slap_someone_on_the_back",
"A078": "point_someone",
"A079": "hug",
"A080": "give_something_to_someone",
"A081": "steal_something_from_other_pocket",
"A082": "rob_something_from_someone",
"A083": "shake_hands",
"A084": "walk_toward_someone",
"A085": "walk_away_from_someone",
"A086": "hit_someone_with_something",
"A087": "threat_some_with_a_knife",
"A088": "bump_into_someone",
"A089": "walk_side_by_side",
"A090": "high_five",
"A091": "drink_a_toast",
"A092": "move_something_with_someone",
"A093": "take_a_phone_for_someone",
"A094": "stalk_someone",
"A095": "whisper_in_someone_ear",
"A096": "exchange_something_with_someone",
"A097": "lend_an_arm_to_support_someone",
"A098": "rock-paper-scissors",
"A099": "hover",
"A100": "land",
"A101": "land_at_designated_locations",
"A102": "move_forward",
"A103": "move_backward",
"A104": "move_left",
"A105": "move_right",
"A106": "ascend",
"A107": "descend",
"A108": "accelerate",
"A109": "decelerate",
"A110": "come_over_here",
"A111": "stay_where_you_are",
"A112": "rear_right_turn",
"A113": "rear_left_turn",
"A114": "abandon_landing",
"A115": "all_clear",
"A116": "not_clear",
"A117": "have_command",
"A118": "follow_me",
"A119": "turn_left",
"A120": "turn_right",
"A121": "throw_litter",
"A122": "dig_a_hole",
"A123": "mow",
"A124": "set_on_fire",
"A125": "smoke",
"A126": "cut_the_tree",
"A127": "fishing",
"A128": "pick_a_lock",
"A129": "pollute_walls",
"A130": "hold_someone_hostage",
"A131": "threat_someone_with_a_gun",
"A132": "wave_a_goodbye",
"A133": "chase_someone",
"A134": "comfort_someone",
"A135": "drag_someone",
"A136": "sweep_the_floor",
"A137": "mop_the_floor",
"A138": "bounce_the_ball",
"A139": "shoot_at_the_basket",
"A140": "swing_the_racket",
"A141": "leg_pressing",
"A142": "escape_to_survive",
"A143": "call_for_help",
"A144": "wear_a_mask",
"A145": "take_off_a_mask",
"A146": "bend_arms_around_someone_shoulder",
"A147": "run",
"A148": "stab_someone_with_a_knife",
"A149": "throw_a_frisbee",
"A150": "carry_a_carrying_pole",
"A151": "use_a_lever_to_lift_something",
"A152": "walk",
"A153": "open_an_umbrella",
"A154": "close_an_umbrella"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment