Update README.md
Browse files
README.md
CHANGED
@@ -21,6 +21,13 @@ processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
|
21 |
model = AutoModelForCausalLM.from_pretrained(model_id,trust_remote_code=True)
|
22 |
# if have a cuda device
|
23 |
model.to('cuda')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
```
|
25 |
|
26 |
# LLM Inference
|
@@ -91,6 +98,8 @@ Create a concise caption that accurately describes the main elements in the imag
|
|
91 |
"""
|
92 |
inputs = processor(text=input_text, images=image, return_tensors="pt")
|
93 |
inputs = {key: value.cuda() for key, value in inputs.items()}
|
|
|
|
|
94 |
|
95 |
image
|
96 |
```
|
|
|
21 |
model = AutoModelForCausalLM.from_pretrained(model_id,trust_remote_code=True)
|
22 |
# if have a cuda device
|
23 |
model.to('cuda')
|
24 |
+
# else if you have cpu you can use
|
25 |
+
model = AutoModelForCausalLM.from_pretrained(
|
26 |
+
model_id,
|
27 |
+
trust_remote_code=True,
|
28 |
+
device_map='cpu' # Assure que le modèle est chargé sur le CPU
|
29 |
+
,torch_dtype=torch.bfloat16 # Charger le modèle en demi-précision
|
30 |
+
)
|
31 |
```
|
32 |
|
33 |
# LLM Inference
|
|
|
98 |
"""
|
99 |
inputs = processor(text=input_text, images=image, return_tensors="pt")
|
100 |
inputs = {key: value.cuda() for key, value in inputs.items()}
|
101 |
+
# NB : if you are using bflot16 ==>
|
102 |
+
inputs = {key: value.to(dtype=model.dtype) if value.dtype == torch.float32 else value for key, value in inputs.items()}
|
103 |
|
104 |
image
|
105 |
```
|