Spaces:
Build error
Build error
Julian Bilcke commited on
Commit Β·
82a6631
1
Parent(s): f407698
working on a fix for manual captions
Browse filesFiles changed (12)
- app.py+11-12
- vms/__init__.pyAdded
- captioning_service.py β vms/captioning_service.pyRenamed+34
- config.py β vms/config.pyRenamed
- finetrainers_utils.py β vms/finetrainers_utils.pyRenamed
- image_preprocessing.py β vms/image_preprocessing.pyRenamed
- import_service.py β vms/import_service.pyRenamed
- splitting_service.py β vms/splitting_service.pyRenamed
- training_log_parser.py β vms/training_log_parser.pyRenamed
- training_service.py β vms/training_service.pyRenamed+1-2
- utils.py β vms/utils.pyRenamed
- video_preprocessing.py β vms/video_preprocessing.pyRenamed
29 unmodified lines303132333435363738394041424344454647414 unmodified lines46246346446546646746846947047129 unmodified linesimport zipfilefrom typing import Any, Optional, Dict, List, Union, Tuplefrom typing import AsyncGeneratorfrom training_service import TrainingServicefrom captioning_service import CaptioningServicefrom splitting_service import SplittingServicefrom import_service import ImportServicefrom config import (STORAGE_PATH, VIDEOS_TO_SPLIT_PATH, STAGING_PATH,TRAINING_PATH, LOG_FILE_PATH, TRAINING_PRESETS, TRAINING_VIDEOS_PATH, MODEL_PATH, OUTPUT_PATH, DEFAULT_CAPTIONING_BOT_INSTRUCTIONS,DEFAULT_PROMPT_PREFIX, HF_API_TOKEN, ASK_USER_TO_DUPLICATE_SPACE, MODEL_TYPES, SMALL_TRAINING_BUCKETS)from utils import make_archive, count_media_files, format_media_title, is_image_file, is_video_file, validate_model_repo, format_timefrom finetrainers_utils import copy_files_to_training_dir, prepare_finetrainers_datasetfrom training_log_parser import TrainingLogParserlogger = logging.getLogger(__name__)logger.setLevel(logging.INFO)414 unmodified linesfull_caption = preview_captionpath = Path(preview_video if preview_video else preview_image)if path.suffix == '.txt':self.trainer.update_file_caption(path.with_suffix(''), full_caption)else:self.trainer.update_file_caption(path, full_caption)return gr.update(value="Caption saved successfully!")except Exception as e:return gr.update(value=f"Error saving caption: {str(e)}")29 unmodified lines30313233343536373839404142434445464748414 unmodified lines46346446546646746846947029 unmodified linesimport zipfilefrom typing import Any, Optional, Dict, List, Union, Tuplefrom typing import AsyncGeneratorfrom vms.training_service import TrainingServicefrom vms.captioning_service import CaptioningServicefrom vms.splitting_service import SplittingServicefrom vms.import_service import ImportServicefrom vms.config import (STORAGE_PATH, VIDEOS_TO_SPLIT_PATH, STAGING_PATH,TRAINING_PATH, LOG_FILE_PATH, TRAINING_PRESETS, TRAINING_VIDEOS_PATH, MODEL_PATH, OUTPUT_PATH, DEFAULT_CAPTIONING_BOT_INSTRUCTIONS,DEFAULT_PROMPT_PREFIX, HF_API_TOKEN, ASK_USER_TO_DUPLICATE_SPACE, MODEL_TYPES, SMALL_TRAINING_BUCKETS)from vms.utils import make_archive, count_media_files, format_media_title, is_image_file, is_video_file, validate_model_repo, format_timefrom vms.finetrainers_utils import copy_files_to_training_dir, prepare_finetrainers_datasetfrom vms.training_log_parser import TrainingLogParserlogger = logging.getLogger(__name__)logger.setLevel(logging.INFO)414 unmodified linesfull_caption = preview_captionpath = Path(preview_video if preview_video else preview_image)file_path = path.with_suffix('') if path.suffix == '.txt' else pathself.captioner.update_file_caption(file_path, full_caption)return gr.update(value="Caption saved successfully!")except Exception as e:return gr.update(value=f"Error saving caption: {str(e)}")
99 unmodified lines10010110210310410599 unmodified linescls._model_loading = Noneraiseasync def ensure_model_loaded(self):"""Ensure model is loaded before processing"""if USE_MOCK_CAPTIONING_MODEL:99 unmodified lines10010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813999 unmodified linescls._model_loading = Noneraisedef update_file_caption(self, file_path: Path, caption: str) -> None:"""Update caption for a training fileArgs:file_path: Path to the media filecaption: New caption text"""try:# Ensure we're working with Path objectsfile_path = Path(file_path)# Create the caption file pathcaption_path = file_path.with_suffix('.txt')# Write the new captioncaption_path.write_text(caption)logger.info(f"Updated caption for {file_path.name}")# the following code is disabled, because we want to make the copy to prompts.txt manual# If the file is in TRAINING_VIDEOS_PATH, update prompts.txt as well# if TRAINING_VIDEOS_PATH in file_path.parents:# # Try to update the training dataset# try:# prepare_finetrainers_dataset()# logger.info("Updated training dataset with new caption")# except Exception as e:# logger.warning(f"Could not update training dataset: {str(e)}")except Exception as e:logger.error(f"Error updating caption: {str(e)}")raiseasync def ensure_model_loaded(self):"""Ensure model is loaded before processing"""if USE_MOCK_CAPTIONING_MODEL:
211 unmodified lines212213214215216217218219211 unmodified linesexcept Exception as e:logger.error(f"Error during config validation: {str(e)}")return f"Configuration validation failed: {str(e)}"def start_training(self,model_type: str,211 unmodified lines212213214215216217218211 unmodified linesexcept Exception as e:logger.error(f"Error during config validation: {str(e)}")return f"Configuration validation failed: {str(e)}"def start_training(self,model_type: str,
app.py+11-12
vms/__init__.pyAdded
captioning_service.py β vms/captioning_service.pyRenamed+34
config.py β vms/config.pyRenamed
finetrainers_utils.py β vms/finetrainers_utils.pyRenamed
image_preprocessing.py β vms/image_preprocessing.pyRenamed
import_service.py β vms/import_service.pyRenamed
splitting_service.py β vms/splitting_service.pyRenamed
training_log_parser.py β vms/training_log_parser.pyRenamed
training_service.py β vms/training_service.pyRenamed+1-2
utils.py β vms/utils.pyRenamed
video_preprocessing.py β vms/video_preprocessing.pyRenamed