Instructions to use yuta24/ui-test-vision-2b-alpha with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use yuta24/ui-test-vision-2b-alpha with PEFT:
Task type is invalid.
- MLX
How to use yuta24/ui-test-vision-2b-alpha with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("yuta24/ui-test-vision-2b-alpha") config = load_config("yuta24/ui-test-vision-2b-alpha") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download code/scripts/swap_records.py from yuta24/ui-test-vision-2b-alpha: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/yuta24/ui-test-vision-2b-alpha/resolve/main/code/scripts/swap_records.py
- Command line
-
hf download hf://yuta24/ui-test-vision-2b-alpha/code/scripts/swap_records.py
-
curl -L -o swap_records.py https://huggingface.co/yuta24/ui-test-vision-2b-alpha/resolve/main/code/scripts/swap_records.py
1.92 kB
| """Replace records of a base JSONL with re-captured records (matched by id), keeping the base order. | |
| Image paths of the replacements are rewritten relative to the output file's directory. | |
| usage: python scripts/swap_records.py base.jsonl replacements.jsonl out.jsonl [--only-substr settings_destructive] | |
| """ | |
| import json, os, sys | |
| def load(p): | |
| with open(p, encoding="utf-8") as f: | |
| return [json.loads(l) for l in f if l.strip()] | |
| def main(base, repl, dst, only=None): | |
| rep = {r["id"]: r for r in load(repl)} | |
| rdir, odir = os.path.dirname(os.path.abspath(repl)), os.path.dirname(os.path.abspath(dst)) | |
| n = swapped = 0 | |
| used, unmatched = set(), [] | |
| with open(dst, "w", encoding="utf-8", newline="\n") as out: | |
| for r in load(base): | |
| n += 1 | |
| if r["id"] in rep: | |
| new = json.loads(json.dumps(rep[r["id"]])) | |
| new["images"] = [os.path.relpath(os.path.join(rdir, im), odir).replace("\\", "/") for im in new["images"]] | |
| missing = [im for im in new["images"] if not os.path.exists(os.path.join(odir, im))] | |
| if missing: | |
| sys.exit(f"missing image {missing}") | |
| new["meta"]["swapped_from"] = os.path.relpath(repl, odir).replace("\\", "/") | |
| r = new | |
| used.add(r["id"]) | |
| swapped += 1 | |
| elif only and only in r["id"]: | |
| unmatched.append(r["id"]) | |
| out.write(json.dumps(r, ensure_ascii=False) + "\n") | |
| print(f"{n} records, swapped={swapped}, replacements unused={len(rep) - len(used)}, " | |
| f"base '{only}' not swapped={len(unmatched)} {unmatched[:5]} -> {dst}") | |
| if __name__ == "__main__": | |
| a = sys.argv[1:] | |
| only = None | |
| if "--only-substr" in a: | |
| i = a.index("--only-substr"); only = a[i + 1]; del a[i:i + 2] | |
| main(*a, only=only) | |