File tree Expand file tree Collapse file tree 8 files changed +121
-5
lines changed Expand file tree Collapse file tree 8 files changed +121
-5
lines changed Original file line number Diff line number Diff line change
1
+ name : Lint
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ pull_request :
8
+ # Allow to trigger the workflow manually
9
+ workflow_dispatch :
10
+
11
+ permissions :
12
+ contents : read
13
+
14
+ concurrency :
15
+ group : " ${{ github.workflow }}-${{ github.ref }}"
16
+ cancel-in-progress : ${{ github.event_name == 'pull_request' }}
17
+
18
+ env :
19
+ CUDA_VERSION : " 11.7"
20
+
21
+ jobs :
22
+ lint :
23
+ runs-on : ubuntu-latest
24
+ timeout-minutes : 30
25
+ steps :
26
+ - name : Checkout
27
+ uses : actions/checkout@v4
28
+ with :
29
+ submodules : " recursive"
30
+ fetch-depth : 1
31
+
32
+ - name : Set up Python 3.9
33
+ uses : actions/setup-python@v5
34
+ with :
35
+ python-version : " 3.9"
36
+ update-environment : true
37
+
38
+ - name : Upgrade pip
39
+ run : |
40
+ python -m pip install --upgrade pip setuptools wheel
41
+
42
+ - name : Install TorchOpt
43
+ env :
44
+ USE_FP16 : " OFF"
45
+ TORCH_CUDA_ARCH_LIST : " Auto"
46
+ run : |
47
+ python -m pip install torch numpy pybind11
48
+ python -m pip install -vvv --no-build-isolation --editable '.[lint]'
49
+
50
+ - name : pre-commit
51
+ run : |
52
+ make pre-commit
53
+
54
+ - name : ruff
55
+ run : |
56
+ make ruff
57
+
58
+ - name : flake8
59
+ run : |
60
+ make flake8
61
+
62
+ - name : isort and black
63
+ run : |
64
+ make py-format
65
+
66
+ - name : addlicense
67
+ run : |
68
+ make addlicense
Original file line number Diff line number Diff line change @@ -132,18 +132,34 @@ tokenizer = vl_chat_processor.tokenizer
132
132
vl_gpt: MultiModalityCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code = True )
133
133
vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()
134
134
135
+ # # single image conversation example
135
136
conversation = [
136
137
{
137
138
" role" : " User" ,
138
139
" content" : " <image_placeholder>Describe each stage of this image." ,
139
- " images" : [" ./images/training_pipelines.jpg" ]
140
+ " images" : [" ./images/training_pipelines.jpg" ],
140
141
},
141
- {
142
- " role" : " Assistant" ,
143
- " content" : " "
144
- }
142
+ {" role" : " Assistant" , " content" : " " },
145
143
]
146
144
145
+ # # multiple images (or in-context learning) conversation example
146
+ # conversation = [
147
+ # {
148
+ # "role": "User",
149
+ # "content": "<image_placeholder>A dog wearing nothing in the foreground, "
150
+ # "<image_placeholder>a dog wearing a santa hat, "
151
+ # "<image_placeholder>a dog wearing a wizard outfit, and "
152
+ # "<image_placeholder>what's the dog wearing?",
153
+ # "images": [
154
+ # "images/dog_a.png",
155
+ # "images/dog_b.png",
156
+ # "images/dog_c.png",
157
+ # "images/dog_d.png",
158
+ # ],
159
+ # },
160
+ # {"role": "Assistant", "content": ""}
161
+ # ]
162
+
147
163
# load images and prepare for inputs
148
164
pil_images = load_pil_images(conversation)
149
165
prepare_inputs = vl_chat_processor(
Original file line number Diff line number Diff line change 33
33
)
34
34
vl_gpt = vl_gpt .to (torch .bfloat16 ).cuda ().eval ()
35
35
36
+ # single image conversation example
36
37
conversation = [
37
38
{
38
39
"role" : "User" ,
42
43
{"role" : "Assistant" , "content" : "" },
43
44
]
44
45
46
+ # multiple images (or in-context learning) conversation example
47
+ # conversation = [
48
+ # {
49
+ # "role": "User",
50
+ # "content": "<image_placeholder>A dog wearing nothing in the foreground, "
51
+ # "<image_placeholder>a dog wearing a santa hat, "
52
+ # "<image_placeholder>a dog wearing a wizard outfit, and "
53
+ # "<image_placeholder>what's the dog wearing?",
54
+ # "images": [
55
+ # "images/dog_a.png",
56
+ # "images/dog_b.png",
57
+ # "images/dog_c.png",
58
+ # "images/dog_d.png",
59
+ # ],
60
+ # },
61
+ # {"role": "Assistant", "content": ""}
62
+ # ]
45
63
46
64
# load images and prepare for inputs
47
65
pil_images = load_pil_images (conversation )
Original file line number Diff line number Diff line change @@ -34,6 +34,20 @@ gradio = [
34
34
" markdown==3.4.1" ,
35
35
" SentencePiece==0.1.96"
36
36
]
37
+ lint = [
38
+ " isort" ,
39
+ " black[jupyter] >= 22.6.0" ,
40
+ " pylint[spelling] >= 2.15.0" ,
41
+ " flake8" ,
42
+ " flake8-bugbear" ,
43
+ " flake8-comprehensions" ,
44
+ " flake8-docstrings" ,
45
+ " flake8-pyi" ,
46
+ " flake8-simplify" ,
47
+ " ruff" ,
48
+ " pyenchant" ,
49
+ " pre-commit" ,
50
+ ]
37
51
38
52
[tool .setuptools ]
39
53
packages = {find = {exclude = [" images" ]}}
You can’t perform that action at this time.
0 commit comments