Julian Bilcke commited on
Commit Β·
d5908ed
1
Parent(s): b08a534
fixes for the dataset importer
Browse filesFiles changed (33)
- app.py+2-2
- vms/ui/__init__.py+2-2
- vms/ui/video_trainer_ui.py β vms/ui/app_ui.pyRenamed+150-68
- vms/ui/monitoring/services/__init__.pyAdded+5
- vms/services/monitoring.py β vms/ui/monitoring/services/monitoring.pyRenamed
- vms/ui/monitoring/tabs/__init__.pyAdded+9
- vms/tabs/monitor_tab.py β vms/ui/monitoring/tabs/general_tab.pyRenamed+7-26
- vms/ui/monitoring/utils/__init__.pyAdded+7
- vms/ui/monitoring/utils/get_folder_size.pyAdded+22
- vms/ui/monitoring/utils/human_readable_size.pyAdded+10
- vms/services/__init__.py β vms/ui/project/services/__init__.pyRenamed-2
- vms/services/captioning.py β vms/ui/project/services/captioning.pyRenamed+2-2
- vms/services/importing/__init__.py β vms/ui/project/services/importing/__init__.pyRenamed
- vms/services/importing/file_upload.py β vms/ui/project/services/importing/file_upload.pyRenamed
- vms/services/importing/hub_dataset.py β vms/ui/project/services/importing/hub_dataset.pyRenamed+5-5
- vms/services/importing/import_service.py β vms/ui/project/services/importing/import_service.pyRenamed+4-3
- vms/services/importing/youtube.py β vms/ui/project/services/importing/youtube.pyRenamed
- vms/services/previewing.py β vms/ui/project/services/previewing.pyRenamed
- vms/services/splitting.py β vms/ui/project/services/splitting.pyRenamed+2-2
- vms/services/training.py β vms/ui/project/services/training.pyRenamed+2-2
- vms/tabs/__init__.py β vms/ui/project/tabs/__init__.pyRenamed+1-5
- vms/tabs/caption_tab.py β vms/ui/project/tabs/caption_tab.pyRenamed+4-6
- vms/tabs/import_tab/__init__.py β vms/ui/project/tabs/import_tab/__init__.pyRenamed
- vms/tabs/import_tab/hub_tab.py β vms/ui/project/tabs/import_tab/hub_tab.pyRenamed+20-12
- vms/tabs/import_tab/import_tab.py β vms/ui/project/tabs/import_tab/import_tab.pyRenamed+19-13
- vms/tabs/import_tab/upload_tab.py β vms/ui/project/tabs/import_tab/upload_tab.pyRenamed+51-19
- vms/tabs/import_tab/youtube_tab.py β vms/ui/project/tabs/import_tab/youtube_tab.pyRenamed+52-16
- vms/tabs/manage_tab.py β vms/ui/project/tabs/manage_tab.pyRenamed+53-49
- vms/tabs/preview_tab.py β vms/ui/project/tabs/preview_tab.pyRenamed+4-4
- vms/tabs/split_tab.py β vms/ui/project/tabs/split_tab.pyRenamed+1-1
- vms/tabs/train_tab.py β vms/ui/project/tabs/train_tab.pyRenamed+2-2
- vms/utils/__init__.py+4-1
- vms/tabs/base_tab.py β vms/utils/base_tab.pyRenamed+1-1
14 unmodified lines1516171819202115 unmodified lines3738394041424314 unmodified linesHF_API_TOKEN)from vms.ui.video_trainer_ui import VideoTrainerUI# Configure logginglogger = logging.getLogger(__name__)15 unmodified linesreturn app# Create the main application UIui = VideoTrainerUI()app = ui.create_ui()return app14 unmodified lines1516171819202115 unmodified lines3738394041424314 unmodified linesHF_API_TOKEN)from vms.ui.app_ui import AppUI# Configure logginglogger = logging.getLogger(__name__)15 unmodified linesreturn app# Create the main application UIui = AppUI()app = ui.create_ui()return app
12345from .video_trainer_ui import VideoTrainerUI__all__ = ['VideoTrainerUI',]12345from .app_ui import AppUI__all__ = ['AppUI',]
4 unmodified lines567891011129 unmodified lines222324252627282930313233341 unmodified line363738394041424344454647484950515253545556579 unmodified lines67686970717273747523 unmodified lines991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861872 unmodified lines1901911921931941951961972 unmodified lines200201202203204205206207208209210211212213214215216257 unmodified lines4744754764774784794804814 unmodified linesimport asynciofrom typing import Any, Optional, Dict, List, Union, Tuplefrom ..services import TrainingService, CaptioningService, SplittingService, ImportingService, PreviewingService, MonitoringServicefrom ..config import (STORAGE_PATH, VIDEOS_TO_SPLIT_PATH, STAGING_PATH, OUTPUT_PATH,TRAINING_PATH, LOG_FILE_PATH, TRAINING_PRESETS, TRAINING_VIDEOS_PATH, MODEL_PATH, OUTPUT_PATH,MODEL_TYPES, SMALL_TRAINING_BUCKETS, TRAINING_TYPES,9 unmodified linesDEFAULT_NB_TRAINING_STEPS,DEFAULT_NB_LR_WARMUP_STEPS)from ..utils import (get_recommended_precomputation_items,count_media_files,format_media_title,TrainingLogParser)from ..tabs import ImportTab, SplitTab, CaptionTab, TrainTab, MonitorTab, PreviewTab, ManageTablogger = logging.getLogger(__name__)logger.setLevel(logging.INFO)1 unmodified linehttpx_logger = logging.getLogger('httpx')httpx_logger.setLevel(logging.WARN)class VideoTrainerUI:def __init__(self):"""Initialize services and tabs"""# Initialize core servicesself.training = TrainingService(self)self.splitting = SplittingService()self.importing = ImportingService()self.captioning = CaptioningService()self.monitoring = MonitoringService()self.previewing = PreviewingService()# Start the monitoring service on app creationself.monitoring.start_monitoring()# Recovery status from any interrupted trainingrecovery_result = self.training.recover_interrupted_training()# Add null check for recovery_resultif recovery_result is None:recovery_result = {"status": "unknown", "ui_updates": {}}9 unmodified lines"recovery_result": recovery_result}# Initialize tabs dictionary (will be populated in create_ui)self.tabs = {}self.tabs_component = None# Log recovery statuslogger.info(f"Initialization complete. Recovery status: {self.recovery_status}")23 unmodified lineslogger.info(f"Added periodic callback {callback_fn.__name__} with interval {interval}s")except Exception as e:logger.error(f"Error adding periodic callback: {e}", exc_info=True)def create_ui(self):"""Create the main Gradio UI"""with gr.Blocks(title="π₯ Video Model Studio") as app:gr.Markdown("# π₯ Video Model Studio")# Create main tabs componentwith gr.Tabs() as self.tabs_component:# Initialize tab objectsself.tabs["import_tab"] = ImportTab(self)self.tabs["split_tab"] = SplitTab(self)self.tabs["caption_tab"] = CaptionTab(self)self.tabs["train_tab"] = TrainTab(self)self.tabs["monitor_tab"] = MonitorTab(self)self.tabs["preview_tab"] = PreviewTab(self)self.tabs["manage_tab"] = ManageTab(self)# Create tab UI componentsfor tab_id, tab_obj in self.tabs.items():tab_obj.create(self.tabs_component)# Connect event handlersfor tab_id, tab_obj in self.tabs.items():tab_obj.connect_events()# app-level timers for auto-refresh functionalityself._add_timers()# Initialize app state on loadapp.load(fn=self.initialize_app_state,outputs=[self.tabs["split_tab"].components["video_list"],self.tabs["caption_tab"].components["training_dataset"],self.tabs["train_tab"].components["start_btn"],self.tabs["train_tab"].components["stop_btn"],self.tabs["train_tab"].components["pause_resume_btn"],self.tabs["train_tab"].components["training_preset"],self.tabs["train_tab"].components["model_type"],self.tabs["train_tab"].components["training_type"],self.tabs["train_tab"].components["lora_rank"],self.tabs["train_tab"].components["lora_alpha"],self.tabs["train_tab"].components["train_steps"],self.tabs["train_tab"].components["batch_size"],self.tabs["train_tab"].components["learning_rate"],self.tabs["train_tab"].components["save_iterations"],self.tabs["train_tab"].components["current_task_box"],self.tabs["train_tab"].components["num_gpus"],self.tabs["train_tab"].components["precomputation_items"],self.tabs["train_tab"].components["lr_warmup_steps"]])return appdef _add_timers(self):"""Add auto-refresh timers to the UI"""# Status update timer for text components (every 1 second)status_timer = gr.Timer(value=1)status_timer.tick(fn=self.tabs["train_tab"].get_status_updates, # Use a new function that returns appropriate updatesoutputs=[self.tabs["train_tab"].components["status_box"],self.tabs["train_tab"].components["log_box"],self.tabs["train_tab"].components["current_task_box"] if "current_task_box" in self.tabs["train_tab"].components else None])# Button update timer for button components (every 1 second)button_timer = gr.Timer(value=1)button_outputs = [self.tabs["train_tab"].components["start_btn"],self.tabs["train_tab"].components["stop_btn"]]# Add delete_checkpoints_btn or pause_resume_btn as the third buttonif "delete_checkpoints_btn" in self.tabs["train_tab"].components:button_outputs.append(self.tabs["train_tab"].components["delete_checkpoints_btn"])elif "pause_resume_btn" in self.tabs["train_tab"].components:button_outputs.append(self.tabs["train_tab"].components["pause_resume_btn"])button_timer.tick(fn=self.tabs["train_tab"].get_button_updates, # Use a new function for button-specific updatesoutputs=button_outputs)2 unmodified linesdataset_timer.tick(fn=self.refresh_dataset,outputs=[self.tabs["split_tab"].components["video_list"],self.tabs["caption_tab"].components["training_dataset"]])2 unmodified linestitles_timer.tick(fn=self.update_titles,outputs=[self.tabs["split_tab"].components["split_title"],self.tabs["caption_tab"].components["caption_title"],self.tabs["train_tab"].components["train_title"]])def initialize_app_state(self):"""Initialize all app state in one function to ensure correct output count"""# Get dataset infovideo_list = self.tabs["split_tab"].list_unprocessed_videos()training_dataset = self.tabs["caption_tab"].list_training_files_to_caption()# Get button states based on recovery statusbutton_states = self.get_initial_button_states()257 unmodified linesdef refresh_dataset(self):"""Refresh all dynamic lists and training state"""video_list = self.tabs["split_tab"].list_unprocessed_videos()training_dataset = self.tabs["caption_tab"].list_training_files_to_caption()return (video_list,4 unmodified lines5678910119 unmodified lines2122232425262728293031323334353637383940414243444546471 unmodified line49505152535455565758596061626364656667686970719 unmodified lines8182838485868788899091929323 unmodified lines1171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692 unmodified lines2722732742752762772782792 unmodified lines282283284285286287288289290291292293294295296297298257 unmodified lines5565575585595605615625634 unmodified linesimport asynciofrom typing import Any, Optional, Dict, List, Union, Tuplefrom vms.config import (STORAGE_PATH, VIDEOS_TO_SPLIT_PATH, STAGING_PATH, OUTPUT_PATH,TRAINING_PATH, LOG_FILE_PATH, TRAINING_PRESETS, TRAINING_VIDEOS_PATH, MODEL_PATH, OUTPUT_PATH,MODEL_TYPES, SMALL_TRAINING_BUCKETS, TRAINING_TYPES,9 unmodified linesDEFAULT_NB_TRAINING_STEPS,DEFAULT_NB_LR_WARMUP_STEPS)from vms.utils import (get_recommended_precomputation_items,count_media_files,format_media_title,TrainingLogParser)from vms.ui.project.services import (TrainingService, CaptioningService, SplittingService, ImportingService, PreviewingService)from vms.ui.project.tabs import (ImportTab, SplitTab, CaptionTab, TrainTab, PreviewTab, ManageTab)from vms.ui.monitoring.services import (MonitoringService)from vms.ui.monitoring.tabs import (GeneralTab)logger = logging.getLogger(__name__)logger.setLevel(logging.INFO)1 unmodified linehttpx_logger = logging.getLogger('httpx')httpx_logger.setLevel(logging.WARN)class AppUI:def __init__(self):"""Initialize services and tabs"""# Project viewself.training = TrainingService(self)self.splitting = SplittingService()self.importing = ImportingService()self.captioning = CaptioningService()self.previewing = PreviewingService()# Monitoring viewself.monitoring = MonitoringService()self.monitoring.start_monitoring()# Recovery status from any interrupted trainingrecovery_result = self.training.recover_interrupted_training()# Add null check for recovery_resultif recovery_result is None:recovery_result = {"status": "unknown", "ui_updates": {}}9 unmodified lines"recovery_result": recovery_result}# Initialize tabs dictionaryself.tabs = {}self.project_tabs = {}self.monitor_tabs = {}self.main_tabs = None # Main tabbed interfaceself.project_tabs_component = None # Project sub-tabsself.monitor_tabs_component = None # Monitor sub-tabs# Log recovery statuslogger.info(f"Initialization complete. Recovery status: {self.recovery_status}")23 unmodified lineslogger.info(f"Added periodic callback {callback_fn.__name__} with interval {interval}s")except Exception as e:logger.error(f"Error adding periodic callback: {e}", exc_info=True)def switch_to_tab(self, tab_index: int):"""Switch to the specified tab indexArgs:tab_index: Index of the tab to select (0 for Project, 1 for Monitor)Returns:Tab selection dictionary for Gradio"""return gr.Tabs(selected=tab_index)def create_ui(self):self.components = {}"""Create the main Gradio UI with tabbed navigation"""with gr.Blocks(title="ποΈ Video Model Studio",# Let's hack Gradio!css="#component-8 > .tab-wrapper{ display: none; }") as app:self.app = app# Main container with sidebar and tab areawith gr.Row():# Sidebar for navigationwith gr.Sidebar(position="left", open=True):gr.Markdown("# ποΈ Video Model Studio")self.components["current_project_btn"] = gr.Button("Current Project", variant="primary")self.components["system_monitoring_btn"] = gr.Button("System Monitoring")# Main content area with tabswith gr.Column():# Main tabbed interface for switching between Project and Monitor viewswith gr.Tabs() as main_tabs:self.main_tabs = main_tabs# Project View Tabwith gr.Tab("π Current Project", id=0) as project_view:# Create project tabswith gr.Tabs() as project_tabs:# Store reference to project tabs componentself.project_tabs_component = project_tabs# Initialize project tab objectsself.project_tabs["import_tab"] = ImportTab(self)self.project_tabs["split_tab"] = SplitTab(self)self.project_tabs["caption_tab"] = CaptionTab(self)self.project_tabs["train_tab"] = TrainTab(self)self.project_tabs["preview_tab"] = PreviewTab(self)self.project_tabs["manage_tab"] = ManageTab(self)# Create tab UI components for projectfor tab_id, tab_obj in self.project_tabs.items():tab_obj.create(project_tabs)# Monitoring View Tabwith gr.Tab("π System Monitoring", id=1) as monitoring_view:# Create monitoring tabswith gr.Tabs() as monitoring_tabs:# Store reference to monitoring tabs componentself.monitor_tabs_component = monitoring_tabs# Initialize monitoring tab objectsself.monitor_tabs["general_tab"] = GeneralTab(self)# Create tab UI components for monitoringfor tab_id, tab_obj in self.monitor_tabs.items():tab_obj.create(monitoring_tabs)# Combine all tabs into a single dictionary for event handlingself.tabs = {**self.project_tabs, **self.monitor_tabs}# Connect event handlers for all tabs - this must happen AFTER all tabs are createdfor tab_id, tab_obj in self.tabs.items():tab_obj.connect_events()# app-level timers for auto-refresh functionalityself._add_timers()# Connect navigation events using tab switchingself.components["current_project_btn"].click(fn=lambda: self.switch_to_tab(0),outputs=[self.main_tabs],)self.components["system_monitoring_btn"].click(fn=lambda: self.switch_to_tab(1),outputs=[self.main_tabs],)# Initialize app state on loadapp.load(fn=self.initialize_app_state,outputs=[self.project_tabs["split_tab"].components["video_list"],self.project_tabs["caption_tab"].components["training_dataset"],self.project_tabs["train_tab"].components["start_btn"],self.project_tabs["train_tab"].components["stop_btn"],self.project_tabs["train_tab"].components["pause_resume_btn"],self.project_tabs["train_tab"].components["training_preset"],self.project_tabs["train_tab"].components["model_type"],self.project_tabs["train_tab"].components["training_type"],self.project_tabs["train_tab"].components["lora_rank"],self.project_tabs["train_tab"].components["lora_alpha"],self.project_tabs["train_tab"].components["train_steps"],self.project_tabs["train_tab"].components["batch_size"],self.project_tabs["train_tab"].components["learning_rate"],self.project_tabs["train_tab"].components["save_iterations"],self.project_tabs["train_tab"].components["current_task_box"],self.project_tabs["train_tab"].components["num_gpus"],self.project_tabs["train_tab"].components["precomputation_items"],self.project_tabs["train_tab"].components["lr_warmup_steps"]])return appdef _add_timers(self):"""Add auto-refresh timers to the UI"""# Status update timer for text components (every 1 second)status_timer = gr.Timer(value=1)status_timer.tick(fn=self.project_tabs["train_tab"].get_status_updates, # Use a new function that returns appropriate updatesoutputs=[self.project_tabs["train_tab"].components["status_box"],self.project_tabs["train_tab"].components["log_box"],self.project_tabs["train_tab"].components["current_task_box"] if "current_task_box" in self.project_tabs["train_tab"].components else None])# Button update timer for button components (every 1 second)button_timer = gr.Timer(value=1)button_outputs = [self.project_tabs["train_tab"].components["start_btn"],self.project_tabs["train_tab"].components["stop_btn"]]# Add delete_checkpoints_btn or pause_resume_btn as the third buttonif "delete_checkpoints_btn" in self.project_tabs["train_tab"].components:button_outputs.append(self.project_tabs["train_tab"].components["delete_checkpoints_btn"])elif "pause_resume_btn" in self.project_tabs["train_tab"].components:button_outputs.append(self.project_tabs["train_tab"].components["pause_resume_btn"])button_timer.tick(fn=self.project_tabs["train_tab"].get_button_updates, # Use a new function for button-specific updatesoutputs=button_outputs)2 unmodified linesdataset_timer.tick(fn=self.refresh_dataset,outputs=[self.project_tabs["split_tab"].components["video_list"],self.project_tabs["caption_tab"].components["training_dataset"]])2 unmodified linestitles_timer.tick(fn=self.update_titles,outputs=[self.project_tabs["split_tab"].components["split_title"],self.project_tabs["caption_tab"].components["caption_title"],self.project_tabs["train_tab"].components["train_title"]])def initialize_app_state(self):"""Initialize all app state in one function to ensure correct output count"""# Get dataset infovideo_list = self.project_tabs["split_tab"].list_unprocessed_videos()training_dataset = self.project_tabs["caption_tab"].list_training_files_to_caption()# Get button states based on recovery statusbutton_states = self.get_initial_button_states()257 unmodified linesdef refresh_dataset(self):"""Refresh all dynamic lists and training state"""video_list = self.project_tabs["split_tab"].list_unprocessed_videos()training_dataset = self.project_tabs["caption_tab"].list_training_files_to_caption()return (video_list,
12345from .monitoring import MonitoringService
__all__ = [ 'MonitoringService',]123456789"""Tab components for the "monitor" view"""
from .general_tab import GeneralTab
__all__ = [ 'GeneralTab']11 unmodified lines12131415161718192021222324252627282930313233343536373839404142434445464748495011 unmodified linesfrom typing import Dict, Any, List, Optional, Tuplefrom datetime import datetime, timedeltafrom .base_tab import BaseTabfrom ..config import STORAGE_PATHlogger = logging.getLogger(__name__)def get_folder_size(path):"""Calculate the total size of a folder in bytes"""total_size = 0for dirpath, dirnames, filenames in os.walk(path):for filename in filenames:file_path = os.path.join(dirpath, filename)if not os.path.islink(file_path): # Skip symlinkstotal_size += os.path.getsize(file_path)return total_sizedef human_readable_size(size_bytes):"""Convert a size in bytes to a human-readable string"""if size_bytes == 0:return "0 B"size_names = ("B", "KB", "MB", "GB", "TB", "PB")i = 0while size_bytes >= 1024 and i < len(size_names) - 1:size_bytes /= 1024i += 1return f"{size_bytes:.2f} {size_names[i]}"class MonitorTab(BaseTab):"""Monitor tab for system resource monitoring"""def __init__(self, app_state):super().__init__(app_state)self.id = "monitor_tab"self.title = "5οΈβ£ Monitor"self.refresh_interval = 8def create(self, parent=None) -> gr.TabItem:11 unmodified lines121314151617181920212223242526272829303111 unmodified linesfrom typing import Dict, Any, List, Optional, Tuplefrom datetime import datetime, timedeltafrom vms.utils.base_tab import BaseTabfrom vms.config import STORAGE_PATHfrom vms.ui.monitoring.utils import get_folder_size, human_readable_sizelogger = logging.getLogger(__name__)class GeneralTab(BaseTab):"""Monitor tab for general system resource monitoring"""def __init__(self, app_state):super().__init__(app_state)self.id = "General_tab"self.title = "General stats"self.refresh_interval = 8def create(self, parent=None) -> gr.TabItem:
1234567from .get_folder_size import get_folder_sizefrom .human_readable_size import human_readable_size
__all__ = [ 'get_folder_size', 'human_readable_size',]12345678910111213141516171819202122import os
def get_folder_size(path): """Calculate the total size of a folder in bytes""" total_size = 0 for dirpath, dirnames, filenames in os.walk(path): for filename in filenames: file_path = os.path.join(dirpath, filename) if not os.path.islink(file_path): # Skip symlinks total_size += os.path.getsize(file_path) return total_size
def human_readable_size(size_bytes): """Convert a size in bytes to a human-readable string""" if size_bytes == 0: return "0 B" size_names = ("B", "KB", "MB", "GB", "TB", "PB") i = 0 while size_bytes >= 1024 and i < len(size_names) - 1: size_bytes /= 1024 i += 1 return f"{size_bytes:.2f} {size_names[i]}"12345678910def human_readable_size(size_bytes): """Convert a size in bytes to a human-readable string""" if size_bytes == 0: return "0 B" size_names = ("B", "KB", "MB", "GB", "TB", "PB") i = 0 while size_bytes >= 1024 and i < len(size_names) - 1: size_bytes /= 1024 i += 1 return f"{size_bytes:.2f} {size_names[i]}"1234562 unmodified lines9101112131415from .captioning import CaptioningProgress, CaptioningServicefrom .importing import ImportingServicefrom .monitoring import MonitoringServicefrom .splitting import SplittingServicefrom .previewing import PreviewingServicefrom .training import TrainingService2 unmodified lines'CaptioningProgress','CaptioningService','ImportingService','MonitoringService','SplittingService','PreviewingService','TrainingService',123452 unmodified lines8910111213from .captioning import CaptioningProgress, CaptioningServicefrom .importing import ImportingServicefrom .splitting import SplittingServicefrom .previewing import PreviewingServicefrom .training import TrainingService2 unmodified lines'CaptioningProgress','CaptioningService','ImportingService','SplittingService','PreviewingService','TrainingService',
16 unmodified lines171819202122232416 unmodified linesfrom llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKENfrom llava.conversation import conv_templates, SeparatorStylefrom ..config import TRAINING_VIDEOS_PATH, STAGING_PATH, PRELOAD_CAPTIONING_MODEL, CAPTIONING_MODEL, USE_MOCK_CAPTIONING_MODEL, DEFAULT_CAPTIONING_BOT_INSTRUCTIONS, VIDEOS_TO_SPLIT_PATH, DEFAULT_PROMPT_PREFIXfrom ..utils import extract_scene_info, is_image_file, is_video_file, copy_files_to_training_dir, prepare_finetrainers_datasetlogger = logging.getLogger(__name__)16 unmodified lines171819202122232416 unmodified linesfrom llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKENfrom llava.conversation import conv_templates, SeparatorStylefrom vms.config import TRAINING_VIDEOS_PATH, STAGING_PATH, PRELOAD_CAPTIONING_MODEL, CAPTIONING_MODEL, USE_MOCK_CAPTIONING_MODEL, DEFAULT_CAPTIONING_BOT_INSTRUCTIONS, VIDEOS_TO_SPLIT_PATH, DEFAULT_PROMPT_PREFIXfrom vms.utils import extract_scene_info, is_image_file, is_video_file, copy_files_to_training_dir, prepare_finetrainers_datasetlogger = logging.getLogger(__name__)
112 unmodified lines1131141151161171181196 unmodified lines126127128129130131132133134135136112 unmodified linesdataset_info = self.hf_api.dataset_info(dataset_id)# Format the information for displayinfo_text = f"## {dataset_info.id}\n\n"# Add description if available (with safer access)card_data = getattr(dataset_info, "card_data", None)6 unmodified linesinfo_text += f"{description[:500]}{'...' if len(description) > 500 else ''}\n\n"# Add basic stats (with safer access)downloads = getattr(dataset_info, 'downloads', None)info_text += f"## Downloads: {downloads if downloads is not None else 'N/A'}\n"last_modified = getattr(dataset_info, 'last_modified', None)info_text += f"## Last modified: {last_modified if last_modified is not None else 'N/A'}\n"# Group files by typefile_groups = {112 unmodified lines1131141151161171181196 unmodified lines126127128129130131132133134135136112 unmodified linesdataset_info = self.hf_api.dataset_info(dataset_id)# Format the information for displayinfo_text = f"### {dataset_info.id}\n\n"# Add description if available (with safer access)card_data = getattr(dataset_info, "card_data", None)6 unmodified linesinfo_text += f"{description[:500]}{'...' if len(description) > 500 else ''}\n\n"# Add basic stats (with safer access)#downloads = getattr(dataset_info, 'downloads', None)#info_text += f"## Downloads: {downloads if downloads is not None else 'N/A'}\n"#last_modified = getattr(dataset_info, 'last_modified', None)#info_text += f"## Last modified: {last_modified if last_modified is not None else 'N/A'}\n"# Group files by typefile_groups = {
9 unmodified lines10111213141516171819209 unmodified linesfrom huggingface_hub import HfApifrom .file_upload import FileUploadHandlerfrom .youtube import YouTubeDownloaderfrom .hub_dataset import HubDatasetBrowserfrom vms.config import HF_API_TOKENlogger = logging.getLogger(__name__)class ImportingService:9 unmodified lines1011121314151617181920219 unmodified linesfrom huggingface_hub import HfApifrom vms.config import HF_API_TOKENfrom vms.ui.project.services.importing.file_upload import FileUploadHandlerfrom vms.ui.project.services.importing.youtube import YouTubeDownloaderfrom vms.ui.project.services.importing.hub_dataset import HubDatasetBrowserlogger = logging.getLogger(__name__)class ImportingService:
11 unmodified lines121314151617181911 unmodified linesfrom scenedetect import detect, ContentDetector, SceneManager, open_videofrom scenedetect.video_splitter import split_video_ffmpegfrom ..config import TRAINING_PATH, STORAGE_PATH, TRAINING_VIDEOS_PATH, VIDEOS_TO_SPLIT_PATH, STAGING_PATH, DEFAULT_PROMPT_PREFIXfrom ..utils import remove_black_bars, extract_scene_info, is_video_file, is_image_file, add_prefix_to_captionlogger = logging.getLogger(__name__)11 unmodified lines121314151617181911 unmodified linesfrom scenedetect import detect, ContentDetector, SceneManager, open_videofrom scenedetect.video_splitter import split_video_ffmpegfrom vms.config import TRAINING_PATH, STORAGE_PATH, TRAINING_VIDEOS_PATH, VIDEOS_TO_SPLIT_PATH, STAGING_PATH, DEFAULT_PROMPT_PREFIXfrom vms.utils import remove_black_bars, extract_scene_info, is_video_file, is_image_file, add_prefix_to_captionlogger = logging.getLogger(__name__)
19 unmodified lines2021222324252612 unmodified lines3940414243444519 unmodified linesfrom huggingface_hub import upload_folder, create_repofrom ..config import (TrainingConfig, TRAINING_PRESETS, LOG_FILE_PATH, TRAINING_VIDEOS_PATH,STORAGE_PATH, TRAINING_PATH, MODEL_PATH, OUTPUT_PATH, HF_API_TOKEN,MODEL_TYPES, TRAINING_TYPES,12 unmodified linesDEFAULT_NB_TRAINING_STEPS,DEFAULT_NB_LR_WARMUP_STEPS)from ..utils import (get_available_gpu_count,make_archive,parse_training_log,19 unmodified lines2021222324252612 unmodified lines3940414243444519 unmodified linesfrom huggingface_hub import upload_folder, create_repofrom vms.config import (TrainingConfig, TRAINING_PRESETS, LOG_FILE_PATH, TRAINING_VIDEOS_PATH,STORAGE_PATH, TRAINING_PATH, MODEL_PATH, OUTPUT_PATH, HF_API_TOKEN,MODEL_TYPES, TRAINING_TYPES,12 unmodified linesDEFAULT_NB_TRAINING_STEPS,DEFAULT_NB_LR_WARMUP_STEPS)from vms.utils import (get_available_gpu_count,make_archive,parse_training_log,
1234567891011121314151617181920212223"""Tab components for Video Model Studio UI"""from .base_tab import BaseTabfrom .import_tab import ImportTabfrom .split_tab import SplitTabfrom .caption_tab import CaptionTabfrom .train_tab import TrainTabfrom .monitor_tab import MonitorTabfrom .preview_tab import PreviewTabfrom .manage_tab import ManageTab__all__ = ['BaseTab','ImportTab','SplitTab','CaptionTab','TrainTab','MonitorTab','PreviewTab','ManageTab']12345678910111213141516171819"""Tab components for the "project" view"""from .import_tab import ImportTabfrom .split_tab import SplitTabfrom .caption_tab import CaptionTabfrom .train_tab import TrainTabfrom .preview_tab import PreviewTabfrom .manage_tab import ManageTab__all__ = ['ImportTab','SplitTab','CaptionTab','TrainTab','PreviewTab','ManageTab']
7 unmodified lines891011121314151617515 unmodified lines5335345355365375385395405417 unmodified linesimport tracebackfrom typing import Dict, Any, List, Optional, AsyncGenerator, Tuplefrom pathlib import Pathfrom .base_tab import BaseTabfrom ..config import DEFAULT_CAPTIONING_BOT_INSTRUCTIONS, DEFAULT_PROMPT_PREFIX, STAGING_PATH, TRAINING_VIDEOS_PATHfrom ..utils import is_image_file, is_video_file, copy_files_to_training_dirlogger = logging.getLogger(__name__)515 unmodified linesReturns:Dict with preview content for each preview component"""import mimetypesfrom ..config import TRAINING_VIDEOS_PATHif not selected_text or "Caption:" in selected_text:return {"video": None,7 unmodified lines891011121314151617515 unmodified lines5335345355365375385397 unmodified linesimport tracebackfrom typing import Dict, Any, List, Optional, AsyncGenerator, Tuplefrom pathlib import Pathimport 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__)515 unmodified linesReturns:Dict with preview content for each preview component"""if not selected_text or "Caption:" in selected_text:return {"video": None,
9 unmodified lines101112131415169 unmodified lines2627282930313233343536373839404142434445464718 unmodified lines66676869707172739 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, List, Optional, Tuplefrom ..base_tab import BaseTablogger = logging.getLogger(__name__)9 unmodified linesdef create(self, parent=None) -> gr.Tab:"""Create the Hub tab UI components"""with gr.Tab(self.title, id=self.id) as tab:with gr.Column():with gr.Row():gr.Markdown("## Import from Hub datasets")with gr.Row():gr.Markdown("Search for datasets with videos or WebDataset archives:")with gr.Row():self.components["dataset_search"] = gr.Textbox(label="Search Hugging Face Datasets (eg. cakeify, disney, rickroll..)",placeholder="Search for video datasets (eg. cakeify, disney, rickroll..)")with gr.Row():self.components["dataset_search_btn"] = gr.Button("Search Datasets", variant="primary")# Dataset browser results sectionwith gr.Row(visible=False) as dataset_results_row:self.components["dataset_results_row"] = dataset_results_row18 unmodified lineswith gr.Column(visible=False) as files_section:self.components["files_section"] = files_sectiongr.Markdown("## Files:")# Video files row (appears if videos are present)with gr.Row() as video_files_row:self.components["video_files_row"] = video_files_row9 unmodified lines101112131415169 unmodified lines262728293031323334353637383940414243444546474849505152535455565718 unmodified lines7677787980819 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, List, Optional, Tuplefrom vms.utils import BaseTablogger = logging.getLogger(__name__)9 unmodified linesdef create(self, parent=None) -> gr.Tab:"""Create the Hub tab UI components"""with gr.Tab(self.title, id=self.id) as tab:with gr.Column():with gr.Row():gr.Markdown("## Import a dataset from Hugging Face")with gr.Row():with gr.Column():with gr.Row():gr.Markdown("You can use any dataset containing video files (.mp4) with optional captions (same names but in .txt format)")with gr.Row():gr.Markdown("You can also use a dataset containing WebDataset shards (.tar files).")with gr.Column():self.components["dataset_search"] = gr.Textbox(label="Search Hugging Face Datasets (MP4, WebDataset)",placeholder="video datasets eg. cakeify, disney, rickroll..")with gr.Row():self.components["dataset_search_btn"] = gr.Button("Search Datasets",variant="primary",#size="md")# Dataset browser results sectionwith gr.Row(visible=False) as dataset_results_row:self.components["dataset_results_row"] = dataset_results_row18 unmodified lineswith gr.Column(visible=False) as files_section:self.components["files_section"] = files_section# Video files row (appears if videos are present)with gr.Row() as video_files_row:self.components["video_files_row"] = video_files_row
8 unmodified lines91011121314151617189 unmodified lines2829303132333418 unmodified lines535455565758594 unmodified lines646566676869707172737475767778798081828 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, List, Optional, Tuplefrom ..base_tab import BaseTabfrom .upload_tab import UploadTabfrom .youtube_tab import YouTubeTabfrom .hub_tab import HubTabfrom vms.config import (VIDEOS_TO_SPLIT_PATH, DEFAULT_PROMPT_PREFIX, DEFAULT_CAPTIONING_BOT_INSTRUCTIONS,9 unmodified linessuper().__init__(app_state)self.id = "import_tab"self.title = "1οΈβ£ Import"# Initialize sub-tabsself.upload_tab = UploadTab(app_state)self.youtube_tab = YouTubeTab(app_state)self.hub_tab = HubTab(app_state)18 unmodified linesvisible=True,)# Create tabs for different import methodswith gr.Tabs() as import_tabs:# Create each sub-tabself.upload_tab.create(import_tabs)4 unmodified linesself.components["upload_tab"] = self.upload_tabself.components["youtube_tab"] = self.youtube_tabself.components["hub_tab"] = self.hub_tabwith gr.Row():self.components["import_status"] = gr.Textbox(label="Status", interactive=False)return tabdef connect_events(self) -> None:"""Connect event handlers to UI components"""# Set shared components from parent tab to sub-tabs firstfor subtab in [self.upload_tab, self.youtube_tab, self.hub_tab]:subtab.components["import_status"] = self.components["import_status"]subtab.components["enable_automatic_video_split"] = self.components["enable_automatic_video_split"]subtab.components["enable_automatic_content_captioning"] = self.components["enable_automatic_content_captioning"]# Then connect events for each sub-tabself.upload_tab.connect_events()8 unmodified lines91011121314151617189 unmodified lines282930313233343518 unmodified lines54555657585960616263644 unmodified lines69707172737475767778798081828384858687888 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, List, Optional, Tuplefrom vms.utils import BaseTabfrom vms.ui.project.tabs.import_tab.upload_tab import UploadTabfrom vms.ui.project.tabs.import_tab.youtube_tab import YouTubeTabfrom vms.ui.project.tabs.import_tab.hub_tab import HubTabfrom vms.config import (VIDEOS_TO_SPLIT_PATH, DEFAULT_PROMPT_PREFIX, DEFAULT_CAPTIONING_BOT_INSTRUCTIONS,9 unmodified linessuper().__init__(app_state)self.id = "import_tab"self.title = "1οΈβ£ Import"# Initialize sub-tabs - these should be created firstself.upload_tab = UploadTab(app_state)self.youtube_tab = YouTubeTab(app_state)self.hub_tab = HubTab(app_state)18 unmodified linesvisible=True,)# Create the import status textbox before creating the sub-tabswith gr.Row():self.components["import_status"] = gr.Textbox(label="Status", interactive=False)# Now create tabs for different import methodswith gr.Tabs() as import_tabs:# Create each sub-tabself.upload_tab.create(import_tabs)4 unmodified linesself.components["upload_tab"] = self.upload_tabself.components["youtube_tab"] = self.youtube_tabself.components["hub_tab"] = self.hub_tabreturn tabdef connect_events(self) -> None:"""Connect event handlers to UI components"""# Set shared components from parent tab to sub-tabs before connecting eventsfor subtab in [self.upload_tab, self.youtube_tab, self.hub_tab]:# Ensure these components exist in the parent before sharing themif "import_status" in self.components:subtab.components["import_status"] = self.components["import_status"]if "enable_automatic_video_split" in self.components:subtab.components["enable_automatic_video_split"] = self.components["enable_automatic_video_split"]if "enable_automatic_content_captioning" in self.components:subtab.components["enable_automatic_content_captioning"] = self.components["enable_automatic_content_captioning"]# Then connect events for each sub-tabself.upload_tab.connect_events()
7 unmodified lines8910111213144 unmodified lines19202122232426 unmodified lines5152535455565758596061626364656667686970717273747 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, Optionalfrom ..base_tab import BaseTablogger = logging.getLogger(__name__)4 unmodified linessuper().__init__(app_state)self.id = "upload_tab"self.title = "Manual Upload"def create(self, parent=None) -> gr.Tab:"""Create the Upload tab UI components"""26 unmodified linesdef connect_events(self) -> None:"""Connect event handlers to UI components"""# File upload eventself.components["files"].upload(fn=lambda x: self.app.importing.process_uploaded_files(x),inputs=[self.components["files"]],outputs=[self.components["import_status"]] # This comes from parent tab).success(fn=self.app.tabs["import_tab"].update_titles_after_import,inputs=[self.components["enable_automatic_video_split"],self.components["enable_automatic_content_captioning"],self.app.tabs["caption_tab"].components["custom_prompt_prefix"]],outputs=[self.app.tabs_component, # Main tabs componentself.app.tabs["split_tab"].components["video_list"],self.app.tabs["split_tab"].components["detect_status"],self.app.tabs["split_tab"].components["split_title"],self.app.tabs["caption_tab"].components["caption_title"],self.app.tabs["train_tab"].components["train_title"]])7 unmodified lines8910111213144 unmodified lines19202122232425262728293026 unmodified lines575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051067 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, Optionalfrom vms.utils import BaseTablogger = logging.getLogger(__name__)4 unmodified linessuper().__init__(app_state)self.id = "upload_tab"self.title = "Manual Upload"# Initialize the components dictionary with None values for expected shared componentsif "components" not in self.__dict__:self.components = {}self.components["import_status"] = Noneself.components["enable_automatic_video_split"] = Noneself.components["enable_automatic_content_captioning"] = Nonedef create(self, parent=None) -> gr.Tab:"""Create the Upload tab UI components"""26 unmodified linesdef connect_events(self) -> None:"""Connect event handlers to UI components"""# Check if required shared components exist before connecting eventsif not self.components.get("import_status"):logger.warning("import_status component is not set in UploadTab")return# File upload eventupload_event = self.components["files"].upload(fn=lambda x: self.app.importing.process_uploaded_files(x),inputs=[self.components["files"]],outputs=[self.components["import_status"]])# Only add success handler if all required components existif hasattr(self.app.tabs, "import_tab") and hasattr(self.app.tabs, "split_tab") and \hasattr(self.app.tabs, "caption_tab") and hasattr(self.app.tabs, "train_tab"):# Get required components for success handlertry:# If the components are missing, this will raise an AttributeErrortabs_component = self.app.tabs_componentvideo_list = self.app.tabs["split_tab"].components["video_list"]detect_status = self.app.tabs["split_tab"].components["detect_status"]split_title = self.app.tabs["split_tab"].components["split_title"]caption_title = self.app.tabs["caption_tab"].components["caption_title"]train_title = self.app.tabs["train_tab"].components["train_title"]custom_prompt_prefix = self.app.tabs["caption_tab"].components["custom_prompt_prefix"]# Add success handlerupload_event.success(fn=self.app.tabs["import_tab"].update_titles_after_import,inputs=[self.components["enable_automatic_video_split"],self.components["enable_automatic_content_captioning"],custom_prompt_prefix],outputs=[tabs_component,video_list,detect_status,split_title,caption_title,train_title])except (AttributeError, KeyError) as e:logger.error(f"Error connecting event handlers in UploadTab: {str(e)}")# Continue without the success handler
7 unmodified lines8910111213144 unmodified lines19202122232422 unmodified lines4748495051525354555657585960616263646566677 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, Optionalfrom ..base_tab import BaseTablogger = logging.getLogger(__name__)4 unmodified linessuper().__init__(app_state)self.id = "youtube_tab"self.title = "Download from YouTube"def create(self, parent=None) -> gr.Tab:"""Create the YouTube tab UI components"""22 unmodified linesdef connect_events(self) -> None:"""Connect event handlers to UI components"""# YouTube download eventself.components["youtube_download_btn"].click(fn=self.app.importing.download_youtube_video,inputs=[self.components["youtube_url"]],outputs=[self.components["import_status"]] # This comes from parent tab).success(fn=self.app.tabs["import_tab"].on_import_success,inputs=[self.components["enable_automatic_video_split"],self.components["enable_automatic_content_captioning"],self.app.tabs["caption_tab"].components["custom_prompt_prefix"]],outputs=[self.app.tabs_component,self.app.tabs["split_tab"].components["video_list"],self.app.tabs["split_tab"].components["detect_status"]])7 unmodified lines8910111213144 unmodified lines19202122232425262728293022 unmodified lines53545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021037 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, Optionalfrom vms.utils import BaseTablogger = logging.getLogger(__name__)4 unmodified linessuper().__init__(app_state)self.id = "youtube_tab"self.title = "Download from YouTube"# Initialize components that will be shared from parentif "components" not in self.__dict__:self.components = {}self.components["import_status"] = Noneself.components["enable_automatic_video_split"] = Noneself.components["enable_automatic_content_captioning"] = Nonedef create(self, parent=None) -> gr.Tab:"""Create the YouTube tab UI components"""22 unmodified linesdef connect_events(self) -> None:"""Connect event handlers to UI components"""# Check if required shared components exist before connecting eventsif not self.components.get("import_status"):logger.warning("import_status component is not set in YouTubeTab")returnif not self.components.get("enable_automatic_video_split"):logger.warning("enable_automatic_video_split component is not set in YouTubeTab")returnif not self.components.get("enable_automatic_content_captioning"):logger.warning("enable_automatic_content_captioning component is not set in YouTubeTab")return# Only try to access custom_prompt_prefix if the caption_tab existscustom_prompt_prefix = Nonetry:if hasattr(self.app.tabs, "caption_tab") and "custom_prompt_prefix" in self.app.tabs["caption_tab"].components:custom_prompt_prefix = self.app.tabs["caption_tab"].components["custom_prompt_prefix"]except (AttributeError, KeyError):logger.warning("Could not access custom_prompt_prefix component")# YouTube download eventdownload_event = self.components["youtube_download_btn"].click(fn=self.app.importing.download_youtube_video,inputs=[self.components["youtube_url"]],outputs=[self.components["import_status"]])# Add success handler if all components existif hasattr(self.app.tabs, "import_tab") and custom_prompt_prefix is not None:try:# Add the success handlerdownload_event.success(fn=self.app.tabs["import_tab"].on_import_success,inputs=[self.components["enable_automatic_video_split"],self.components["enable_automatic_content_captioning"],custom_prompt_prefix],outputs=[self.app.tabs_component,self.app.tabs["split_tab"].components["video_list"],self.app.tabs["split_tab"].components["detect_status"]])except (AttributeError, KeyError) as e:logger.error(f"Error connecting success handler in YouTubeTab: {str(e)}")# Continue without the success handler
7 unmodified lines89101112131415161718193 unmodified lines23242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980817 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, List, Optionalfrom .base_tab import BaseTabfrom ..config import (HF_API_TOKEN, VIDEOS_TO_SPLIT_PATH, STAGING_PATH, TRAINING_VIDEOS_PATH,TRAINING_PATH, MODEL_PATH, OUTPUT_PATH, LOG_FILE_PATH)from ..utils import validate_model_repologger = logging.getLogger(__name__)3 unmodified linesdef __init__(self, app_state):super().__init__(app_state)self.id = "manage_tab"self.title = "7οΈβ£ Manage"def create(self, parent=None) -> gr.TabItem:"""Create the Manage tab UI components"""with gr.TabItem(self.title, id=self.id) as tab:with gr.Column():with gr.Row():with gr.Column():gr.Markdown("## Publishing")gr.Markdown("You model can be pushed to Hugging Face (this will use HF_API_TOKEN)")with gr.Row():with gr.Column():self.components["repo_id"] = gr.Textbox(label="HuggingFace Model Repository",placeholder="username/model-name",info="The repository will be created if it doesn't exist")self.components["make_public"] = gr.Checkbox(label="Check this to make your model public (ie. visible and downloadable by anyone)",info="You model is private by default")self.components["push_model_btn"] = gr.Button("Push my model")with gr.Row():with gr.Column():with gr.Row():with gr.Column():gr.Markdown("## Storage management")with gr.Row():self.components["download_dataset_btn"] = gr.DownloadButton("Download dataset (click again if DL doesn't start)",variant="secondary",size="lg")self.components["download_model_btn"] = gr.DownloadButton("Download model (click again if DL doesn't start)",variant="secondary",size="lg")with gr.Row():self.components["global_stop_btn"] = gr.Button("Stop everything and delete my data",variant="stop")self.components["global_status"] = gr.Textbox(label="Global Status",interactive=False,visible=False)return tab7 unmodified lines891011121314151617183 unmodified lines222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384857 unmodified linesfrom pathlib import Pathfrom typing import Dict, Any, List, Optionalfrom 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__)3 unmodified linesdef __init__(self, app_state):super().__init__(app_state)self.id = "manage_tab"self.title = "6οΈβ£ Storage"def create(self, parent=None) -> gr.TabItem:"""Create the Manage tab UI components"""with gr.TabItem(self.title, id=self.id) as tab:with gr.Row():with gr.Column():gr.Markdown("## Download your model")gr.Markdown("There is currently a bug, you might have to click multiple times to trigger a download.")with gr.Row():self.components["download_dataset_btn"] = gr.DownloadButton("Download training dataset",variant="secondary",size="lg")self.components["download_model_btn"] = gr.DownloadButton("Download model weights",variant="secondary",size="lg")with gr.Row():with gr.Column():gr.Markdown("## Publish your model")gr.Markdown("You model can be pushed to Hugging Face (this will use HF_API_TOKEN)")with gr.Row():with gr.Column():self.components["repo_id"] = gr.Textbox(label="HuggingFace Model Repository",placeholder="username/model-name",info="The repository will be created if it doesn't exist")self.components["make_public"] = gr.Checkbox(label="Check this to make your model public (ie. visible and downloadable by anyone)",info="You model is private by default")self.components["push_model_btn"] = gr.Button("Push my model")with gr.Row():with gr.Column():gr.Markdown("## Delete your model")gr.Markdown("If something went wrong, you can trigger a full reset (model shutdown + data destruction).")gr.Markdown("Make sure you have made a backup first.")gr.Markdown("If you are deleting because of a bug, remember you can use the Developer Mode on HF to inspect the working directory (in /data or .data)")with gr.Row():self.components["global_stop_btn"] = gr.Button("Stop everything and delete my data",variant="stop")self.components["global_status"] = gr.Textbox(label="Global Status",interactive=False,visible=False)return tab
7 unmodified lines891011121314155 unmodified lines212223242526272829303132337 unmodified linesfrom typing import Dict, Any, List, Optional, Tupleimport timefrom .base_tab import BaseTabfrom ..config import (MODEL_TYPES, DEFAULT_PROMPT_PREFIX)5 unmodified linesdef __init__(self, app_state):super().__init__(app_state)self.id = "preview_tab"self.title = "6οΈβ£ Preview"def create(self, parent=None) -> gr.TabItem:"""Create the Preview tab UI components"""with gr.TabItem(self.title, id=self.id) as tab:with gr.Row():gr.Markdown("## Test Your Trained Model")with gr.Row():with gr.Column(scale=2):7 unmodified lines891011121314155 unmodified lines212223242526272829303132337 unmodified linesfrom typing import Dict, Any, List, Optional, Tupleimport timefrom vms.utils import BaseTabfrom vms.config import (MODEL_TYPES, DEFAULT_PROMPT_PREFIX)5 unmodified linesdef __init__(self, app_state):super().__init__(app_state)self.id = "preview_tab"self.title = "5οΈβ£ Preview"def create(self, parent=None) -> gr.TabItem:"""Create the Preview tab UI components"""with gr.TabItem(self.title, id=self.id) as tab:with gr.Row():gr.Markdown("## Preview your model")with gr.Row():with gr.Column(scale=2):
5 unmodified lines67891011125 unmodified linesimport loggingfrom typing import Dict, Any, List, Optionalfrom .base_tab import BaseTablogger = logging.getLogger(__name__)5 unmodified lines67891011125 unmodified linesimport loggingfrom typing import Dict, Any, List, Optionalfrom vms.utils import BaseTablogger = logging.getLogger(__name__)
7 unmodified lines891011121314157 unmodified linesfrom typing import Dict, Any, List, Optional, Tuplefrom pathlib import Pathfrom .base_tab import BaseTabfrom ..config import (TRAINING_PRESETS, OUTPUT_PATH, MODEL_TYPES, ASK_USER_TO_DUPLICATE_SPACE, SMALL_TRAINING_BUCKETS, TRAINING_TYPES,DEFAULT_NB_TRAINING_STEPS, DEFAULT_SAVE_CHECKPOINT_EVERY_N_STEPS,DEFAULT_BATCH_SIZE, DEFAULT_CAPTION_DROPOUT_P,7 unmodified lines891011121314157 unmodified linesfrom typing import Dict, Any, List, Optional, Tuplefrom pathlib import Pathfrom vms.utils import BaseTabfrom vms.config import (TRAINING_PRESETS, OUTPUT_PATH, MODEL_TYPES, ASK_USER_TO_DUPLICATE_SPACE, SMALL_TRAINING_BUCKETS, TRAINING_TYPES,DEFAULT_NB_TRAINING_STEPS, DEFAULT_SAVE_CHECKPOINT_EVERY_N_STEPS,DEFAULT_BATCH_SIZE, DEFAULT_CAPTION_DROPOUT_P,
8 unmodified lines9101112131424 unmodified lines39404142438 unmodified linesfrom . import webdataset_handlerfrom .gpu_detector import get_available_gpu_count, get_gpu_info, get_recommended_precomputation_items__all__ = ['validate_model_repo',24 unmodified lines'get_available_gpu_count','get_gpu_info','get_recommended_precomputation_items']8 unmodified lines910111213141524 unmodified lines404142434445468 unmodified linesfrom . import webdataset_handlerfrom .gpu_detector import get_available_gpu_count, get_gpu_info, get_recommended_precomputation_itemsfrom .base_tab import BaseTab__all__ = ['validate_model_repo',24 unmodified lines'get_available_gpu_count','get_gpu_info','get_recommended_precomputation_items','BaseTab',]
14 unmodified lines1516171819202114 unmodified lines"""Initialize the tab with app state referenceArgs:app_state: Reference to main VideoTrainerUI instance"""self.app = app_stateself.components = {}14 unmodified lines1516171819202114 unmodified lines"""Initialize the tab with app state referenceArgs:app_state: Reference to main AppUI instance"""self.app = app_stateself.components = {}
app.py+2-2
vms/ui/__init__.py+2-2
vms/ui/video_trainer_ui.py β vms/ui/app_ui.pyRenamed+150-68
vms/ui/monitoring/services/__init__.pyAdded+5
vms/services/monitoring.py β vms/ui/monitoring/services/monitoring.pyRenamed
vms/ui/monitoring/tabs/__init__.pyAdded+9
vms/tabs/monitor_tab.py β vms/ui/monitoring/tabs/general_tab.pyRenamed+7-26
vms/ui/monitoring/utils/__init__.pyAdded+7
vms/ui/monitoring/utils/get_folder_size.pyAdded+22
vms/ui/monitoring/utils/human_readable_size.pyAdded+10
vms/services/__init__.py β vms/ui/project/services/__init__.pyRenamed-2
vms/services/captioning.py β vms/ui/project/services/captioning.pyRenamed+2-2
vms/services/importing/__init__.py β vms/ui/project/services/importing/__init__.pyRenamed
vms/services/importing/file_upload.py β vms/ui/project/services/importing/file_upload.pyRenamed
vms/services/importing/hub_dataset.py β vms/ui/project/services/importing/hub_dataset.pyRenamed+5-5
vms/services/importing/import_service.py β vms/ui/project/services/importing/import_service.pyRenamed+4-3
vms/services/importing/youtube.py β vms/ui/project/services/importing/youtube.pyRenamed
vms/services/previewing.py β vms/ui/project/services/previewing.pyRenamed
vms/services/splitting.py β vms/ui/project/services/splitting.pyRenamed+2-2
vms/services/training.py β vms/ui/project/services/training.pyRenamed+2-2
vms/tabs/__init__.py β vms/ui/project/tabs/__init__.pyRenamed+1-5
vms/tabs/caption_tab.py β vms/ui/project/tabs/caption_tab.pyRenamed+4-6
vms/tabs/import_tab/__init__.py β vms/ui/project/tabs/import_tab/__init__.pyRenamed
vms/tabs/import_tab/hub_tab.py β vms/ui/project/tabs/import_tab/hub_tab.pyRenamed+20-12
vms/tabs/import_tab/import_tab.py β vms/ui/project/tabs/import_tab/import_tab.pyRenamed+19-13
vms/tabs/import_tab/upload_tab.py β vms/ui/project/tabs/import_tab/upload_tab.pyRenamed+51-19
vms/tabs/import_tab/youtube_tab.py β vms/ui/project/tabs/import_tab/youtube_tab.pyRenamed+52-16
vms/tabs/manage_tab.py β vms/ui/project/tabs/manage_tab.pyRenamed+53-49
vms/tabs/preview_tab.py β vms/ui/project/tabs/preview_tab.pyRenamed+4-4
vms/tabs/split_tab.py β vms/ui/project/tabs/split_tab.pyRenamed+1-1
vms/tabs/train_tab.py β vms/ui/project/tabs/train_tab.pyRenamed+2-2
vms/utils/__init__.py+4-1
vms/tabs/base_tab.py β vms/utils/base_tab.pyRenamed+1-1