Buckets:
| import pandas as pd | |
| data = pd.read_csv("OpenHumanVid_part_001.csv") | |
| import re | |
| # Patterns that indicate multiple characters | |
| multi_person_pattern = re.compile( | |
| r'\b(' | |
| r'two|three|four|five|six|seven|eight|nine|ten' | |
| r'|multiple|several|some|a few|a couple|a pair|a group|a crowd|a team|a gang|a duo' | |
| r'|both|together|each other|one another' | |
| r'|2|3|4|5|6|7|8|9' | |
| r')\b', | |
| re.IGNORECASE | |
| ) | |
| single_char_mask = ~data['caption'].str.contains(multi_person_pattern) | |
| single_char_data = data[single_char_mask].reset_index(drop=True) | |
| print(f"Original: {len(data):,} rows") | |
| print(f"Single character: {len(single_char_data):,} rows ({len(single_char_data)/len(data)*100:.1f}%)") | |
| single_char_data | |
| action_patterns = { | |
| 'talking': r'\b(talk(?:ing|s)?|speak(?:ing|s)?|chat(?:ting|s)?|convers(?:ing|ation)|address(?:ing)?|narrat(?:ing|es?)|monologue|lectur(?:ing|es?))\b', | |
| 'running': r'\b(runn(?:ing|s)?|jog(?:ging|s)?|sprint(?:ing|s)?|dash(?:ing|es)?)\b', | |
| 'walking': r'\b(walk(?:ing|s)?|stroll(?:ing|s)?|march(?:ing|es)?|saunter(?:ing)?|striding|strides?)\b', | |
| 'dancing': r'\b(danc(?:ing|es?|er)?|ballet|choreograph(?:y|ing)|twirl(?:ing)?|sway(?:ing)?)\b', | |
| 'fighting': r'\b(fight(?:ing|s)?|punch(?:ing|es)?|kick(?:ing|s)?|spar(?:ring)?|combat(?:ting)?|battle|martial arts?|box(?:ing)?)\b', | |
| 'singing': r'\b(sing(?:ing|s)?|sang|song|vocal(?:izing)?|perform(?:ing)? (?:a )?song)\b', | |
| 'sitting': r'\b(sit(?:ting|s)?|seated|sat down?|lounging|resting)\b', | |
| 'standing': r'\b(stand(?:ing|s)?|stood|upright|posing|poses?)\b', | |
| 'exercising': r'\b(exercis(?:ing|es?)|workout|work(?:ing)? out|gym|yoga|stretch(?:ing)?|lift(?:ing)? weights?|train(?:ing)?)\b', | |
| 'eating': r'\b(eat(?:ing|s)?|ate|dining|chew(?:ing)?|drinking|drink(?:ing|s)?)\b', | |
| } | |
| samples = {} | |
| for action, pattern in action_patterns.items(): | |
| matched = single_char_data[single_char_data['caption'].str.contains(pattern, case=False, regex=True)] | |
| n = min(100, len(matched)) | |
| samples[action] = matched.sample(n=n, random_state=42) if n > 0 else matched | |
| print(f"{action:12s}: {len(matched):5,} matches → {n} sampled") | |
| action_samples = pd.concat(samples.values(), keys=samples.keys()).rename_axis(['action', 'idx']).reset_index(level=0) | |
| action_samples = action_samples.reset_index(drop=True) | |
| print(f"\nTotal samples: {len(action_samples)}") | |
| action_samples[['action', 'clip_id', 'path', 'caption']] | |
| import shutil | |
| from pathlib import Path | |
| # CSV paths are "clips/part_001/..." but files live under BASE_DIR/part_001/... | |
| BASE_DIR = Path("/mnt/data/xinyuy/datasets/OpenHumanVid") | |
| OUT_DIR = BASE_DIR / "selected_2" | |
| copied, missing = 0, 0 | |
| for _, row in action_samples.iterrows(): | |
| # Strip the leading "clips/" prefix that doesn't exist on disk | |
| rel_path = row["path"].removeprefix("clips/") | |
| src = BASE_DIR / (rel_path + ".mp4") | |
| dst_dir = OUT_DIR / row["action"] | |
| dst_dir.mkdir(parents=True, exist_ok=True) | |
| dst = dst_dir / src.name | |
| if src.exists(): | |
| shutil.copy2(src, dst) | |
| copied += 1 | |
| else: | |
| print(f"[missing] {src}") | |
| missing += 1 | |
| print(f"\nDone — copied {copied} files, {missing} missing.") | |
| print(f"Output: {OUT_DIR}") | |
Xet Storage Details
- Size:
- 3.2 kB
- Xet hash:
- 60bb32d554ec61c1583c8fc4bba8a7336ce144bd5a13c2f79450d43664fa7f3d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.