Spaces:
Paused
Paused
Update app.py
Browse files1499 unmodified lines150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821499 unmodified linesrepo_id = clean_repo_id(repo_id)paths = get_bucket_paths(repo_id)bf16_dir = paths["bf16"]files = api.list_repo_files(repo_id,repo_type="model")shards = sorted([ffor f in filesif (f.lower().endswith(".gguf")and "bf16" in f.lower())])if not shards:raise RuntimeError("No BF16 GGUF shards found")log(f"π¦ Found {len(shards)} BF16 shards")local_files = []for idx, shard in enumerate(shards,start=1):local_path = os.path.join(bf16_dir,os.path.basename(shard))if os.path.exists(local_path):log(f"β»οΈ SHARD {idx} already cached")else:log(f"π₯ Downloading shard {idx}/{len(shards)}")hf_hub_download(repo_id=repo_id,filename=shard,local_dir=bf16_dir,repo_type="model",token=HF_TOKEN)log(f"β Saved {os.path.basename(shard)}")show_bucket()local_files.append(local_path)create_bf16_flag(repo_id,[os.path.basename(x)for x in local_files])return local_files[0]# =====================================================1499 unmodified lines1500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401499 unmodified linesrepo_id = clean_repo_id(repo_id)project = get_project_name(repo_id)cache_dir = os.path.join(BUCKET_DIR,"gguf",project)os.makedirs(cache_dir,exist_ok=True)log(f"πͺ£ BUCKET CACHE:\n{cache_dir}")files = api.list_repo_files(repo_id,repo_type="model")shards = sorted([f for f in filesif (f.lower().endswith(".gguf")and "bf16" in f.lower())])if not shards:raise RuntimeError("No BF16 GGUF shards found")log(f"π¦ Found {len(shards)} shards")local_files = []for idx, remote in enumerate(shards,start=1):filename = os.path.basename(remote)local = os.path.join(cache_dir,filename)log(f"π₯ SHARD {idx}/{len(shards)}")log(remote)if os.path.exists(local):size = (os.path.getsize(local)/(1024**3))log(f"β»οΈ Already exists {size:.2f} GB")else:downloaded = hf_hub_download(repo_id=repo_id,filename=remote,repo_type="model",local_dir=cache_dir,token=HF_TOKEN,)if downloaded != local:shutil.move(downloaded,local)size = (os.path.getsize(local)/(1024**3))log(f"β Saved {size:.2f} GB")local_files.append(local)show_bucket()log("π ALL BF16 SHARDS READY")return local_files[0]# =====================================================
app.py+91-33