Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
711d3435
Commit
711d3435
authored
Jan 24, 2024
by
Lianmin Zheng
Browse files
add a batch llava example
parent
6dceab4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
benchmark/llava_bench/README.md
benchmark/llava_bench/README.md
+1
-0
examples/quick_start/srt_example_llava.py
examples/quick_start/srt_example_llava.py
+22
-2
No files found.
benchmark/llava_bench/README.md
View file @
711d3435
...
@@ -8,6 +8,7 @@ image benchmark source: https://huggingface.co/datasets/liuhaotian/llava-bench-i
...
@@ -8,6 +8,7 @@ image benchmark source: https://huggingface.co/datasets/liuhaotian/llava-bench-i
### Other Dependency
### Other Dependency
```
```
pip3 install "sglang[all]"
pip3 install "torch>=2.1.2" "transformers>=4.36" pillow
pip3 install "torch>=2.1.2" "transformers>=4.36" pillow
```
```
...
...
examples/quick_start/srt_example_llava.py
View file @
711d3435
"""
Usage: python3 srt_example_llava.py
"""
import
sglang
as
sgl
import
sglang
as
sgl
...
@@ -12,7 +15,24 @@ runtime = sgl.Runtime(model_path="liuhaotian/llava-v1.5-7b",
...
@@ -12,7 +15,24 @@ runtime = sgl.Runtime(model_path="liuhaotian/llava-v1.5-7b",
sgl
.
set_default_backend
(
runtime
)
sgl
.
set_default_backend
(
runtime
)
state
=
image_qa
.
run
(
image_path
=
"images/cat.jpeg"
,
question
=
"What is this?"
)
# Single
print
(
state
[
"answer"
])
state
=
image_qa
.
run
(
image_path
=
"images/cat.jpeg"
,
question
=
"What is this?"
,
max_new_tokens
=
64
)
print
(
state
[
"answer"
],
"
\n
"
)
# Batch
states
=
image_qa
.
run_batch
(
[
{
"image_path"
:
"images/cat.jpeg"
,
"question"
:
"What is this?"
},
{
"image_path"
:
"images/dog.jpeg"
,
"question"
:
"What is this?"
},
],
max_new_tokens
=
64
,
)
for
s
in
states
:
print
(
s
[
"answer"
],
"
\n
"
)
runtime
.
shutdown
()
runtime
.
shutdown
()
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