File size: 1,282 Bytes
8eaaeca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | """One-shot: mirror MiniMax H3 turbo LoRAs from civitai.red to HF."""
import os
import time
import urllib.request
from huggingface_hub import HfApi
REPO = "nikdevs/minimax-h3-loras"
FILES = {
"minimax_h3_fl2v_turbo_8step_v1.0_comfyui_bf16.safetensors": "https://civitai.red/api/download/models/3219337",
"minimax_h3_fl2v_turbo_4step_v1.0_768p_comfyui_bf16.safetensors": "https://civitai.red/api/download/models/3219346",
}
api = HfApi()
api.create_repo(REPO, exist_ok=True, private=False)
existing = {s.rfilename for s in api.repo_info(REPO).siblings}
for name, url in FILES.items():
if name in existing:
print(f"[skip] {name}", flush=True)
continue
t0 = time.time()
print(f"[dl] {name}", flush=True)
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
with urllib.request.urlopen(req, timeout=600) as r, open(f"/tmp/{name}", "wb") as f:
while chunk := r.read(1 << 22):
f.write(chunk)
print(f"[dl] done {time.time()-t0:.0f}s, uploading", flush=True)
api.upload_file(path_or_fileobj=f"/tmp/{name}", path_in_repo=name, repo_id=REPO)
os.remove(f"/tmp/{name}")
print(f"[up] done {time.time()-t0:.0f}s total", flush=True)
print("LORA MIRROR DONE", flush=True)
time.sleep(10 ** 6)
|