DaVinciCode commited on
Commit
29b2ebe
·
verified ·
1 Parent(s): ec3c805

Replace **dtype** with **torch_dtype** in Model Loading

Browse files

The model card for Kosmos 2.5 has been updated to address an issue where the dtype parameter in the from_pretrained method was not functioning as intended. The code has been revised to use torch_dtype instead, aligning with the standard PyTorch API convention in Hugging Face's Transformers library. This change ensures proper data type specification during model loading and resolves issues with the previous dtype parameter.
The updated code is as follows:
```
model = Kosmos2_5ForConditionalGeneration.from_pretrained(repo, device_map=device, torch_dtype=dtype)
```
This update does not alter the model's functionality but ensures compatibility with the Hugging Face Transformers API.

Files changed (1) hide show
  1. README.md +2 -2
README.md CHANGED
@@ -33,7 +33,7 @@ from transformers import AutoProcessor, Kosmos2_5ForConditionalGeneration, infer
33
  repo = "microsoft/kosmos-2.5"
34
  device = "cuda:0"
35
  dtype = torch.bfloat16
36
- model = Kosmos2_5ForConditionalGeneration.from_pretrained(repo, device_map=device, dtype=dtype)
37
  processor = AutoProcessor.from_pretrained(repo)
38
 
39
  # sample image
@@ -71,7 +71,7 @@ from transformers import AutoProcessor, Kosmos2_5ForConditionalGeneration, infer
71
  repo = "microsoft/kosmos-2.5"
72
  device = "cuda:0"
73
  dtype = torch.bfloat16
74
- model = Kosmos2_5ForConditionalGeneration.from_pretrained(repo, device_map=device, dtype=dtype)
75
  processor = AutoProcessor.from_pretrained(repo)
76
 
77
  # sample image
 
33
  repo = "microsoft/kosmos-2.5"
34
  device = "cuda:0"
35
  dtype = torch.bfloat16
36
+ model = Kosmos2_5ForConditionalGeneration.from_pretrained(repo, device_map=device, torch_dtype=dtype)
37
  processor = AutoProcessor.from_pretrained(repo)
38
 
39
  # sample image
 
71
  repo = "microsoft/kosmos-2.5"
72
  device = "cuda:0"
73
  dtype = torch.bfloat16
74
+ model = Kosmos2_5ForConditionalGeneration.from_pretrained(repo, device_map=device, torch_dtype=dtype)
75
  processor = AutoProcessor.from_pretrained(repo)
76
 
77
  # sample image