Bl4ckSpaces commited on
Commit
51815a8
·
verified ·
1 Parent(s): 02c1039

Release Speedster v16 Nitro (Auto-Upload)

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ sample_data/mnist_test.csv filter=lfs diff=lfs merge=lfs -text
37
+ sample_data/mnist_train_small.csv filter=lfs diff=lfs merge=lfs -text
sample_data/README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This directory includes a few sample datasets to get you started.
2
+
3
+ * `california_housing_data*.csv` is California housing data from the 1990 US
4
+ Census; more information is available at:
5
+ https://docs.google.com/document/d/e/2PACX-1vRhYtsvc5eOR2FWNCwaBiKL6suIOrxJig8LcSBbmCbyYsayia_DvPOOBlXZ4CAlQ5nlDD8kTaIDRwrN/pub
6
+
7
+ * `mnist_*.csv` is a small sample of the
8
+ [MNIST database](https://en.wikipedia.org/wiki/MNIST_database), which is
9
+ described at: http://yann.lecun.com/exdb/mnist/
10
+
11
+ * `anscombe.json` contains a copy of
12
+ [Anscombe's quartet](https://en.wikipedia.org/wiki/Anscombe%27s_quartet); it
13
+ was originally described in
14
+
15
+ Anscombe, F. J. (1973). 'Graphs in Statistical Analysis'. American
16
+ Statistician. 27 (1): 17-21. JSTOR 2682899.
17
+
18
+ and our copy was prepared by the
19
+ [vega_datasets library](https://github.com/altair-viz/vega_datasets/blob/4f67bdaad10f45e3549984e17e1b3088c731503d/vega_datasets/_data/anscombe.json).
sample_data/anscombe.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {"Series":"I", "X":10.0, "Y":8.04},
3
+ {"Series":"I", "X":8.0, "Y":6.95},
4
+ {"Series":"I", "X":13.0, "Y":7.58},
5
+ {"Series":"I", "X":9.0, "Y":8.81},
6
+ {"Series":"I", "X":11.0, "Y":8.33},
7
+ {"Series":"I", "X":14.0, "Y":9.96},
8
+ {"Series":"I", "X":6.0, "Y":7.24},
9
+ {"Series":"I", "X":4.0, "Y":4.26},
10
+ {"Series":"I", "X":12.0, "Y":10.84},
11
+ {"Series":"I", "X":7.0, "Y":4.81},
12
+ {"Series":"I", "X":5.0, "Y":5.68},
13
+
14
+ {"Series":"II", "X":10.0, "Y":9.14},
15
+ {"Series":"II", "X":8.0, "Y":8.14},
16
+ {"Series":"II", "X":13.0, "Y":8.74},
17
+ {"Series":"II", "X":9.0, "Y":8.77},
18
+ {"Series":"II", "X":11.0, "Y":9.26},
19
+ {"Series":"II", "X":14.0, "Y":8.10},
20
+ {"Series":"II", "X":6.0, "Y":6.13},
21
+ {"Series":"II", "X":4.0, "Y":3.10},
22
+ {"Series":"II", "X":12.0, "Y":9.13},
23
+ {"Series":"II", "X":7.0, "Y":7.26},
24
+ {"Series":"II", "X":5.0, "Y":4.74},
25
+
26
+ {"Series":"III", "X":10.0, "Y":7.46},
27
+ {"Series":"III", "X":8.0, "Y":6.77},
28
+ {"Series":"III", "X":13.0, "Y":12.74},
29
+ {"Series":"III", "X":9.0, "Y":7.11},
30
+ {"Series":"III", "X":11.0, "Y":7.81},
31
+ {"Series":"III", "X":14.0, "Y":8.84},
32
+ {"Series":"III", "X":6.0, "Y":6.08},
33
+ {"Series":"III", "X":4.0, "Y":5.39},
34
+ {"Series":"III", "X":12.0, "Y":8.15},
35
+ {"Series":"III", "X":7.0, "Y":6.42},
36
+ {"Series":"III", "X":5.0, "Y":5.73},
37
+
38
+ {"Series":"IV", "X":8.0, "Y":6.58},
39
+ {"Series":"IV", "X":8.0, "Y":5.76},
40
+ {"Series":"IV", "X":8.0, "Y":7.71},
41
+ {"Series":"IV", "X":8.0, "Y":8.84},
42
+ {"Series":"IV", "X":8.0, "Y":8.47},
43
+ {"Series":"IV", "X":8.0, "Y":7.04},
44
+ {"Series":"IV", "X":8.0, "Y":5.25},
45
+ {"Series":"IV", "X":19.0, "Y":12.50},
46
+ {"Series":"IV", "X":8.0, "Y":5.56},
47
+ {"Series":"IV", "X":8.0, "Y":7.91},
48
+ {"Series":"IV", "X":8.0, "Y":6.89}
49
+ ]
sample_data/california_housing_test.csv ADDED
The diff for this file is too large to render. See raw diff
 
sample_data/california_housing_train.csv ADDED
The diff for this file is too large to render. See raw diff
 
sample_data/mnist_test.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:51c292478d94ec3a01461bdfa82eb0885d262eb09e615679b2d69dedb6ad09e7
3
+ size 18289443
sample_data/mnist_train_small.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ef64781aa03180f4f5ce504314f058f5d0227277df86060473d973cf43b033e
3
+ size 36523880
setup.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="speedster",
5
+ version="16.0.0",
6
+ packages=find_packages(),
7
+ install_requires=[
8
+ "aiohttp>=3.9.0",
9
+ "tqdm>=4.66.0",
10
+ "nest_asyncio",
11
+ "requests"
12
+ ],
13
+ author="Bl4ckSpaces",
14
+ description="Ultra-fast, asynchronous, memory-efficient universal downloader (Nitro Edition).",
15
+ keywords="downloader, aiohttp, async, civitai, huggingface, speedster",
16
+ python_requires=">=3.8",
17
+ )
speedster/__init__.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import asyncio
3
+ import aiohttp
4
+ import urllib.parse
5
+ from tqdm.asyncio import tqdm
6
+ import nest_asyncio
7
+
8
+ # Apply nest_asyncio to allow running asyncio in Jupyter/Colab notebooks
9
+ nest_asyncio.apply()
10
+
11
+ class Speedster:
12
+ def __init__(self, num_threads=16, chunk_size_mb=2):
13
+ self.num_threads = num_threads
14
+ self.chunk_size = chunk_size_mb * 1024 * 1024 # Buffer in bytes
15
+
16
+ # Headers samaran agar dianggap browser (Anti-Block)
17
+ self.default_headers = {
18
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
19
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
20
+ "Accept-Language": "en-US,en;q=0.5",
21
+ }
22
+
23
+ async def _fetch_chunk(self, session, url, start, end, fd, headers, pbar):
24
+ chunk_headers = headers.copy()
25
+ chunk_headers['Range'] = f'bytes={start}-{end}'
26
+
27
+ try:
28
+ async with session.get(url, headers=chunk_headers, timeout=60) as response:
29
+ response.raise_for_status()
30
+ offset = start
31
+
32
+ async for chunk in response.content.iter_chunked(self.chunk_size):
33
+ if chunk:
34
+ # [CORE MAGIC] os.pwrite langsung ke disk tanpa locking python
35
+ os.pwrite(fd, chunk, offset)
36
+ offset += len(chunk)
37
+ pbar.update(len(chunk))
38
+ except Exception as e:
39
+ # Silent retry mechanism could be added here
40
+ print(f"⚠️ Chunk Error: {e}")
41
+ raise
42
+
43
+ async def _download_logic(self, url, dest_path, headers):
44
+ async with aiohttp.ClientSession() as session:
45
+ # 1. Get Metadata
46
+ async with session.get(url, headers=headers, allow_redirects=True) as response:
47
+ final_url = response.url
48
+ total_size = int(response.headers.get('Content-Length', 0))
49
+
50
+ if os.path.isdir(dest_path):
51
+ if 'Content-Disposition' in response.headers:
52
+ try:
53
+ cd = response.headers['Content-Disposition']
54
+ filename = cd.split('filename=')[1].strip('"')
55
+ except:
56
+ filename = os.path.basename(urllib.parse.urlparse(str(final_url)).path)
57
+ else:
58
+ filename = os.path.basename(urllib.parse.urlparse(str(final_url)).path)
59
+
60
+ if not filename: filename = "downloaded_file.bin"
61
+ dest_path = os.path.join(dest_path, filename)
62
+
63
+ if total_size == 0:
64
+ print(f"❌ Server menolak memberikan ukuran file. Download gagal.")
65
+ return
66
+
67
+ print(f"🚀 [Speedster Nitro] Target: {dest_path} | Size: {total_size / (1024**3):.2f} GB")
68
+
69
+ # 2. Chunking
70
+ chunk_size = total_size // self.num_threads
71
+ chunks = []
72
+ for i in range(self.num_threads):
73
+ start = i * chunk_size
74
+ end = total_size - 1 if i == self.num_threads - 1 else (start + chunk_size - 1)
75
+ chunks.append((start, end))
76
+
77
+ # 3. Allocating Disk (Zero-Fill)
78
+ fd = os.open(dest_path, os.O_RDWR | os.O_CREAT)
79
+ os.ftruncate(fd, total_size)
80
+
81
+ # 4. Fire Async Workers
82
+ pbar = tqdm(total=total_size, unit='iB', unit_scale=True, unit_divisor=1024, desc="⚡ SPEEDSTER")
83
+ tasks = []
84
+ for start, end in chunks:
85
+ task = asyncio.create_task(self._fetch_chunk(session, final_url, start, end, fd, headers, pbar))
86
+ tasks.append(task)
87
+
88
+ await asyncio.gather(*tasks)
89
+ pbar.close()
90
+ os.close(fd)
91
+ print("✅ Download Selesai!")
92
+
93
+ def download(self, url, dest_path="/content", token=None):
94
+ headers = self.default_headers.copy()
95
+ if token:
96
+ headers["Authorization"] = f"Bearer {token}"
97
+
98
+ loop = asyncio.get_event_loop()
99
+ if loop.is_running():
100
+ # Jika sudah dalam event loop (seperti di Colab)
101
+ asyncio.create_task(self._download_logic(url, dest_path, headers))
102
+ else:
103
+ asyncio.run(self._download_logic(url, dest_path, headers))
104
+
105
+ # Wrapper Global
106
+ def download(url, dest_path="/content", token=None, threads=16):
107
+ engine = Speedster(num_threads=threads)
108
+ engine.download(url, dest_path, token)