Image-Text-to-Text
Transformers
Safetensors
internvl_chat
feature-extraction
conversational
custom_code
Instructions to use OS-Copilot/OS-Genesis-4B-AC with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OS-Copilot/OS-Genesis-4B-AC with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OS-Copilot/OS-Genesis-4B-AC", 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("OS-Copilot/OS-Genesis-4B-AC", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OS-Copilot/OS-Genesis-4B-AC with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OS-Copilot/OS-Genesis-4B-AC" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OS-Copilot/OS-Genesis-4B-AC", "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/OS-Copilot/OS-Genesis-4B-AC
- SGLang
How to use OS-Copilot/OS-Genesis-4B-AC 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 "OS-Copilot/OS-Genesis-4B-AC" \ --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": "OS-Copilot/OS-Genesis-4B-AC", "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 "OS-Copilot/OS-Genesis-4B-AC" \ --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": "OS-Copilot/OS-Genesis-4B-AC", "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 OS-Copilot/OS-Genesis-4B-AC with Docker Model Runner:
docker model run hf.co/OS-Copilot/OS-Genesis-4B-AC
Update license to MIT
#1
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
library_name: transformers
|
| 4 |
base_model: OpenGVLab/InternVL2-4B
|
|
|
|
|
|
|
| 5 |
pipeline_tag: image-text-to-text
|
| 6 |
---
|
| 7 |
|
|
@@ -137,9 +137,15 @@ tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast
|
|
| 137 |
pixel_values = load_image('./web_dfacd48d-d2c2-492f-b94c-41e6a34ea99f.png', max_num=6).to(torch.bfloat16).cuda()
|
| 138 |
generation_config = dict(max_new_tokens=1024, do_sample=True)
|
| 139 |
|
| 140 |
-
question = "<image>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
|
| 142 |
-
print(f'User: {question}
|
|
|
|
| 143 |
```
|
| 144 |
|
| 145 |
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
| 2 |
base_model: OpenGVLab/InternVL2-4B
|
| 3 |
+
library_name: transformers
|
| 4 |
+
license: mit
|
| 5 |
pipeline_tag: image-text-to-text
|
| 6 |
---
|
| 7 |
|
|
|
|
| 137 |
pixel_values = load_image('./web_dfacd48d-d2c2-492f-b94c-41e6a34ea99f.png', max_num=6).to(torch.bfloat16).cuda()
|
| 138 |
generation_config = dict(max_new_tokens=1024, do_sample=True)
|
| 139 |
|
| 140 |
+
question = "<image>
|
| 141 |
+
You are a GUI task expert, I will provide you with a high-level instruction, an action history, a screenshot with its corresponding accessibility tree.
|
| 142 |
+
High-level instruction: {high_level_instruction}
|
| 143 |
+
Action history: {action_history}
|
| 144 |
+
Accessibility tree: {a11y_tree}
|
| 145 |
+
Please generate the low-level thought and action for the next step."
|
| 146 |
response, history = model.chat(tokenizer, pixel_values, question, generation_config, history=None, return_history=True)
|
| 147 |
+
print(f'User: {question}
|
| 148 |
+
Assistant: {response}')
|
| 149 |
```
|
| 150 |
|
| 151 |
|