Spaces:
Build error
Build error
fixed some bugs with finetrainers CLI params
Browse filesFiles changed (4)
484 unmodified lines485486487488489490484 unmodified linesif self.precompute_conditions:args.append("--precompute_conditions")# Diffusion argumentsif self.flow_resolution_shifting:args.append("--flow_resolution_shifting")484 unmodified lines485486487488489490491492493484 unmodified linesif self.precompute_conditions:args.append("--precompute_conditions")if hasattr(self, 'precomputation_items') and self.precomputation_items:args.extend(["--precomputation_items", str(self.precomputation_items)])# Diffusion argumentsif self.flow_resolution_shifting:args.append("--flow_resolution_shifting")
51 unmodified lines52535455565758506 unmodified lines56556656756856957057157225 unmodified lines59859960060160260360460510 unmodified lines6166176186196206216226233 unmodified lines62762862963063163263363463563663763863985 unmodified lines72572672772872973073173273373422 unmodified lines75775875976076176280 unmodified lines84384484584684784884985050 unmodified lines90190290390490590690790851 unmodified lineslogger = logging.getLogger(__name__)class TrainingService:def __init__(self):# State and log filesself.session_file = OUTPUT_PATH / "session.json"self.status_file = OUTPUT_PATH / "status.json"506 unmodified lineslogger.info(f"{log_prefix} training with model_type={model_type}, training_type={training_type}")# Update progress if availableif progress:progress(0.15, desc="Setting up training configuration")try:# Get absolute paths - FIXED to look in project root instead of within vms directory25 unmodified lineslogger.info("Training data path: %s", TRAINING_PATH)# Update progressif progress:progress(0.2, desc="Preparing training dataset")videos_file, prompts_file = prepare_finetrainers_dataset()if videos_file is None or prompts_file is None:10 unmodified linesreturn error_msg, "No training data available"# Update progressif progress:progress(0.25, desc="Creating dataset configuration")# Get preset configurationpreset = TRAINING_PRESETS[preset_name]3 unmodified lines# Get the custom prompt prefix from the tabscustom_prompt_prefix = Noneif hasattr(self.app, 'tabs') and 'caption_tab' in self.app.tabs:if hasattr(self.app.tabs['caption_tab'], 'components') and 'custom_prompt_prefix' in self.app.tabs['caption_tab'].components:# Get the value and clean itprefix = self.app.tabs['caption_tab'].components['custom_prompt_prefix'].valueif prefix:# Clean the prefix - remove trailing comma, space or comma+spacecustom_prompt_prefix = prefix.rstrip(', ')# Create a proper dataset configuration JSON filedataset_config_file = OUTPUT_PATH / "dataset_config.json"85 unmodified linesconfig.flow_weighting_scheme = flow_weighting_schemeconfig.lr_warmup_steps = int(lr_warmup_steps)config_args.extend(["--precomputation_items", str(precomputation_items)])# Update the NUM_GPUS variable and CUDA_VISIBLE_DEVICESnum_gpus = min(num_gpus, get_available_gpu_count())if num_gpus <= 0:22 unmodified linesconfig.enable_tiling = Trueconfig.caption_dropout_p = DEFAULT_CAPTION_DROPOUT_Pvalidation_error = self.validate_training_config(config, model_type)if validation_error:error_msg = f"Configuration validation failed: {validation_error}"80 unmodified linesenv["FINETRAINERS_LOG_LEVEL"] = "DEBUG" # Added for better debuggingenv["CUDA_VISIBLE_DEVICES"] = visible_devicesif progress:progress(0.9, desc="Launching training process")# Start the training processprocess = subprocess.Popen(50 unmodified lineslogger.info(success_msg)# Final progress update - now we'll track it through the log monitorif progress:progress(1.0, desc="Training started successfully")return success_msg, self.get_logs()51 unmodified lines52535455565758596061506 unmodified lines56856957057157257357457525 unmodified lines60160260360460560660760810 unmodified lines6196206216226236246256263 unmodified lines63063163263363463563663763863964064164264385 unmodified lines72973073173273373473522 unmodified lines75875976076176276376476580 unmodified lines84684784884985085185285350 unmodified lines90490590690790890991091151 unmodified lineslogger = logging.getLogger(__name__)class TrainingService:def __init__(self, app=None):# Store reference to appself.app = app# State and log filesself.session_file = OUTPUT_PATH / "session.json"self.status_file = OUTPUT_PATH / "status.json"506 unmodified lineslogger.info(f"{log_prefix} training with model_type={model_type}, training_type={training_type}")# Update progress if available#if progress:# progress(0.15, desc="Setting up training configuration")try:# Get absolute paths - FIXED to look in project root instead of within vms directory25 unmodified lineslogger.info("Training data path: %s", TRAINING_PATH)# Update progress#if progress:# progress(0.2, desc="Preparing training dataset")videos_file, prompts_file = prepare_finetrainers_dataset()if videos_file is None or prompts_file is None:10 unmodified linesreturn error_msg, "No training data available"# Update progress#if progress:# progress(0.25, desc="Creating dataset configuration")# Get preset configurationpreset = TRAINING_PRESETS[preset_name]3 unmodified lines# Get the custom prompt prefix from the tabscustom_prompt_prefix = Noneif hasattr(self, 'app') and self.app is not None:if hasattr(self.app, 'tabs') and 'caption_tab' in self.app.tabs:if hasattr(self.app.tabs['caption_tab'], 'components') and 'custom_prompt_prefix' in self.app.tabs['caption_tab'].components:# Get the value and clean itprefix = self.app.tabs['caption_tab'].components['custom_prompt_prefix'].valueif prefix:# Clean the prefix - remove trailing comma, space or comma+spacecustom_prompt_prefix = prefix.rstrip(', ')# Create a proper dataset configuration JSON filedataset_config_file = OUTPUT_PATH / "dataset_config.json"85 unmodified linesconfig.flow_weighting_scheme = flow_weighting_schemeconfig.lr_warmup_steps = int(lr_warmup_steps)# Update the NUM_GPUS variable and CUDA_VISIBLE_DEVICESnum_gpus = min(num_gpus, get_available_gpu_count())if num_gpus <= 0:22 unmodified linesconfig.enable_tiling = Trueconfig.caption_dropout_p = DEFAULT_CAPTION_DROPOUT_Pconfig.precomputation_items = precomputation_itemsvalidation_error = self.validate_training_config(config, model_type)if validation_error:error_msg = f"Configuration validation failed: {validation_error}"80 unmodified linesenv["FINETRAINERS_LOG_LEVEL"] = "DEBUG" # Added for better debuggingenv["CUDA_VISIBLE_DEVICES"] = visible_devices#if progress:# progress(0.9, desc="Launching training process")# Start the training processprocess = subprocess.Popen(50 unmodified lineslogger.info(success_msg)# Final progress update - now we'll track it through the log monitor#if progress:# progress(1.0, desc="Training started successfully")return success_msg, self.get_logs()
383 unmodified lines3843853863873883893904 unmodified lines3953963973983994004014 unmodified lines4064074084094104114124134149 unmodified lines424425426427428429430431383 unmodified linesoutputs=[self.components["status_box"]])def handle_training_start(self, preset, model_type, training_type, *args, progress=gr.Progress()):"""Handle training start with proper log parser reset and checkpoint detection"""# Safely reset log parser if it existsif hasattr(self.app, 'log_parser') and self.app.log_parser is not None:4 unmodified linesself.app.log_parser = TrainingLogParser()# Initialize progressprogress(0, desc="Initializing training")# Check for latest checkpointcheckpoints = list(OUTPUT_PATH.glob("checkpoint-*"))4 unmodified lineslatest_checkpoint = max(checkpoints, key=os.path.getmtime)resume_from = str(latest_checkpoint)logger.info(f"Found checkpoint at {resume_from}, will resume training")progress(0.05, desc=f"Resuming from checkpoint {Path(resume_from).name}")else:progress(0.05, desc="Starting new training run")# Convert model_type display name to internal namemodel_internal_type = MODEL_TYPES.get(model_type)9 unmodified lineslogger.error(f"Invalid training type: {training_type}")return f"Error: Invalid training type '{training_type}'", "Training type not recognized"# Progress updateprogress(0.1, desc="Preparing dataset")# Start training (it will automatically use the checkpoint if provided)try:383 unmodified lines3843853863873883893903913924 unmodified lines3973983994004014024034 unmodified lines4084094104114124134144154164179 unmodified lines427428429430431432433434435436437438439383 unmodified linesoutputs=[self.components["status_box"]])def handle_training_start(self, preset, model_type, training_type, lora_rank, lora_alpha, train_steps, batch_size, learning_rate, save_iterations, repo_id, progress=gr.Progress()):"""Handle training start with proper log parser reset and checkpoint detection"""# Safely reset log parser if it existsif hasattr(self.app, 'log_parser') and self.app.log_parser is not None:4 unmodified linesself.app.log_parser = TrainingLogParser()# Initialize progress#progress(0, desc="Initializing training")# Check for latest checkpointcheckpoints = list(OUTPUT_PATH.glob("checkpoint-*"))4 unmodified lineslatest_checkpoint = max(checkpoints, key=os.path.getmtime)resume_from = str(latest_checkpoint)logger.info(f"Found checkpoint at {resume_from}, will resume training")#progress(0.05, desc=f"Resuming from checkpoint {Path(resume_from).name}")else:#progress(0.05, desc="Starting new training run")pass# Convert model_type display name to internal namemodel_internal_type = MODEL_TYPES.get(model_type)9 unmodified lineslogger.error(f"Invalid training type: {training_type}")return f"Error: Invalid training type '{training_type}'", "Training type not recognized"# Get other parameters from UI formnum_gpus = int(self.components["num_gpus"].value)precomputation_items = int(self.components["precomputation_items"].value)lr_warmup_steps = int(self.components["lr_warmup_steps"].value)# Progress update#progress(0.1, desc="Preparing dataset")# Start training (it will automatically use the checkpoint if provided)try:
39 unmodified lines4041424344454639 unmodified linesdef __init__(self):"""Initialize services and tabs"""# Initialize core servicesself.trainer = TrainingService()self.splitter = SplittingService()self.importer = ImportService()self.captioner = CaptioningService()39 unmodified lines4041424344454639 unmodified linesdef __init__(self):"""Initialize services and tabs"""# Initialize core servicesself.trainer = TrainingService(self)self.splitter = SplittingService()self.importer = ImportService()self.captioner = CaptioningService()
vms/config.py+3
vms/services/trainer.py+25-22
vms/tabs/train_tab.py+13-5
vms/ui/video_trainer_ui.py+1-1