Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1500,83 +1500,141 @@ def download_gguf_set(
|
|
| 1500 |
|
| 1501 |
repo_id = clean_repo_id(repo_id)
|
| 1502 |
|
| 1503 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1504 |
|
| 1505 |
-
bf16_dir = paths["bf16"]
|
| 1506 |
|
| 1507 |
files = api.list_repo_files(
|
| 1508 |
repo_id,
|
| 1509 |
repo_type="model"
|
| 1510 |
)
|
| 1511 |
|
| 1512 |
-
|
| 1513 |
-
|
| 1514 |
-
|
| 1515 |
-
|
| 1516 |
-
|
| 1517 |
-
|
| 1518 |
-
|
| 1519 |
-
|
|
|
|
|
|
|
|
|
|
| 1520 |
|
| 1521 |
if not shards:
|
|
|
|
| 1522 |
raise RuntimeError(
|
| 1523 |
"No BF16 GGUF shards found"
|
| 1524 |
)
|
| 1525 |
|
|
|
|
| 1526 |
log(
|
| 1527 |
-
f"π¦ Found {len(shards)}
|
| 1528 |
)
|
| 1529 |
|
|
|
|
| 1530 |
local_files = []
|
| 1531 |
|
| 1532 |
-
|
|
|
|
| 1533 |
shards,
|
| 1534 |
start=1
|
| 1535 |
):
|
| 1536 |
|
| 1537 |
-
|
| 1538 |
-
|
| 1539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1540 |
)
|
| 1541 |
|
| 1542 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1543 |
|
| 1544 |
log(
|
| 1545 |
-
f"β»οΈ
|
| 1546 |
)
|
| 1547 |
|
| 1548 |
else:
|
| 1549 |
|
| 1550 |
-
|
| 1551 |
-
f"π₯ Downloading shard {idx}/{len(shards)}"
|
| 1552 |
-
)
|
| 1553 |
|
| 1554 |
-
hf_hub_download(
|
| 1555 |
repo_id=repo_id,
|
| 1556 |
-
|
| 1557 |
-
|
|
|
|
| 1558 |
repo_type="model",
|
| 1559 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1560 |
)
|
| 1561 |
|
| 1562 |
log(
|
| 1563 |
-
f"β
Saved {
|
| 1564 |
)
|
| 1565 |
|
| 1566 |
-
show_bucket()
|
| 1567 |
|
| 1568 |
local_files.append(
|
| 1569 |
-
|
| 1570 |
)
|
| 1571 |
|
| 1572 |
-
|
| 1573 |
-
|
| 1574 |
-
|
| 1575 |
-
|
| 1576 |
-
|
| 1577 |
-
|
| 1578 |
)
|
| 1579 |
|
|
|
|
| 1580 |
return local_files[0]
|
| 1581 |
|
| 1582 |
# =====================================================
|
|
|
|
| 1500 |
|
| 1501 |
repo_id = clean_repo_id(repo_id)
|
| 1502 |
|
| 1503 |
+
project = get_project_name(repo_id)
|
| 1504 |
+
|
| 1505 |
+
cache_dir = os.path.join(
|
| 1506 |
+
BUCKET_DIR,
|
| 1507 |
+
"gguf",
|
| 1508 |
+
project
|
| 1509 |
+
)
|
| 1510 |
+
|
| 1511 |
+
os.makedirs(
|
| 1512 |
+
cache_dir,
|
| 1513 |
+
exist_ok=True
|
| 1514 |
+
)
|
| 1515 |
+
|
| 1516 |
+
log(
|
| 1517 |
+
f"πͺ£ BUCKET CACHE:\n{cache_dir}"
|
| 1518 |
+
)
|
| 1519 |
|
|
|
|
| 1520 |
|
| 1521 |
files = api.list_repo_files(
|
| 1522 |
repo_id,
|
| 1523 |
repo_type="model"
|
| 1524 |
)
|
| 1525 |
|
| 1526 |
+
|
| 1527 |
+
shards = sorted(
|
| 1528 |
+
[
|
| 1529 |
+
f for f in files
|
| 1530 |
+
if (
|
| 1531 |
+
f.lower().endswith(".gguf")
|
| 1532 |
+
and "bf16" in f.lower()
|
| 1533 |
+
)
|
| 1534 |
+
]
|
| 1535 |
+
)
|
| 1536 |
+
|
| 1537 |
|
| 1538 |
if not shards:
|
| 1539 |
+
|
| 1540 |
raise RuntimeError(
|
| 1541 |
"No BF16 GGUF shards found"
|
| 1542 |
)
|
| 1543 |
|
| 1544 |
+
|
| 1545 |
log(
|
| 1546 |
+
f"π¦ Found {len(shards)} shards"
|
| 1547 |
)
|
| 1548 |
|
| 1549 |
+
|
| 1550 |
local_files = []
|
| 1551 |
|
| 1552 |
+
|
| 1553 |
+
for idx, remote in enumerate(
|
| 1554 |
shards,
|
| 1555 |
start=1
|
| 1556 |
):
|
| 1557 |
|
| 1558 |
+
filename = os.path.basename(
|
| 1559 |
+
remote
|
| 1560 |
+
)
|
| 1561 |
+
|
| 1562 |
+
local = os.path.join(
|
| 1563 |
+
cache_dir,
|
| 1564 |
+
filename
|
| 1565 |
+
)
|
| 1566 |
+
|
| 1567 |
+
|
| 1568 |
+
log(
|
| 1569 |
+
f"π₯ SHARD {idx}/{len(shards)}"
|
| 1570 |
+
)
|
| 1571 |
+
|
| 1572 |
+
log(
|
| 1573 |
+
remote
|
| 1574 |
)
|
| 1575 |
|
| 1576 |
+
|
| 1577 |
+
if os.path.exists(local):
|
| 1578 |
+
|
| 1579 |
+
size = (
|
| 1580 |
+
os.path.getsize(local)
|
| 1581 |
+
/
|
| 1582 |
+
(1024**3)
|
| 1583 |
+
)
|
| 1584 |
|
| 1585 |
log(
|
| 1586 |
+
f"β»οΈ Already exists {size:.2f} GB"
|
| 1587 |
)
|
| 1588 |
|
| 1589 |
else:
|
| 1590 |
|
| 1591 |
+
downloaded = hf_hub_download(
|
|
|
|
|
|
|
| 1592 |
|
|
|
|
| 1593 |
repo_id=repo_id,
|
| 1594 |
+
|
| 1595 |
+
filename=remote,
|
| 1596 |
+
|
| 1597 |
repo_type="model",
|
| 1598 |
+
|
| 1599 |
+
local_dir=cache_dir,
|
| 1600 |
+
|
| 1601 |
+
token=HF_TOKEN,
|
| 1602 |
+
|
| 1603 |
+
)
|
| 1604 |
+
|
| 1605 |
+
|
| 1606 |
+
if downloaded != local:
|
| 1607 |
+
|
| 1608 |
+
shutil.move(
|
| 1609 |
+
downloaded,
|
| 1610 |
+
local
|
| 1611 |
+
)
|
| 1612 |
+
|
| 1613 |
+
|
| 1614 |
+
size = (
|
| 1615 |
+
os.path.getsize(local)
|
| 1616 |
+
/
|
| 1617 |
+
(1024**3)
|
| 1618 |
)
|
| 1619 |
|
| 1620 |
log(
|
| 1621 |
+
f"β
Saved {size:.2f} GB"
|
| 1622 |
)
|
| 1623 |
|
|
|
|
| 1624 |
|
| 1625 |
local_files.append(
|
| 1626 |
+
local
|
| 1627 |
)
|
| 1628 |
|
| 1629 |
+
|
| 1630 |
+
show_bucket()
|
| 1631 |
+
|
| 1632 |
+
|
| 1633 |
+
log(
|
| 1634 |
+
"π ALL BF16 SHARDS READY"
|
| 1635 |
)
|
| 1636 |
|
| 1637 |
+
|
| 1638 |
return local_files[0]
|
| 1639 |
|
| 1640 |
# =====================================================
|