Julian Bilcke commited on
Commit ·
083045e
1
Parent(s): 9d56bbe
Fix model type display issue when internal model type name is used
Browse filesFiles changed (2)
54 unmodified lines555657585960616263646566676854 unmodified linesstatus = ui_state.get('project_status', 'draft')# Get model type from UI statemodel_type_display = ui_state.get('model_type', '')# Map display name to internal namefor display_name, internal_name in MODEL_TYPES.items():if display_name == model_type_display:model_type = internal_namemodel_display_name = display_namebreakexcept Exception as e:logger.error(f"Error loading UI state for model {model_id}: {str(e)}")54 unmodified lines55565758596061626364656667686970717273747576777854 unmodified linesstatus = ui_state.get('project_status', 'draft')# Get model type from UI statemodel_type_value = ui_state.get('model_type', '')# First check if model_type_value is a display namedisplay_name_found = Falsefor display_name, internal_name in MODEL_TYPES.items():if display_name == model_type_value:model_type = internal_namemodel_display_name = display_namedisplay_name_found = Truebreak# If not a display name, check if it's an internal nameif not display_name_found:for display_name, internal_name in MODEL_TYPES.items():if internal_name == model_type_value:model_type = internal_namemodel_display_name = display_namebreakexcept Exception as e:logger.error(f"Error loading UI state for model {model_id}: {str(e)}")
1 unmodified line2345673 unmodified lines1112131415161721 unmodified lines39404142434422 unmodified lines67686970717229 unmodified lines10210310410510610747 unmodified lines1551561571581591601611 unmodified linefrom pathlib import Pathimport loggingimport shutilfrom typing import Any, Optional, Dict, List, Union, Tuplefrom ..config import (3 unmodified linesDEFAULT_VALIDATION_HEIGHT,DEFAULT_VALIDATION_WIDTH,DEFAULT_VALIDATION_NB_FRAMES,DEFAULT_VALIDATION_FRAMERATE)from .utils import get_video_fps, extract_scene_info, make_archive, is_image_file, is_video_file21 unmodified linesReturns:Tuple of (videos_file_path, prompts_file_path)"""# Verifies the videos subdirectorytraining_videos_path.mkdir(exist_ok=True)22 unmodified linesrelative_path = f"videos/{file.name}"media_files.append(relative_path)captions.append(caption)# Write files if we have contentif media_files and captions:29 unmodified linesgr.Info("Copying assets to the training dataset..")# Find files needing captionsvideo_files = list(STAGING_PATH.glob("*.mp4"))image_files = [f for f in STAGING_PATH.glob("*") if is_image_file(f)]47 unmodified linesprint(f"failed to copy one of the pairs: {e}")passprepare_finetrainers_dataset()gr.Info(f"Successfully generated the training dataset ({nb_copied_pairs} pairs)")1 unmodified line23456783 unmodified lines121314151617181921 unmodified lines414243444546474849505152535455565758596061626364656622 unmodified lines899091929394959697989910010110210310410510610710829 unmodified lines13813914014114214314414514614714814915015115215315415515615715815916016147 unmodified lines2092102112122132142152162171 unmodified linefrom pathlib import Pathimport loggingimport shutilimport jsonfrom typing import Any, Optional, Dict, List, Union, Tuplefrom ..config import (3 unmodified linesDEFAULT_VALIDATION_HEIGHT,DEFAULT_VALIDATION_WIDTH,DEFAULT_VALIDATION_NB_FRAMES,DEFAULT_VALIDATION_FRAMERATE,load_global_config, get_project_paths)from .utils import get_video_fps, extract_scene_info, make_archive, is_image_file, is_video_file21 unmodified linesReturns:Tuple of (videos_file_path, prompts_file_path)"""# Get project ID from global config if paths not providedif training_path is None or training_videos_path is None:config = load_global_config()project_id = config.get("latest_model_project_id")if not project_id:logger.error("No active project found in global config")return None, None# Get paths for this projectproject_training_path, project_videos_path, _, _ = get_project_paths(project_id)# Use provided paths or defaultstraining_path = training_path or project_training_pathtraining_videos_path = training_videos_path or project_videos_path# Validate pathsif training_path is None or training_videos_path is None:logger.error("Could not determine training paths")return None, None# Verifies the videos subdirectorytraining_videos_path.mkdir(exist_ok=True)22 unmodified linesrelative_path = f"videos/{file.name}"media_files.append(relative_path)captions.append(caption)# Also include image files if present (for image conditioning)for idx, file in enumerate(sorted(training_videos_path.glob("*"))):if is_image_file(file):caption_file = file.with_suffix('.txt')if caption_file.exists():# Normalize caption to single linecaption = caption_file.read_text().strip()caption = ' '.join(caption.split())# Use relative path from training rootrelative_path = f"videos/{file.name}"media_files.append(relative_path)captions.append(caption)# Write files if we have contentif media_files and captions:29 unmodified linesgr.Info("Copying assets to the training dataset..")# Get project ID from global configconfig = load_global_config()project_id = config.get("latest_model_project_id")if not project_id:logger.error("No active project found in global config")raise ValueError("No active project found. Please create or select a project first.")# Get paths for this project if not providedif training_videos_path is None:_, training_videos_path, _, _ = get_project_paths(project_id)if training_videos_path is None:logger.error("Could not determine training videos path")raise ValueError("Training videos path is not set or could not be determined")logger.info(f"Using training videos path: {training_videos_path}")# Find files needing captionsvideo_files = list(STAGING_PATH.glob("*.mp4"))image_files = [f for f in STAGING_PATH.glob("*") if is_image_file(f)]47 unmodified linesprint(f"failed to copy one of the pairs: {e}")pass# Get training_path for prepare_finetrainers_datasettraining_path, _, _, _ = get_project_paths(project_id)prepare_finetrainers_dataset(training_path, training_videos_path)gr.Info(f"Successfully generated the training dataset ({nb_copied_pairs} pairs)")
vms/ui/models/services/models_service.py+13-3
vms/utils/finetrainers_utils.py+58-2