Spaces:
Paused
Paused
Update app.py
Browse files1499 unmodified lines1500150115021503150315041505150615071508150915101511151215131514151515161517151815191505152015211522152315241525152615121513151415151516151715181519152715281529153015311532153315341535153615371538153915401541154215431544154515271546154715481549155015511552153215531554155515561557153715381539155815591560156115621563156415651566156715681569157015711572157315741575157615421577157815791580158115821583158415851545158615871588158915901550155115521591159215541593155615571594159515961597159815991600155916011602160316041605160616071608160916101611161216131614161516161617161816191620156316211622162315661624162515691626162716281572157315741575157615771629163016311632163316341635163616371638163916401499 unmodified lines
repo_id = clean_repo_id(repo_id)
paths = get_bucket_paths(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}" )
bf16_dir = paths["bf16"]
files = api.list_repo_files( repo_id, repo_type="model" )
shards = sorted([ f for f in files if ( f.lower().endswith(".gguf") and "bf16" in f.lower() ) ]) shards = sorted( [ f for f in files if ( 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" f"π¦ Found {len(shards)} shards" )
local_files = []
for idx, shard in enumerate( for idx, remote in enumerate( shards, start=1 ):
local_path = os.path.join( bf16_dir, os.path.basename(shard) 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_path): if os.path.exists(local):
size = ( os.path.getsize(local) / (1024**3) )
log( f"β»οΈ SHARD {idx} already cached" f"β»οΈ Already exists {size:.2f} GB" )
else:
log( f"π₯ Downloading shard {idx}/{len(shards)}" ) downloaded = hf_hub_download(
hf_hub_download( repo_id=repo_id, filename=shard, local_dir=bf16_dir,
filename=remote,
repo_type="model",
local_dir=cache_dir,
token=HF_TOKEN token=HF_TOKEN,
)
if downloaded != local:
shutil.move( downloaded, local )
size = ( os.path.getsize(local) / (1024**3) )
log( f"β
Saved {os.path.basename(shard)}" f"β
Saved {size:.2f} GB" )
show_bucket()
local_files.append( local_path local )
create_bf16_flag( repo_id, [ os.path.basename(x) for x in local_files ]
show_bucket()
log( "π ALL BF16 SHARDS READY" )
return local_files[0]
# =====================================================app.py+91-33