update
Browse files
README.md
CHANGED
|
@@ -30,7 +30,7 @@ pipeline_tag: text-generation
|
|
| 30 |
|
| 31 |
<sup>*</sup> Project lead <sup>†</sup> First authors <sup>‡</sup> Second authors <sup>▽</sup> Leadership
|
| 32 |
|
| 33 |
-
\[[arXiv Paper](https://www.arxiv.org/pdf/2502.13130)\] \[[Project Page](https://microsoft.github.io/Magma/)\] \[[Hugging Face
|
| 34 |
|
| 35 |
</div>
|
| 36 |
|
|
@@ -67,6 +67,45 @@ The model is developed by Microsoft and is funded by Microsoft Research. The mod
|
|
| 67 |
- **License:** {{ license | default("[More Information Needed]", true)}}
|
| 68 |
- **Finetuned from model [optional]:** {{ base_model | default("[More Information Needed]", true)}} -->
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
## Intended Uses
|
| 71 |
|
| 72 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
|
@@ -141,43 +180,6 @@ For the robotic manipulation task, some mitigation strategies to use for human s
|
|
| 141 |
* **Safety Standards and Compliance:** Adhere to established safety standards (e.g., ISO 10218, ISO/TS 15066) for industrial robots and collaborative robots.
|
| 142 |
* **User Training and Awareness:** Provide comprehensive training for all personnel working around robotic arms to understand their functions, safety features, and emergency procedures. Promote awareness of the potential risks associated with robotic manipulation.
|
| 143 |
|
| 144 |
-
## How to Get Started with the Model
|
| 145 |
-
|
| 146 |
-
<!-- {{ get_started_code | default("[More Information Needed]", true)}} -->
|
| 147 |
-
|
| 148 |
-
Use the code below to get started with the model.
|
| 149 |
-
|
| 150 |
-
```python
|
| 151 |
-
from magma.image_processing_magma import MagmaImageProcessor
|
| 152 |
-
from magma.processing_magma import MagmaProcessor
|
| 153 |
-
from magma.modeling_magma import MagmaForConditionalGeneration
|
| 154 |
-
|
| 155 |
-
# Load the model
|
| 156 |
-
model_id = "microsoft/Magma-8B"
|
| 157 |
-
processor = MagmaProcessor.from_pretrained(model_id, trust_remote_code=True)
|
| 158 |
-
model = MagmaForConditionalGeneration.from_pretrained(model_id, device_map="cuda", low_cpu_mem_usage=True)
|
| 159 |
-
|
| 160 |
-
# Inference
|
| 161 |
-
url = "https://assets-c4akfrf5b4d3f4b7.z01.azurefd.net/assets/2024/04/BMDataViz_661fb89f3845e.png"
|
| 162 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
| 163 |
-
|
| 164 |
-
convs = [
|
| 165 |
-
{"role": "system", "content": "You are agent that can see, talk and act."},
|
| 166 |
-
{"role": "user", "content": "<image_start><image><image_end>\nWhat is in this image?"},
|
| 167 |
-
]
|
| 168 |
-
prompt = processor.tokenizer.apply_chat_template(convs, tokenize=False, add_generation_prompt=True)
|
| 169 |
-
inputs = processor(images=[image], texts=prompt, return_tensors="pt")
|
| 170 |
-
inputs = inputs.to("cuda")
|
| 171 |
-
|
| 172 |
-
with torch.inference_mode():
|
| 173 |
-
generate_ids = model.generate(**inputs, **generation_args)
|
| 174 |
-
|
| 175 |
-
generate_ids = generate_ids[:, inputs["input_ids"].shape[-1] :]
|
| 176 |
-
response = processor.decode(generate_ids[0], skip_special_tokens=True).strip()
|
| 177 |
-
|
| 178 |
-
print(response)
|
| 179 |
-
```
|
| 180 |
-
|
| 181 |
## Training Details
|
| 182 |
|
| 183 |
### Training Data
|
|
|
|
| 30 |
|
| 31 |
<sup>*</sup> Project lead <sup>†</sup> First authors <sup>‡</sup> Second authors <sup>▽</sup> Leadership
|
| 32 |
|
| 33 |
+
\[[arXiv Paper](https://www.arxiv.org/pdf/2502.13130)\] \[[Project Page](https://microsoft.github.io/Magma/)\] \[[Hugging Face Paper](https://huggingface.co/papers/2502.13130)\] \[[Github Repo](https://github.com/microsoft/Magma)\]
|
| 34 |
|
| 35 |
</div>
|
| 36 |
|
|
|
|
| 67 |
- **License:** {{ license | default("[More Information Needed]", true)}}
|
| 68 |
- **Finetuned from model [optional]:** {{ base_model | default("[More Information Needed]", true)}} -->
|
| 69 |
|
| 70 |
+
## How to Get Started with the Model
|
| 71 |
+
|
| 72 |
+
<!-- {{ get_started_code | default("[More Information Needed]", true)}} -->
|
| 73 |
+
|
| 74 |
+
Use the code below to get started with the model.
|
| 75 |
+
|
| 76 |
+
```python
|
| 77 |
+
import torch
|
| 78 |
+
from PIL import Image
|
| 79 |
+
import requests
|
| 80 |
+
|
| 81 |
+
from transformers import AutoModelForCausalLM
|
| 82 |
+
from transformers import AutoProcessor
|
| 83 |
+
|
| 84 |
+
# Load the model and processor
|
| 85 |
+
model = AutoModelForCausalLM.from_pretrained("microsoft/Magma-8B", trust_remote_code=True)
|
| 86 |
+
processor = AutoProcessor.from_pretrained("microsoft/Magma-8B", trust_remote_code=True)
|
| 87 |
+
|
| 88 |
+
# Inference
|
| 89 |
+
url = "https://assets-c4akfrf5b4d3f4b7.z01.azurefd.net/assets/2024/04/BMDataViz_661fb89f3845e.png"
|
| 90 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
| 91 |
+
|
| 92 |
+
convs = [
|
| 93 |
+
{"role": "system", "content": "You are agent that can see, talk and act."},
|
| 94 |
+
{"role": "user", "content": "<image_start><image><image_end>\nWhat is in this image?"},
|
| 95 |
+
]
|
| 96 |
+
prompt = processor.tokenizer.apply_chat_template(convs, tokenize=False, add_generation_prompt=True)
|
| 97 |
+
inputs = processor(images=[image], texts=prompt, return_tensors="pt")
|
| 98 |
+
inputs = inputs.to("cuda")
|
| 99 |
+
|
| 100 |
+
with torch.inference_mode():
|
| 101 |
+
generate_ids = model.generate(**inputs, **generation_args)
|
| 102 |
+
|
| 103 |
+
generate_ids = generate_ids[:, inputs["input_ids"].shape[-1] :]
|
| 104 |
+
response = processor.decode(generate_ids[0], skip_special_tokens=True).strip()
|
| 105 |
+
|
| 106 |
+
print(response)
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
## Intended Uses
|
| 110 |
|
| 111 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
|
|
|
| 180 |
* **Safety Standards and Compliance:** Adhere to established safety standards (e.g., ISO 10218, ISO/TS 15066) for industrial robots and collaborative robots.
|
| 181 |
* **User Training and Awareness:** Provide comprehensive training for all personnel working around robotic arms to understand their functions, safety features, and emergency procedures. Promote awareness of the potential risks associated with robotic manipulation.
|
| 182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
## Training Details
|
| 184 |
|
| 185 |
### Training Data
|