Image-Text-to-Text
Transformers
Safetensors
English
opencua
feature-extraction
VLM
Computer-Use-Agent
OS-Agent
GUI
Grounding
conversational
custom_code
Instructions to use xlangai/OpenCUA-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xlangai/OpenCUA-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="xlangai/OpenCUA-7B", trust_remote_code=True) 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 AutoModel model = AutoModel.from_pretrained("xlangai/OpenCUA-7B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use xlangai/OpenCUA-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xlangai/OpenCUA-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xlangai/OpenCUA-7B", "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/xlangai/OpenCUA-7B
- SGLang
How to use xlangai/OpenCUA-7B 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 "xlangai/OpenCUA-7B" \ --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": "xlangai/OpenCUA-7B", "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 "xlangai/OpenCUA-7B" \ --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": "xlangai/OpenCUA-7B", "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 xlangai/OpenCUA-7B with Docker Model Runner:
docker model run hf.co/xlangai/OpenCUA-7B
add _support_sdpa property to support more transformers version (#7)
Browse files- add _support_sdpa property to support more transformers version (c366a9cb6e7c970ad5452a9a20a22aef1824bd1c)
Co-authored-by: mqhuang <LutherXD@users.noreply.huggingface.co>
- modeling_opencua.py +5 -4
modeling_opencua.py
CHANGED
|
@@ -67,6 +67,10 @@ class OpenCUAPreTrainedModel(PreTrainedModel):
|
|
| 67 |
_skip_keys_device_placement = "past_key_values"
|
| 68 |
_supports_flash_attn_2 = True
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def _init_weights(self, module):
|
| 71 |
# important: this ported version of Llava isn't meant for training from scratch - only
|
| 72 |
# inference and fine-tuning - so the proper init weights code has been removed - the original codebase
|
|
@@ -95,11 +99,8 @@ class OpenCUAForConditionalGeneration(OpenCUAPreTrainedModel):
|
|
| 95 |
super().__init__(config)
|
| 96 |
self.vision_tower = Qwen2_5_VisionTransformerPretrainedModel(config.vision_config)
|
| 97 |
self.language_model = Qwen2ForCausalLM(config.text_config)
|
|
|
|
| 98 |
self.post_init()
|
| 99 |
-
|
| 100 |
-
@property
|
| 101 |
-
def _supports_sdpa(self):
|
| 102 |
-
return self.language_model._supports_sdpa
|
| 103 |
|
| 104 |
# 使用 property 来创建动态属性
|
| 105 |
@property
|
|
|
|
| 67 |
_skip_keys_device_placement = "past_key_values"
|
| 68 |
_supports_flash_attn_2 = True
|
| 69 |
|
| 70 |
+
supports_gradient_checkpointing = True
|
| 71 |
+
|
| 72 |
+
_supports_sdpa = True
|
| 73 |
+
|
| 74 |
def _init_weights(self, module):
|
| 75 |
# important: this ported version of Llava isn't meant for training from scratch - only
|
| 76 |
# inference and fine-tuning - so the proper init weights code has been removed - the original codebase
|
|
|
|
| 99 |
super().__init__(config)
|
| 100 |
self.vision_tower = Qwen2_5_VisionTransformerPretrainedModel(config.vision_config)
|
| 101 |
self.language_model = Qwen2ForCausalLM(config.text_config)
|
| 102 |
+
self._supports_sdpa = True
|
| 103 |
self.post_init()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
# 使用 property 来创建动态属性
|
| 106 |
@property
|