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
98a3e8ef
Unverified
Commit
98a3e8ef
authored
Jan 18, 2024
by
Lianmin Zheng
Committed by
GitHub
Jan 18, 2024
Browse files
Add a llava example (#47)
parent
2b079f89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
examples/quick_start/srt_example_llava.py
examples/quick_start/srt_example_llava.py
+18
-0
No files found.
examples/quick_start/srt_example_llava.py
0 → 100644
View file @
98a3e8ef
import
sglang
as
sgl
@
sgl
.
function
def
image_qa
(
s
,
image_path
,
question
):
s
+=
sgl
.
user
(
sgl
.
image
(
image_path
)
+
question
)
s
+=
sgl
.
assistant
(
sgl
.
gen
(
"answer"
))
runtime
=
sgl
.
Runtime
(
model_path
=
"liuhaotian/llava-v1.5-7b"
,
tokenizer_path
=
"llava-hf/llava-1.5-7b-hf"
)
sgl
.
set_default_backend
(
runtime
)
state
=
image_qa
.
run
(
image_path
=
"images/cat.jpeg"
,
question
=
"What is this?"
)
print
(
state
[
"answer"
])
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