README: drop inline inference example, point to molmo2 repo
Browse files
README.md
CHANGED
|
@@ -42,52 +42,9 @@ All other hyperparameters follow [Molmo2](https://github.com/allenai/molmo2).
|
|
| 42 |
- **Code**: https://github.com/allenai/molmo2
|
| 43 |
- **Base model**: [Molmo2-4B](https://github.com/allenai/molmo2)
|
| 44 |
|
| 45 |
-
##
|
| 46 |
|
| 47 |
-
|
| 48 |
-
from transformers import AutoProcessor, AutoModelForImageTextToText
|
| 49 |
-
from PIL import Image
|
| 50 |
-
import requests
|
| 51 |
-
import torch
|
| 52 |
-
|
| 53 |
-
model = AutoModelForImageTextToText.from_pretrained(
|
| 54 |
-
"allenai/Molmo2-ER-4B",
|
| 55 |
-
trust_remote_code=True,
|
| 56 |
-
dtype="auto",
|
| 57 |
-
device_map="auto",
|
| 58 |
-
)
|
| 59 |
-
|
| 60 |
-
processor = AutoProcessor.from_pretrained(
|
| 61 |
-
"allenai/Molmo2-ER-4B",
|
| 62 |
-
trust_remote_code=True,
|
| 63 |
-
padding_side="left",
|
| 64 |
-
)
|
| 65 |
-
|
| 66 |
-
messages = [{
|
| 67 |
-
"role": "user",
|
| 68 |
-
"content": [
|
| 69 |
-
{"type": "text", "text": "Point to the apple."},
|
| 70 |
-
{"type": "image", "image": Image.open(requests.get(
|
| 71 |
-
"https://picsum.photos/id/237/536/354", stream=True
|
| 72 |
-
).raw)},
|
| 73 |
-
],
|
| 74 |
-
}]
|
| 75 |
-
|
| 76 |
-
inputs = processor.apply_chat_template(
|
| 77 |
-
messages,
|
| 78 |
-
tokenize=True,
|
| 79 |
-
add_generation_prompt=True,
|
| 80 |
-
return_tensors="pt",
|
| 81 |
-
return_dict=True,
|
| 82 |
-
padding=True,
|
| 83 |
-
)
|
| 84 |
-
inputs = {k: v.to("cuda") for k, v in inputs.items()}
|
| 85 |
-
|
| 86 |
-
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
|
| 87 |
-
output = model.generate(**inputs, max_new_tokens=256)
|
| 88 |
-
|
| 89 |
-
print(processor.decode(output[0, inputs["input_ids"].size(1):], skip_special_tokens=True))
|
| 90 |
-
```
|
| 91 |
|
| 92 |
## License
|
| 93 |
|
|
|
|
| 42 |
- **Code**: https://github.com/allenai/molmo2
|
| 43 |
- **Base model**: [Molmo2-4B](https://github.com/allenai/molmo2)
|
| 44 |
|
| 45 |
+
## Usage
|
| 46 |
|
| 47 |
+
See https://github.com/allenai/molmo2 for inference, evaluation, and training code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
## License
|
| 50 |
|