Download combine_metadata.py from mukul54/motion-text-classifier-v2: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/datasets/mukul54/motion-text-classifier-v2/resolve/main/combine_metadata.py
- Command line
-
hf download hf://datasets/mukul54/motion-text-classifier-v2/combine_metadata.py
-
curl -L -o combine_metadata.py https://huggingface.co/datasets/mukul54/motion-text-classifier-v2/resolve/main/combine_metadata.py
1.75 kB
| import pandas as pd | |
| from pathlib import Path | |
| # Configuration parameters used in generation | |
| CONFIG = { | |
| 'noise_density': 0.5, | |
| 'speckle_size': 1, | |
| 'speed': 2, | |
| 'direction': 'horizontal', | |
| 'fps': 60, | |
| 'resolution': '960x540' | |
| } | |
| # Read motion_only metadata | |
| motion_df = pd.read_csv('train/motion_only/metadata.csv') | |
| motion_df['file_name'] = 'motion_only/' + motion_df['filename'] | |
| motion_df['category'] = 'motion_only' | |
| # Read text_fg_bg metadata | |
| text_df = pd.read_csv('train/text_fg_bg/metadata.csv') | |
| text_df['file_name'] = 'text_fg_bg/' + text_df['filename'] | |
| text_df['category'] = 'text_fg_bg' | |
| # Combine | |
| combined_df = pd.concat([motion_df, text_df], ignore_index=True) | |
| # Add configuration columns | |
| combined_df['noise_density'] = CONFIG['noise_density'] | |
| combined_df['speckle_size'] = CONFIG['speckle_size'] | |
| combined_df['speed'] = CONFIG['speed'] | |
| combined_df['direction'] = CONFIG['direction'] | |
| combined_df['fps'] = CONFIG['fps'] | |
| combined_df['resolution'] = CONFIG['resolution'] | |
| # Reorder columns | |
| column_order = [ | |
| 'file_name', | |
| 'category', | |
| 'label', | |
| 'text', | |
| 'duration', | |
| 'num_frames', | |
| 'noise_density', | |
| 'speckle_size', | |
| 'speed', | |
| 'direction', | |
| 'fps', | |
| 'resolution' | |
| ] | |
| # Only keep columns that exist | |
| column_order = [col for col in column_order if col in combined_df.columns] | |
| combined_df = combined_df[column_order] | |
| # Save combined metadata | |
| combined_df.to_csv('train/metadata.csv', index=False) | |
| print(f"✓ Combined metadata saved to train/metadata.csv") | |
| print(f" Total samples: {len(combined_df)}") | |
| print(f" Motion-only: {len(motion_df)}") | |
| print(f" Text videos: {len(text_df)}") | |
| print(f"\nColumns: {', '.join(combined_df.columns)}") | |
| print(f"\nFirst few rows:") | |
| print(combined_df.head()) | |