Xinyi0214 commited on
Commit
fe577bb
·
verified ·
1 Parent(s): 03a5ae2

Add upload_to_shared: push results to HuggingFriends generated_data/<model>_<variant>

Browse files
Files changed (1) hide show
  1. ge_modal_app.py +37 -0
ge_modal_app.py CHANGED
@@ -438,6 +438,43 @@ def clean_frames(source: str):
438
  return len(to_del)
439
 
440
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
  # ==========================================================================
442
  # 本地编排入口:modal run ge_modal_app.py
443
  # ==========================================================================
 
438
  return len(to_del)
439
 
440
 
441
+ # ==========================================================================
442
+ # 把结果上传到「共享数据集」的 generated_data/<model>_<variant>/ 下
443
+ # 结构与搭档 wan26_flash 一致:data/<source>/generated_data/<model>_<variant>/<task>/<episode>/1/
444
+ # ⚠️ 目标是 HuggingFriends 共享仓库,secret 里的 HF_TOKEN 需对该 org 有写权限
445
+ # ==========================================================================
446
+ @app.function(
447
+ image=image,
448
+ volumes={OUT_DIR: output_vol},
449
+ secrets=[modal.Secret.from_name("huggingface-secret")],
450
+ timeout=60 * 60,
451
+ )
452
+ def upload_to_shared(
453
+ source: str,
454
+ variant: str, # "prefix" 或 "rewrite"
455
+ model_name: str = "genie", # 文件夹名 <model_name>_<variant>,对齐搭档 wan26_flash 风格
456
+ repo_id: str = "HuggingFriends/mllm-as-embodied-world-judge",
457
+ ):
458
+ import os
459
+ from huggingface_hub import HfApi
460
+ api = HfApi(token=os.environ["HF_TOKEN"])
461
+ # 我们 volume 里的目录名是 prompt_prefix / prompt_rewrite
462
+ src_dir = os.path.join(OUT_DIR, source, f"prompt_{variant}")
463
+ if not os.path.isdir(src_dir):
464
+ print(f"⚠️ {src_dir} 不存在,跳过(该 source/variant 还没生成?)")
465
+ return
466
+ path_in_repo = f"data/{source}/generated_data/{model_name}_{variant}"
467
+ api.upload_folder(
468
+ folder_path=src_dir,
469
+ path_in_repo=path_in_repo,
470
+ repo_id=repo_id,
471
+ repo_type="dataset",
472
+ ignore_patterns=["**/video/**"], # 只传 mp4 + prompt,不传抽帧
473
+ commit_message=f"Add {model_name} {variant} results: {source}",
474
+ )
475
+ print(f"✅ {source}/{variant} -> {repo_id}/{path_in_repo}")
476
+
477
+
478
  # ==========================================================================
479
  # 本地编排入口:modal run ge_modal_app.py
480
  # ==========================================================================