Image-Text-to-Text
Transformers
Safetensors
English
qwen2_5_vl
Multimodal
VLM
Computer-Use-Agent
Web-Agent
GUI
Grounding
GUI Subtask
conversational
text-generation-inference
Instructions to use Uniphore/actio-ui-7b-sft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Uniphore/actio-ui-7b-sft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Uniphore/actio-ui-7b-sft") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Uniphore/actio-ui-7b-sft") model = AutoModelForMultimodalLM.from_pretrained("Uniphore/actio-ui-7b-sft", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Uniphore/actio-ui-7b-sft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Uniphore/actio-ui-7b-sft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Uniphore/actio-ui-7b-sft", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Uniphore/actio-ui-7b-sft
- SGLang
How to use Uniphore/actio-ui-7b-sft 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 "Uniphore/actio-ui-7b-sft" \ --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": "Uniphore/actio-ui-7b-sft", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "Uniphore/actio-ui-7b-sft" \ --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": "Uniphore/actio-ui-7b-sft", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Uniphore/actio-ui-7b-sft with Docker Model Runner:
docker model run hf.co/Uniphore/actio-ui-7b-sft
| import base64 | |
| import sys | |
| import torch | |
| from transformers import AutoTokenizer, AutoModelForVision2Seq, AutoProcessor | |
| from PIL import Image | |
| def encode_image(image_path: str) -> str: | |
| """Encode image to base64 string for model input.""" | |
| with open(image_path, "rb") as f: | |
| return base64.b64encode(f.read()).decode() | |
| def load_model( | |
| model_path: str, | |
| ) -> tuple[AutoModelForVision2Seq, AutoTokenizer, AutoProcessor]: | |
| """Load OpenCUA model, tokenizer, and image processor.""" | |
| tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True) | |
| model = AutoModelForVision2Seq.from_pretrained( | |
| model_path, torch_dtype="auto", device_map="auto", trust_remote_code=True | |
| ) | |
| image_processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True) | |
| return model, tokenizer, image_processor | |
| def create_grounding_messages(image_path: str, instruction: str) -> list[dict]: | |
| """Create chat messages for GUI grounding task.""" | |
| system_prompt = ( | |
| "You are a GUI agent. You are given a task and a screenshot of the screen. " | |
| "You need to perform a series of pyautogui actions to complete the task." | |
| ) | |
| messages = [ | |
| {"role": "system", "content": system_prompt}, | |
| { | |
| "role": "user", | |
| "content": [ | |
| { | |
| "type": "text", | |
| "text": "Please perform the following task by providing the action and the coordinates in the format of <action>(x, y): " | |
| + instruction, | |
| }, | |
| { | |
| "type": "image", | |
| "image": f"data:image/png;base64,{encode_image(image_path)}", | |
| }, | |
| ], | |
| }, | |
| ] | |
| return messages | |
| def run_inference( | |
| model: AutoModelForVision2Seq, | |
| tokenizer: AutoTokenizer, | |
| image_processor: AutoProcessor, | |
| messages: list[dict], | |
| image_path: str, | |
| ) -> str: | |
| """Run inference on the model.""" | |
| # Prepare text from messages | |
| text = image_processor.apply_chat_template( | |
| messages, tokenize=False, add_generation_prompt=True | |
| ) | |
| # Open image | |
| image = Image.open(image_path).convert("RGB") | |
| # Process inputs using the processor | |
| inputs = image_processor( | |
| text=[text], images=[image], padding=True, return_tensors="pt" | |
| ) | |
| # Move inputs to model device | |
| inputs = {k: v.to(model.device) for k, v in inputs.items()} | |
| # Generate response | |
| with torch.no_grad(): | |
| generated_ids = model.generate( | |
| **inputs, | |
| max_new_tokens=2048, | |
| do_sample=False, | |
| ) | |
| # Decode output (skip the input tokens) | |
| generated_ids_trimmed = [ | |
| out_ids[len(in_ids) :] | |
| for in_ids, out_ids in zip(inputs["input_ids"], generated_ids) | |
| ] | |
| output_text = image_processor.batch_decode( | |
| generated_ids_trimmed, | |
| skip_special_tokens=True, | |
| clean_up_tokenization_spaces=False, | |
| )[0] | |
| return output_text | |
| def main(): | |
| """Main function to run the sanity check.""" | |
| # Configuration | |
| model_path = "Uniphore/actio-ui-7b-sft" # or other model variants | |
| image_path = "screenshot.png" | |
| instruction = "Click on the submit button" | |
| # Check if custom instruction provided | |
| if len(sys.argv) > 1: | |
| instruction = " ".join(sys.argv[1:]) | |
| print(f"Loading model from: {model_path}") | |
| try: | |
| model, tokenizer, image_processor = load_model(model_path) | |
| print("✓ Model loaded successfully") | |
| except Exception as e: | |
| print(f"✗ Error loading model: {e}") | |
| return 1 | |
| print(f"Processing image: {image_path}") | |
| print(f"Instruction: {instruction}") | |
| try: | |
| messages = create_grounding_messages(image_path, instruction) | |
| result = run_inference(model, tokenizer, image_processor, messages, image_path) | |
| print("\n" + "=" * 60) | |
| print("MODEL OUTPUT:") | |
| print("=" * 60) | |
| print(result) | |
| print("=" * 60) | |
| return 0 | |
| except Exception as e: | |
| print(f"✗ Error during inference: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| return 1 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |