-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Frontend] Multi-Modality Support for Loading Local Image Files #9915
Conversation
👋 Hi! Thank you for contributing to the vLLM project. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can do one of these:
🚀 |
For security reasons, let's require a CLI flag to enable loading local image files. |
@DarkLight1337 What do you reckon would be a good name for a CLI flag? How about |
I think it is too easily confused with Perhaps |
I would suggest that the flag would instead be the allowed path vs. allowing full filesystem access. For example, --allow-local-media-path=/some/path |
3da0d02
to
bcbeb81
Compare
This pull request has merge conflicts that must be resolved before it can be |
2414a7e
to
8c3572b
Compare
b96fa0c
to
e8d1ab6
Compare
Test Code: from openai import OpenAI
# Modify OpenAI's API key and API base to use vLLM's API server.
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8000/v1"
client = OpenAI(
# defaults to os.environ.get("OPENAI_API_KEY")
api_key=openai_api_key,
base_url=openai_api_base,
)
models = client.models.list()
model = models.data[0].id
# Single-image input inference
def run_single_image() -> None:
# Use image url in the payload
# "https://upload.wikimedia.org/wikipedia/commons/d/da/2015_Kaczka_krzy%C5%BCowka_w_wodzie_%28samiec%29.jpg"
image_url = "file:///root/jxy/vllm-source/vllm/duck.jpg"
chat_completion_from_url = client.chat.completions.create(
messages=[{
"role":
"user",
"content": [
{
"type": "text",
"text": "What's in this image?"
},
{
"type": "image_url",
"image_url": {
"url": image_url
},
},
],
}],
model=model,
max_completion_tokens=64,
)
result = chat_completion_from_url.choices[0].message.content
print("Chat completion output from image url:", result)
def main() -> None:
run_single_image()
if __name__ == "__main__":
main()
Test 1: # vllm serve microsoft/Phi-3.5-vision-instruct --task generate \
--trust-remote-code --max-model-len 4096 --limit-mm-per-prompt image=2 \
--dtype=float16 --enforce-eager \
--allowed-local-media-path=/root/jxy/vllm-source/vllm
# python run_single_image.py
Chat completion output from image url: The image shows a single mallard duck swimming on a body of water. The duck has a distinctive green head, yellow bill, white neck ring, and brown chest. The water appears calm, creating a clear reflection of the duck. # vllm serve microsoft/Phi-3.5-vision-instruct --task generate \
--trust-remote-code --max-model-len 4096 --limit-mm-per-prompt image=2 \
--dtype=float16 --enforce-eager
# python run_single_image.py 2 ↵
..
openai.BadRequestError: Error code: 400 - {'object': 'error', 'message': "Invalid 'image_url': Cannot load local files without '--allowed-local-media-path'.", 'type': 'BadRequestError', 'param': None, 'code': 400}
|
/cc @DarkLight1337 PTAL. |
5aa7b79
to
d71bf75
Compare
d71bf75
to
f7f2303
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks good, can you add some tests to verify this?
f7f2303
to
911c6e9
Compare
FIX vllm-project#8730 Signed-off-by: chaunceyjiang <[email protected]>
911c6e9
to
5e1f5fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing this!
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]> Signed-off-by: Linkun Chen <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]> Signed-off-by: Richard Liu <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]>
Signed-off-by: chaunceyjiang <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]> Signed-off-by: Loc Huynh <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]> Signed-off-by: Sumit Dubey <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]> Signed-off-by: Maxime Fournioux <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]> Signed-off-by: Tyler Michael Smith <[email protected]>
…-project#9915) Signed-off-by: chaunceyjiang <[email protected]>
FIX #8730
FIX #9742
Multi-Modality Support for Loading Local image Files