Add a llava example (#47)
This commit is contained in:
18
examples/quick_start/srt_example_llava.py
Normal file
18
examples/quick_start/srt_example_llava.py
Normal file
@@ -0,0 +1,18 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user