Julian Bilcke commited on
Commit ·
1a07d0d
1
Parent(s): d7b6806
let's work on megadatasets
Browse filesFiles changed (5)
123456789101112131415161718# Video Model Studio - Guidelines for Claude
## Build & Run Commands- Setup: `./setup.sh` (with flash attention) or `./setup_no_captions.sh` (without)- Run: `./run.sh` or `python3.10 app.py`- Test: `python3 tests/test_dataset.py`- Single model test: `bash tests/scripts/dummy_cogvideox_lora.sh`
## Code Style- Python version: 3.10 (required for flash-attention compatibility)- Type hints: Use typing module annotations for all functions- Docstrings: Google style with Args/Returns sections- Error handling: Use try/except with specific exceptions, log errors- Imports: Group standard lib, third-party, and project imports- Naming: snake_case for functions/variables, PascalCase for classes- Use Path objects from pathlib instead of string paths- Format utility functions: Extract reusable logic to separate functions- Environment variables: Use parse_bool_env for boolean env vars216 unmodified lines217218219216 unmodified lines```bash./run.sh```216 unmodified lines217218219220221222223224225226227228229230231216 unmodified lines```bash./run.sh```### Environment Variables- `STORAGE_PATH`: Specifies the base storage path (default: '.data')- `HF_API_TOKEN`: Your Hugging Face API token for accessing models and publishing- `USE_LARGE_DATASET`: Set to "true" or "1" to enable large dataset mode, which:- Hides the caption list in the caption tab- Disables preview and editing of individual captions- Disables the dataset download button- Use this when working with large datasets that would be too slow to display in the UI- `PRELOAD_CAPTIONING_MODEL`: Preloads the captioning model at startup- `ASK_USER_TO_DUPLICATE_SPACE`: Prompts users to duplicate the space
18 unmodified lines19202122232418 unmodified linesHF_API_TOKEN = os.getenv("HF_API_TOKEN")ASK_USER_TO_DUPLICATE_SPACE = parse_bool_env(os.getenv("ASK_USER_TO_DUPLICATE_SPACE"))# Base storage pathSTORAGE_PATH = Path(os.environ.get('STORAGE_PATH', '.data'))18 unmodified lines19202122232425262718 unmodified linesHF_API_TOKEN = os.getenv("HF_API_TOKEN")ASK_USER_TO_DUPLICATE_SPACE = parse_bool_env(os.getenv("ASK_USER_TO_DUPLICATE_SPACE"))# For large datasets that would be slow to display or downloadUSE_LARGE_DATASET = parse_bool_env(os.getenv("USE_LARGE_DATASET"))# Base storage pathSTORAGE_PATH = Path(os.environ.get('STORAGE_PATH', '.data'))
10 unmodified lines1112131415161710 unmodified lines2829303132333427 unmodified lines6263646566676826 unmodified lines959697989910073 unmodified lines174175176177178179180181182183134 unmodified lines31831932032132232310 unmodified linesimport mimetypesfrom vms.utils import BaseTab, is_image_file, is_video_file, copy_files_to_training_dirfrom vms.config import DEFAULT_CAPTIONING_BOT_INSTRUCTIONS, DEFAULT_PROMPT_PREFIX, STAGING_PATH, TRAINING_VIDEOS_PATHlogger = logging.getLogger(__name__)10 unmodified lines"""Create the Caption tab UI components"""with gr.TabItem(self.title, id=self.id) as tab:with gr.Row():self.components["caption_title"] = gr.Markdown("## Captioning of 0 files (0 bytes)")with gr.Row():with gr.Column():27 unmodified linesinteractive=False)with gr.Row():with gr.Column():self.components["training_dataset"] = gr.Dataframe(headers=["name", "status"],26 unmodified linesvisible=True)self.components["original_file_path"] = gr.State(value=None)return tab73 unmodified linesdef refresh(self) -> Dict[str, Any]:"""Refresh the dataset list with current data"""training_dataset = self.list_training_files_to_caption()return {"training_dataset": training_dataset}def show_refreshing_status(self) -> List[List[str]]:"""Show a 'Refreshing...' status in the dataframe"""134 unmodified linesdef list_training_files_to_caption(self) -> List[List[str]]:"""List all clips and images - both pending and captioned"""files = []already_listed = {}10 unmodified lines1112131415161710 unmodified lines2829303132333435363727 unmodified lines6566676869707126 unmodified lines989910010110210310410510610773 unmodified lines181182183184185186187188189190191192193194195196134 unmodified lines33133233333433533633733833934010 unmodified linesimport mimetypesfrom vms.utils import BaseTab, is_image_file, is_video_file, copy_files_to_training_dirfrom vms.config import DEFAULT_CAPTIONING_BOT_INSTRUCTIONS, DEFAULT_PROMPT_PREFIX, STAGING_PATH, TRAINING_VIDEOS_PATH, USE_LARGE_DATASETlogger = logging.getLogger(__name__)10 unmodified lines"""Create the Caption tab UI components"""with gr.TabItem(self.title, id=self.id) as tab:with gr.Row():if USE_LARGE_DATASET:self.components["caption_title"] = gr.Markdown("## Captioning (Large Dataset Mode)")else:self.components["caption_title"] = gr.Markdown("## Captioning of 0 files (0 bytes)")with gr.Row():with gr.Column():27 unmodified linesinteractive=False)with gr.Row(visible=not USE_LARGE_DATASET):with gr.Column():self.components["training_dataset"] = gr.Dataframe(headers=["name", "status"],26 unmodified linesvisible=True)self.components["original_file_path"] = gr.State(value=None)with gr.Row(visible=USE_LARGE_DATASET):gr.Markdown("### Large Dataset Mode Active")gr.Markdown("Caption preview and editing is disabled to improve performance with large datasets.")return tab73 unmodified linesdef refresh(self) -> Dict[str, Any]:"""Refresh the dataset list with current data"""if USE_LARGE_DATASET:# In large dataset mode, we don't attempt to list filesreturn {"training_dataset": [["Large dataset mode enabled", "listing skipped"]]}else:training_dataset = self.list_training_files_to_caption()return {"training_dataset": training_dataset}def show_refreshing_status(self) -> List[List[str]]:"""Show a 'Refreshing...' status in the dataframe"""134 unmodified linesdef list_training_files_to_caption(self) -> List[List[str]]:"""List all clips and images - both pending and captioned"""# In large dataset mode, return a placeholder message instead of listing all filesif USE_LARGE_DATASET:return [["Large dataset mode enabled", "listing skipped"]]files = []already_listed = {}
10 unmodified lines1112131415161718 unmodified lines363738394041424310 unmodified linesfrom vms.utils import BaseTab, validate_model_repofrom vms.config import (HF_API_TOKEN, VIDEOS_TO_SPLIT_PATH, STAGING_PATH, TRAINING_VIDEOS_PATH,TRAINING_PATH, MODEL_PATH, OUTPUT_PATH, LOG_FILE_PATH)logger = logging.getLogger(__name__)18 unmodified linesself.components["download_dataset_btn"] = gr.DownloadButton("📦 Download training dataset (.zip)",variant="secondary",size="lg")self.components["download_model_btn"] = gr.DownloadButton("🧠 Download weights (.safetensors)",variant="secondary",10 unmodified lines1112131415161718 unmodified lines3637383940414243444546474810 unmodified linesfrom vms.utils import BaseTab, validate_model_repofrom vms.config import (HF_API_TOKEN, VIDEOS_TO_SPLIT_PATH, STAGING_PATH, TRAINING_VIDEOS_PATH,TRAINING_PATH, MODEL_PATH, OUTPUT_PATH, LOG_FILE_PATH, USE_LARGE_DATASET)logger = logging.getLogger(__name__)18 unmodified linesself.components["download_dataset_btn"] = gr.DownloadButton("📦 Download training dataset (.zip)",variant="secondary",size="lg",visible=not USE_LARGE_DATASET)# If we have a large dataset, display a message explaining why download is disabledif USE_LARGE_DATASET:gr.Markdown("📦 Training dataset download disabled for large datasets")self.components["download_model_btn"] = gr.DownloadButton("🧠 Download weights (.safetensors)",variant="secondary",
CLAUDE.mdAdded+18
README.md+12
vms/config.py+3
vms/ui/project/tabs/caption_tab.py+24-7
vms/ui/project/tabs/manage_tab.py+7-2