Instructions to use keypa/MoonViT-V2-Standalone with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use keypa/MoonViT-V2-Standalone with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="keypa/MoonViT-V2-Standalone")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("keypa/MoonViT-V2-Standalone", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload build_agentic_images.py with huggingface_hub
Browse files- build_agentic_images.py +29 -6
build_agentic_images.py
CHANGED
|
@@ -97,16 +97,25 @@ def _url_to_relpath(url):
|
|
| 97 |
return m.group(1) if m else url
|
| 98 |
|
| 99 |
|
| 100 |
-
def local_parquet_shards(dataset, needed_max_idx, counts):
|
| 101 |
-
"""
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
paths = []
|
| 105 |
-
for u in urls:
|
| 106 |
rel = _url_to_relpath(u)
|
|
|
|
| 107 |
p = hf_hub_download(repo_id=dataset, repo_type="dataset",
|
| 108 |
filename=rel, revision="refs/convert/parquet")
|
| 109 |
paths.append(p)
|
|
|
|
| 110 |
return paths
|
| 111 |
|
| 112 |
|
|
@@ -169,7 +178,21 @@ def aguvis_manifest_path(name):
|
|
| 169 |
|
| 170 |
|
| 171 |
def load_aguvis_manifest(name):
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
return json.load(f)
|
| 174 |
|
| 175 |
|
|
|
|
| 97 |
return m.group(1) if m else url
|
| 98 |
|
| 99 |
|
| 100 |
+
def local_parquet_shards(dataset, needed_max_idx, counts=None):
|
| 101 |
+
"""Resume-safe, CDN-cached download of the shards covering needed_max_idx.
|
| 102 |
+
|
| 103 |
+
`counts` is ignored on purpose (kept for call-site compatibility); we always
|
| 104 |
+
ask HF for the full shard path set and let hf_hub_download's cache do the work.
|
| 105 |
+
"""
|
| 106 |
+
if counts is None:
|
| 107 |
+
counts = [None] # placeholder; hf_hub_download does not need row counts
|
| 108 |
+
n = shards_covering(counts, needed_max_idx) if counts[0] is not None else None
|
| 109 |
+
urls = get_parquet_shard_urls(dataset)
|
| 110 |
+
urls = urls[:n] if n else urls
|
| 111 |
paths = []
|
| 112 |
+
for i, u in enumerate(urls):
|
| 113 |
rel = _url_to_relpath(u)
|
| 114 |
+
# idempotent: re-uses the global HF hub cache
|
| 115 |
p = hf_hub_download(repo_id=dataset, repo_type="dataset",
|
| 116 |
filename=rel, revision="refs/convert/parquet")
|
| 117 |
paths.append(p)
|
| 118 |
+
print(f" [dl] {dataset} shard {i+1}/{len(urls)} -> {os.path.basename(p)}")
|
| 119 |
return paths
|
| 120 |
|
| 121 |
|
|
|
|
| 178 |
|
| 179 |
|
| 180 |
def load_aguvis_manifest(name):
|
| 181 |
+
"""Load the per-subset manifest. Falls back to fetching from HF Hub if missing."""
|
| 182 |
+
path = aguvis_manifest_path(name)
|
| 183 |
+
if not os.path.exists(path):
|
| 184 |
+
os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
|
| 185 |
+
print(f" [aguvis] {name}-l1.json not on disk; fetching from HF hub ...")
|
| 186 |
+
fetched = hf_hub_download(
|
| 187 |
+
repo_id="xlangai/aguvis-stage2",
|
| 188 |
+
repo_type="dataset",
|
| 189 |
+
filename=f"{name}-l1.json",
|
| 190 |
+
local_files_only=False,
|
| 191 |
+
)
|
| 192 |
+
# Copy into the expected local path so reruns are instant and idempotent
|
| 193 |
+
import shutil
|
| 194 |
+
shutil.copyfile(fetched, path)
|
| 195 |
+
with open(path) as f:
|
| 196 |
return json.load(f)
|
| 197 |
|
| 198 |
|