Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Honor a request for no music when the starter's score is left in the prompt
Bowen Xued019e97d3af1
diff --git a/freevideo_engine/encode.py b/freevideo_engine/encode.pyindex 0a621bd..de9f8ad 100644--- a/freevideo_engine/encode.py+++ b/freevideo_engine/encode.py@@ -8,6 +8,7 @@ from .generate import childfrom .hardware import detectfrom .kernel_capabilities import available_backendsfrom .locking import runtime_lock, LOCK_ENV+from .music_request import without_musicfrom .paths import comfy_rootfrom .policy import choosefrom . import processes@@ -31,7 +32,7 @@ def run(args):try:with runtime_lock() as descriptor, tempfile.TemporaryDirectory(prefix='freevideo-encode-', dir=destination.parent) as directory:request = Path(directory) / 'request.json'- request.write_text(json.dumps({'prompt': args.prompt_file.read_text(encoding='utf-8'), 'encoder': args.encoder,+ request.write_text(json.dumps({'prompt': without_music(args.prompt_file.read_text(encoding='utf-8')), 'encoder': args.encoder,'comfy_root': str(args.comfy_root or comfy_root()),'model_paths': str(args.model_paths.resolve()) if args.model_paths else None,'output': str(destination), 'gpu_budget_gb': policy.gpu_budget_bytes / 1e9,diff --git a/freevideo_engine/generate.py b/freevideo_engine/generate.pyindex 3a97b5a..b91e6f4 100644--- a/freevideo_engine/generate.py+++ b/freevideo_engine/generate.py@@ -21,6 +21,7 @@ from .locking import runtime_lock, LOCK_ENVfrom .paths import vdn_root, comfy_rootfrom .monitoring import savefrom .encoder_checkpoint import preflight_encoder+from .music_request import without_musicfrom . import tuningfrom . import processesfrom .system import (inference_headroom, inference_memory_sample, inference_environment, memory_sample,@@ -841,6 +842,7 @@ def _run(args):# The saved prompt stays the user's own; the model is also told what the picture is.from .continuation import first_frame_promptprompt_text = first_frame_prompt(prompt_text)+ prompt_text = without_music(prompt_text)encoding = {'prompt': prompt_text, 'encoder': args.encoder,'comfy_root': str(args.comfy_root or comfy_root()),'model_paths': str(args.model_paths.resolve()) if args.model_paths else None,diff --git a/freevideo_engine/macos_generate.py b/freevideo_engine/macos_generate.pyindex 7f3400e..260efa1 100644--- a/freevideo_engine/macos_generate.py+++ b/freevideo_engine/macos_generate.py@@ -19,6 +19,7 @@ from . import processesfrom .geometry import geometryfrom .locking import LOCK_ENV, runtime_lockfrom .monitoring import save+from .music_request import without_musicfrom .paths import data_rootGiB = 2**30@@ -278,9 +279,13 @@ def run(args):if not prompt.strip() and not getattr(args, 'allow_empty_prompt', False):raise ValueError('A nonempty prompt is required')prompt_file = Path(args.prompt_file).resolve()+ encoder_prompt = promptif report.get('first_frame_reference', {}).get('used'):from .continuation import first_frame_prompt- prompt = first_frame_prompt(prompt)+ encoder_prompt = first_frame_prompt(encoder_prompt)+ encoder_prompt = without_music(encoder_prompt)+ if encoder_prompt != prompt:+ prompt = encoder_promptprompt_file = artifacts / 'encoder-prompt.txt'prompt_file.write_text(prompt, encoding='utf-8')checkpoint = encoder_checkpoint(args)diff --git a/freevideo_engine/music_request.py b/freevideo_engine/music_request.pynew file mode 100644index 0000000..e2cf17d--- /dev/null+++ b/freevideo_engine/music_request.py@@ -0,0 +1,64 @@+"""Whether a prompt asks for no music, and what that means for the score the model is given.++H3 reads the score from its own `non_diegetic_music` section. The starter prompt carries a full+score there, so a user who adds "no background music" to the scene text but leaves that section+as it came still gets the score. Only that untouched starter text is replaced by `N/A`; a score+the user wrote stays as written.+"""+import re++from .default_prompt import DEFAULT_PROMPT++SECTION = re.compile(r'(?m)^[ \t]*non_diegetic_music[ \t]*:[ \t]*(.*?)(?=\n\s*\n|\Z)', re.S)+NOTE = 'non_diegetic_music: N/A'+++def _words(text):+ return ' '.join(text.split())+++STARTER_MUSIC = _words(SECTION.search(DEFAULT_PROMPT).group(1))++# A music word that is not another noun: "music video", "music stand", 音乐会.+_EN_TERM = (r'(?:(?:background|backing|ambient|incidental|film|movie|cinematic)\s+)*'+ r'(?:music(?!al\b|ian|\s+(?:video|stand|box|hall|store|shop|school|class|player|room|note|sheet|book|'+ r'festival|stage|teacher|lesson))|bgm\b|soundtrack|musical\s+(?:score|accompaniment)|'+ r'(?:background|film|movie)\s+score|backing\s+track)')+_EN_FILLER = (r'(?:\s+(?:to|the|any|a|an|of|add|include|use|play|put|have|want|need|generate|create|make|produce|'+ r'insert|bring|with|in|on|over|under|any\s+kind\s+of|kind\s+of|sort\s+of|type\s+of|form\s+of)){0,5}')+_EN = [+ re.compile(r'\b(?:no|without|zero)\s+(?:(?:any|the|extra|added|additional)\s+){0,2}' + _EN_TERM, re.I),+ re.compile(r"\b(?:do\s*n[o']t|do\s+not|don[’']t|never|avoid|omit|exclude|skip|remove|mute|disable|"+ r'turn\s+off|leave\s+out|cut)\b' + _EN_FILLER + r'\s+' + _EN_TERM, re.I),+ re.compile(r'\b(?:music|bgm|soundtrack)[- ]free\b|\bfree\s+of\s+' + _EN_TERM + r'|\bno-music\b', re.I),+]++_ZH_TERM = r'(?:背景音乐|背景乐|背景配乐|电影配乐|配乐|伴奏|[Bb][Gg][Mm]|音乐(?!会|剧|人|家|盒|厅|节|学|课|教室|剧院|视频|短片|[Mm][Vv]|老师))'+_ZH_NEG = (r'(?:不要|不用|无需|不需要|不想要|不能有|不可以有|不得有|不许有|严禁|禁止|别|勿|去掉|去除|删掉|删除|取消|关闭|关掉|'+ r'没有|无|不带|不加|不配|不含|不放|不出现|不添加|不使用|不生成|不包含|不要有|不要加|不要带|不要配|不要放)')+_ZH_FILLER = r'(?:任何|任何的|任何形式的|一切|所有|的|有|加|带|配|放|要|出现|添加|使用|生成|含|包含|额外|多余|额外的|多余的|任何额外的){0,3}'+_ZH = [+ re.compile(_ZH_NEG + _ZH_FILLER + _ZH_TERM),+ re.compile(_ZH_TERM + r'(?:请)?(?:不要|不用|不需要|无需|关闭|关掉|去掉|去除|取消|删掉)'),+]+++def asks_for_no_music(text):+ """True when the prompt text says, in English or Chinese, that it wants no music."""+ return isinstance(text, str) and any(each.search(text) for each in _EN + _ZH)+++def writes_own_music(text):+ """True when the prompt has a score section that is neither the starter's nor N/A."""+ found = SECTION.search(text)+ return bool(found) and _words(found.group(1)) not in (STARTER_MUSIC, 'N/A', '')+++def without_music(text):+ """The prompt with the starter's score replaced by `N/A` when the scene text asks for no music."""+ if not asks_for_no_music(text):+ return text+ found = SECTION.search(text)+ if not found or _words(found.group(1)) != STARTER_MUSIC:+ return text+ return text[:found.start()] + NOTE + text[found.end():]diff --git a/freevideo_engine/prompt_vlm/rules.py b/freevideo_engine/prompt_vlm/rules.pyindex 20b6579..2c6384c 100644--- a/freevideo_engine/prompt_vlm/rules.py+++ b/freevideo_engine/prompt_vlm/rules.py@@ -6,6 +6,8 @@ The public guide describes a prompt format, not a released Context-IR model.import mathimport re+from ..music_request import asks_for_no_music, writes_own_music+BASE_FIELDS = ('integrated_multimodal_description', 'overall_soundscape', 'non_diegetic_music')REF_FIELDS = ('subject_definitions', 'summary', 'retention_analysis', 'detailed_description','overall_soundscape', 'non_diegetic_music')@@ -180,6 +182,9 @@ def validate_output(text, value):for each in required:if each not in text:raise InvalidOutput('missing_picture_reference', text, value)+ if asks_for_no_music(value['text']) and not writes_own_music(value['text']):+ # Asked for no music, and no score of the user's own: the score section says so whatever the rewrite wrote.+ text = re.sub(r'^non_diegetic_music:.*\Z', 'non_diegetic_music: N/A', text, flags=re.M | re.S)return dialogue(text, value['text'])