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 lines303132333334353637343536373839404142424344434445464748414 unmodified lines46346446546546646746846646746846947029 unmodified linesimport zipfilefrom typing import Any, Optional, Dict, List, Union, Tuplefrom typing import AsyncGenerator
from training_service import TrainingServicefrom captioning_service import CaptioningServicefrom splitting_service import SplittingServicefrom import_service import ImportServicefrom config import (from 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 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 TrainingLogParserfrom 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 TrainingLogParser
logger = logging.getLogger(__name__)logger.setLevel(logging.INFO)414 unmodified lines full_caption = preview_caption path = 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) file_path = path.with_suffix('') if path.suffix == '.txt' else path self.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 lines10010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813999 unmodified lines cls._model_loading = None raise
def update_file_caption(self, file_path: Path, caption: str) -> None: """Update caption for a training file Args: file_path: Path to the media file caption: New caption text """ try: # Ensure we're working with Path objects file_path = Path(file_path) # Create the caption file path caption_path = file_path.with_suffix('.txt') # Write the new caption caption_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)}") raise async def ensure_model_loaded(self): """Ensure model is loaded before processing""" if USE_MOCK_CAPTIONING_MODEL:211 unmodified lines212213214215216215216217218211 unmodified lines except 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