Text Generation
Transformers
Safetensors
English
canopy
browser-use
web-agent
recurrent-moe
edge-llm
lightpanda
obscura
multi-agent
robotics-web
conversational
custom_code
Instructions to use psikosen/canopy-258m-r3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use psikosen/canopy-258m-r3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="psikosen/canopy-258m-r3", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("psikosen/canopy-258m-r3", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use psikosen/canopy-258m-r3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "psikosen/canopy-258m-r3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "psikosen/canopy-258m-r3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/psikosen/canopy-258m-r3
- SGLang
How to use psikosen/canopy-258m-r3 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "psikosen/canopy-258m-r3" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "psikosen/canopy-258m-r3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "psikosen/canopy-258m-r3" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "psikosen/canopy-258m-r3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use psikosen/canopy-258m-r3 with Docker Model Runner:
docker model run hf.co/psikosen/canopy-258m-r3
Download miniswardbower/browser/visual_icon_labels.py from psikosen/canopy-258m-r3: direct link, hf CLI and curl.
- Browser
- Download file 2.77 kB
-
https://huggingface.co/psikosen/canopy-258m-r3/resolve/main/miniswardbower/browser/visual_icon_labels.py
- Command line
-
hf download hf://psikosen/canopy-258m-r3/miniswardbower/browser/visual_icon_labels.py
-
curl -L -o visual_icon_labels.py https://huggingface.co/psikosen/canopy-258m-r3/resolve/main/miniswardbower/browser/visual_icon_labels.py
2.77 kB
| """Opt-in experimental icon labels; labels are evidence, never click commands.""" | |
| import io,json | |
| from pathlib import Path | |
| import numpy as np | |
| import torch | |
| import torch.nn.functional as F | |
| from PIL import Image | |
| from safetensors.torch import load_file | |
| from transformers.models.idefics3.configuration_idefics3 import Idefics3VisionConfig | |
| from transformers.models.idefics3.modeling_idefics3 import Idefics3VisionTransformer | |
| from miniswardbower.browser.dom_distiller import DOMDistiller | |
| class VisualIconDistiller(DOMDistiller): | |
| def __init__(self, directory): | |
| super().__init__(draw_overlays=False) | |
| directory=Path(directory) | |
| self.labels=json.loads((directory/'report.json').read_text())['labels'] | |
| config=Idefics3VisionConfig.from_json_file(directory/'vision_config.json');config._attn_implementation='sdpa' | |
| self.vision=Idefics3VisionTransformer(config) | |
| state=load_file(str(directory/'icon_specialist.safetensors')) | |
| self.vision.load_state_dict({k[7:]:v for k,v in state.items() if k.startswith('vision.')},strict=True) | |
| self.head=torch.nn.Linear(config.hidden_size,len(self.labels)) | |
| self.head.load_state_dict({k[5:]:v for k,v in state.items() if k.startswith('head.')},strict=True) | |
| self.vision=self.vision.cuda().bfloat16().eval();self.head=self.head.cuda().eval() | |
| self.observations=[] | |
| def classify(self, image): | |
| a=torch.from_numpy(np.asarray(image.convert('RGB').resize((512,512))).copy()).permute(2,0,1).float()/255 | |
| features=self.vision(pixel_values=((a-.5)/.5)[None].cuda().bfloat16()).last_hidden_state.mean(1).float() | |
| probs=self.head(F.normalize(features,dim=-1)).softmax(-1)[0] | |
| return self.labels[int(probs.argmax())],float(probs.max()) | |
| async def extract_pruned_tree(self,page): | |
| tree=await super().extract_pruned_tree(page) | |
| # A locator screenshot scrolls offscreen elements into view. Perception must not act. | |
| viewport=Image.open(io.BytesIO(await page.screenshot(full_page=False,scale='css'))) | |
| count=0 | |
| for elem in tree.elements: | |
| x,y,w,h=elem.bbox | |
| if elem.aria_label or elem.tag not in ('button','a') or not (0<w<=160 and 0<h<=100):continue | |
| if elem.text and any(c.isalpha() for c in elem.text):continue | |
| if count>=20:break | |
| if x<0 or y<0 or x+w>viewport.width or y+h>viewport.height:continue | |
| name,confidence=self.classify(viewport.crop((x,y,x+w,y+h)));count+=1 | |
| self.observations.append(dict(mark=elem.id,label=name,confidence=confidence)) | |
| if name!='other': | |
| elem.text=(elem.text or '')+f' [visual guess: {name}; confidence {confidence:.2f}]' | |
| return tree | |