Views
No views yet
1
2Name: transformers
3Version: 5.5.0
4Summary: Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
5Home-page: https://github.com/huggingface/transformers
6Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)
7Author-email: transformers@huggingface.co
8License: Apache 2.0 License
9Location: /usr/local/lib/python3.13/dist-packages
10Requires: huggingface-hub, numpy, packaging, pyyaml, regex, safetensors, tokenizers, tqdm, typer
11Required-by: peft, sentence-transformers, trl, unsloth, unsloth_zoo
12---
13Name: torch
14Version: 2.11.0+cu128
15Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
16Home-page: https://pytorch.org
17Author:
18Author-email: PyTorch Team <packages@pytorch.org>
19License: BSD-3-Clause
20Location: /usr/local/lib/python3.13/dist-packages
21Requires: cuda-bindings, cuda-toolkit, filelock, fsspec, jinja2, networkx, nvidia-cudnn-cu12, nvidia-cusparselt-cu12, nvidia-nccl-cu12, nvidia-nvshmem-cu12, setuptools, sympy, triton, typing-extensions
22Required-by: accelerate, bitsandbytes, cut-cross-entropy, fastai, peft, sentence-transformers, timm, torchdata, torchvision, unsloth, unsloth_zoo, xformers
23---
24Name: unsloth
25Version: 2026.8.19
26Summary: 2-5X faster training, reinforcement learning & finetuning
27Home-page: https://unsloth.ai
28Author: Unsloth AI team
29Author-email: info@unsloth.ai
30License:
31Location: /usr/local/lib/python3.13/dist-packages
32Requires: accelerate, bitsandbytes, click, datasets, diffusers, hf_transfer, huggingface_hub, nest-asyncio, numpy, packaging, peft, protobuf, psutil, pydantic, pyyaml, rich, sentencepiece, structlog, torch, torchvision, tqdm, transformers, triton, trl, typer, tyro, unsloth_zoo, wheel, xformers
33Required-by:
34---
35Name: bitsandbytes
36Version: 0.50.1
37Summary: k-bit optimizers and matrix multiplication routines.
38Home-page: https://github.com/bitsandbytes-foundation/bitsandbytes
39Author:
40Author-email: Tim Dettmers <dettmers@cs.washington.edu>
41License:
42Location: /usr/local/lib/python3.13/dist-packages
43Requires: numpy, packaging, torch
44Required-by: unsloth
45
461
2import sys
3import os
4import contextlib
5from PIL import Image
6
7# 1. Download image using wget and load it
8image_url = "https://picsum.photos/300/300"
9image_filename = "test_image.jpg"
10os.system(f"wget -q -O {image_filename} {image_url}")
11
12image = Image.open(image_filename).convert("RGB")
131
2import sys
3import os
4import contextlib
5
6# Suppress all C/C++/Python low-level file descriptor prints during imports
7@contextlib.contextmanager
8def suppress_all_output():
9 with open(os.devnull, "w") as devnull:
10 old_stdout = sys.stdout
11 old_stderr = sys.stderr
12 sys.stdout = devnull
13 sys.stderr = devnull
14 try:
15 yield
16 finally:
17 sys.stdout = old_stdout
18 sys.stderr = old_stderr
19
20# Completely silence unsloth/transformers startup output and progress bars
21os.environ["UNSLOTH_DISABLE_LOGGING"] = "1"
22os.environ["TRANSVERSE_NO_PROGRESS_BARS"] = "1"
23os.environ["TQDM_DISABLE"] = "1"
24
25with suppress_all_output():
26 import torch
27 import numpy as np
28
29 # Globally enforce weights_only=False for PyTorch 2.6+ checkpoint loading
30 original_torch_load = torch.load
31 def patched_torch_load(*args, **kwargs):
32 kwargs["weights_only"] = False
33 return original_torch_load(*args, **kwargs)
34 torch.load = patched_torch_load
35
36 from huggingface_hub import hf_hub_download
37 from PIL import Image
38 from unsloth import FastVisionModel
39
40MODEL_ID = "frankmorales2020/topo-gemma-4-e4b-vision-13tasks"
41
42with suppress_all_output():
43 ckpt_path = hf_hub_download(repo_id=MODEL_ID, filename="pytorch_model.bin")
44 checkpoint = torch.load(ckpt_path, map_location="cpu")
45 BASE_MODEL = checkpoint.get("base_model", "frankmorales2020/gemma-4-e4b-unesco-optimized")
46
47 model, tokenizer = FastVisionModel.from_pretrained(
48 model_name=BASE_MODEL,
49 load_in_4bit=True,
50 dtype=torch.bfloat16,
51 )
52 FastVisionModel.for_inference(model)
53
54# 1. Load test image
55
56# 1.1. Download image using wget and load it
57from PIL import Image
58image_url = "https://picsum.photos/300/300"
59image_filename = "test_image.jpg"
60os.system(f"wget -q -O {image_filename} {image_url}")
61
62image = Image.open("test_image.jpg").convert("RGB")
63
64# 2. Define all 13 tasks
65tasks = [
66 ("Task A", "Animal vs Vehicle", "Does this image depict an animal or a vehicle?"),
67 ("Task B", "Natural vs Man-Made", "Is this subject natural or man-made?"),
68 ("Task C", "Living vs Non-Living", "Is the primary subject living or non-living?"),
69 ("Task D", "Large vs Small", "Is the subject large or small in scale?"),
70 ("Task E", "Ground vs Air/Water", "Does this subject belong to ground or air/water?"),
71 ("Task F", "Domestic vs Wild", "Is this subject domestic or wild?"),
72 ("Task G", "Mammal vs Non-Mammal", "Is this subject a mammal or non-mammal?"),
73 ("Task H", "Flying vs Non-Flying", "Is this subject flying or non-flying?"),
74 ("Task I", "Fast vs Slow", "Is this subject characterized as fast or slow?"),
75 ("Task J", "Urban vs Rural", "Does this setting represent an urban or rural environment?"),
76 ("Task K", "Predator vs Prey", "Is this subject a predator or prey?"),
77 ("Task L", "Nocturnal vs Diurnal", "Is this subject nocturnal or diurnal?"),
78 ("Task M", "Domesticated vs Wild Animals", "Is this animal domesticated or wild?")
79]
80
81print("\n" + "="*80)
82print("🚀 EVALUATING ALL 13 TOPO-2026 TASKS")
83print("="*80)
84
85for task_id, task_name, prompt in tasks:
86 messages = [
87 {
88 "role": "user",
89 "content": [
90 {"type": "image"},
91 {"type": "text", "text": f"{task_id} ({task_name}): {prompt}"}
92 ]
93 }
94 ]
95 input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
96
97 inputs = tokenizer(
98 image,
99 input_text,
100 add_special_tokens=False,
101 return_tensors="pt",
102 ).to("cuda")
103
104 with torch.inference_mode():
105 output_tokens = model.generate(
106 **inputs,
107 max_new_tokens=24,
108 do_sample=False,
109 use_cache=True,
110 )
111
112 response = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
113 answer = response.split("model")[-1].strip() if "model" in response else response
114 print(f"[{task_id}] {task_name:<30} ➔ {answer}")
115
116print("="*80)
117print("🎉 EVALUATION COMPLETE!")
118print("="*80)
1191
2 Loading weights: 100% 2130/2130 [00:03<00:00, 1004.30it/s]
3================================================================================
4🚀 EVALUATING ALL 13 TOPO-2026 TASKS
5================================================================================
6[Task A] Animal vs Vehicle ➔ This image depicts **neither** an animal nor a vehicle. It is a landscape photograph of the **ocean/sea**
7[Task B] Natural vs Man-Made ➔ This subject is **natural**.
8
9It depicts a seascape with waves, ocean, and a distant landmass under a dramatic
10[Task C] Living vs Non-Living ➔ The primary subject in the image is the **ocean/sea** and the **sky/weather**.
11
12Both the ocean
13[Task D] Large vs Small ➔ Based on the image, the **subject** (the ocean, waves, and coastline) is **large in scale**.
14[Task E] Ground vs Air/Water ➔ This subject belongs to **both ground and air/water**.
15
16Here's why:
17
18* **Water:** The
19[Task F] Domestic vs Wild ➔ This subject is **wild**.
20
21The image depicts a natural scene: the ocean, waves, and the sky. These
22[Task G] Mammal vs Non-Mammal ➔ Based on the image provided, there is **no subject** visible that is an animal. The image is a landscape photograph
23[Task H] Flying vs Non-Flying ➔ Based on the image provided, there is **no subject** that is clearly flying or non-flying.
24
25The image
26[Task I] Fast vs Slow ➔ Based on the image, the subject matter is a **seascape** (ocean waves, sky, and coastline).
27[Task J] Urban vs Rural ➔ This setting represents a **rural** environment.
28
29Here's why:
30
31* **Natural Landscape:** The image is
32[Task K] Predator vs Prey ➔ Based on the image provided, which is a **landscape photograph of the ocean at sunset/sunrise**, there are **no
33[Task L] Nocturnal vs Diurnal ➔ Based on the image, the subject is a **seascape** (ocean, waves, sky).
34
35The concept of
36[Task M] Domesticated vs Wild Animals ➔ I'm sorry, but you have provided an image of a **seascape (ocean waves and sky)**, not
37================================================================================
38🎉 EVALUATION COMPLETE!
39================================================================================
40
41
42