Image-Text-to-Text
Transformers
Safetensors
florence2
GUI
VLM
GUI-Grounding
visual-grounding
custom_code
Instructions to use lumimate/PhoneUIAnchor-829M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lumimate/PhoneUIAnchor-829M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="lumimate/PhoneUIAnchor-829M", trust_remote_code=True)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("lumimate/PhoneUIAnchor-829M", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("lumimate/PhoneUIAnchor-829M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lumimate/PhoneUIAnchor-829M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lumimate/PhoneUIAnchor-829M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lumimate/PhoneUIAnchor-829M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/lumimate/PhoneUIAnchor-829M
- SGLang
How to use lumimate/PhoneUIAnchor-829M 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 "lumimate/PhoneUIAnchor-829M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lumimate/PhoneUIAnchor-829M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "lumimate/PhoneUIAnchor-829M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lumimate/PhoneUIAnchor-829M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use lumimate/PhoneUIAnchor-829M with Docker Model Runner:
docker model run hf.co/lumimate/PhoneUIAnchor-829M
File size: 1,863 Bytes
79b6316 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #!/usr/bin/env python3
"""Run GUI grounding with a local directory or Hugging Face model ID."""
import argparse
import re
import torch
from PIL import Image
from transformers import AutoModelForCausalLM, AutoProcessor
POINT_PATTERN = re.compile(r"<loc_(\d+)>,<loc_(\d+)>")
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--model", default=".")
parser.add_argument("--image", required=True)
parser.add_argument("--prompt", required=True)
return parser.parse_args()
def main():
args = parse_args()
if not torch.cuda.is_available():
raise RuntimeError("This example requires a CUDA GPU")
model = AutoModelForCausalLM.from_pretrained(
args.model,
trust_remote_code=True,
torch_dtype=torch.bfloat16,
attn_implementation="sdpa",
).cuda().eval()
processor = AutoProcessor.from_pretrained(args.model, trust_remote_code=True)
image = Image.open(args.image).convert("RGB")
inputs = processor(images=image, text=args.prompt, return_tensors="pt").to(
"cuda", dtype=torch.bfloat16
)
with torch.inference_mode():
output_ids = model.generate(
**inputs,
do_sample=False,
max_new_tokens=16,
)
text = processor.tokenizer.batch_decode(
output_ids, skip_special_tokens=False
)[0]
match = POINT_PATTERN.search(text)
if match is None:
print(text)
raise RuntimeError("the model output did not contain location tokens")
normalized = tuple(map(int, match.groups()))
pixels = (
normalized[0] / 999 * image.width,
normalized[1] / 999 * image.height,
)
print(f"raw_output={text}")
print(f"normalized_point={normalized}")
print(f"pixel_point=({pixels[0]:.2f}, {pixels[1]:.2f})")
if __name__ == "__main__":
main()
|