Update README.md
Browse files
README.md
CHANGED
@@ -1,52 +1,53 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
datasets:
|
4 |
-
- google/docci
|
5 |
-
- google/imageinwords
|
6 |
-
- ProGamerGov/synthetic-dataset-1m-dalle3-high-quality-captions
|
7 |
-
language:
|
8 |
-
- en
|
9 |
-
library_name: transformers
|
10 |
-
pipeline_tag: image-text-to-text
|
11 |
-
tags:
|
12 |
-
- art
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
import
|
23 |
-
import
|
24 |
-
import
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
)
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
config
|
50 |
-
|
51 |
-
|
|
|
52 |
```
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- google/docci
|
5 |
+
- google/imageinwords
|
6 |
+
- ProGamerGov/synthetic-dataset-1m-dalle3-high-quality-captions
|
7 |
+
language:
|
8 |
+
- en
|
9 |
+
library_name: transformers
|
10 |
+
pipeline_tag: image-text-to-text
|
11 |
+
tags:
|
12 |
+
- art
|
13 |
+
base_model: gokaygokay/Florence-2-SD3-Captioner
|
14 |
+
inference: false
|
15 |
+
---
|
16 |
+
|
17 |
+
Original model is [here](https://huggingface.co/gokaygokay/Florence-2-SD3-Captioner).
|
18 |
+
Tagger for local environment is [here](https://huggingface.co/John6666/local_gokaygokay_Florence-2-SD3-Captioner_Tagger).
|
19 |
+
|
20 |
+
```python
|
21 |
+
# recipe
|
22 |
+
from transformers import AutoModelForCausalLM, AutoProcessor, BitsAndBytesConfig
|
23 |
+
import transformers
|
24 |
+
import torch
|
25 |
+
import json
|
26 |
+
|
27 |
+
model_id = 'gokaygokay/Florence-2-SD3-Captioner'
|
28 |
+
save_path = 'gokaygokay-Florence-2-SD3-Captioner-8bit'
|
29 |
+
|
30 |
+
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
31 |
+
model = AutoModelForCausalLM.from_pretrained(
|
32 |
+
model_id,
|
33 |
+
trust_remote_code=True,
|
34 |
+
torch_dtype=torch.float32,
|
35 |
+
low_cpu_mem_usage=True,
|
36 |
+
quantization_config=BitsAndBytesConfig(
|
37 |
+
load_in_8bit=True,
|
38 |
+
llm_int8_threshold=6.0,
|
39 |
+
llm_int8_enable_fp32_cpu_offload=True,
|
40 |
+
llm_int8_skip_modules=['lm_head'],
|
41 |
+
),
|
42 |
+
)
|
43 |
+
|
44 |
+
processor.save_pretrained(save_path)
|
45 |
+
model.save_pretrained(save_path, safe_serialization=True)
|
46 |
+
|
47 |
+
config = {}
|
48 |
+
with open(f'{save_path}/config.json') as f:
|
49 |
+
config = json.load(f)
|
50 |
+
config['vision_config']['model_type'] = 'davit'
|
51 |
+
with open(f'{save_path}/config.json', 'w') as f:
|
52 |
+
json.dump(config, f, indent=2)
|
53 |
```
|