Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
b9e84259
"vscode:/vscode.git/clone" did not exist on "d44e9df7d49a9bb3400b002c38c06fae2dd7d1e8"
Unverified
Commit
b9e84259
authored
Jun 26, 2024
by
Roger Wang
Committed by
GitHub
Jun 26, 2024
Browse files
[Misc] Add example for LLaVA-NeXT (#5879)
parent
294104c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
examples/llava_next_example.py
examples/llava_next_example.py
+38
-0
No files found.
examples/llava_next_example.py
0 → 100644
View file @
b9e84259
from
io
import
BytesIO
import
requests
from
PIL
import
Image
from
vllm
import
LLM
,
SamplingParams
from
vllm.multimodal.image
import
ImagePixelData
# Dynamic image input is currently not supported and therefore
# a fixed image input shape and its corresponding feature size is required.
# See https://github.com/vllm-project/vllm/pull/4199 for the complete
# configuration matrix.
llm
=
LLM
(
model
=
"llava-hf/llava-v1.6-mistral-7b-hf"
,
image_input_type
=
"pixel_values"
,
image_token_id
=
32000
,
image_input_shape
=
"1,3,336,336"
,
image_feature_size
=
1176
,
)
prompt
=
"[INST] "
+
"<image>"
*
1176
+
"
\n
What is shown in this image? [/INST]"
url
=
"https://h2o-release.s3.amazonaws.com/h2ogpt/bigben.jpg"
image
=
Image
.
open
(
BytesIO
(
requests
.
get
(
url
).
content
))
sampling_params
=
SamplingParams
(
temperature
=
0.8
,
top_p
=
0.95
,
max_tokens
=
100
)
outputs
=
llm
.
generate
(
{
"prompt"
:
prompt
,
"multi_modal_data"
:
ImagePixelData
(
image
),
},
sampling_params
=
sampling_params
)
generated_text
=
""
for
o
in
outputs
:
generated_text
+=
o
.
outputs
[
0
].
text
print
(
f
"LLM output:
{
generated_text
}
"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment