-
Notifications
You must be signed in to change notification settings - Fork 123
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
Solution to #258 [CLIP][Server/Engine] Send images to engine / accept PIL images #353
Conversation
@Gavinfornever Thanks for your efforts! Short comment here. I think its slightly more complicated. Potentially, you need two fields, file_upload for pngs and list of urls, as two variables (makes ordering complicated). Roughly the server side code: async def embed_image(
...
upload_images: UploadFile, # maybe also list[images]
input: list[url]
...
):
....
images= await upload_images.read()
.... Roughly Client code for that example: async with aiohttp.ClientSession() as session:
form_data = aiohttp.FormData()
form_data.add_field(
content_type="application/png",
filename="dummy.png",
name="upload_image",
value=file,
)
form_data.add_field(name="input", value=[url1,url2])
... # more form data if needed.
async with session.post(
url=f"localhost:7997/v1/image_embed/",
data=form_data,
) as response:
response.raise_for_status()
json_response = await response.json() |
I would say, break this PR up into two. First PR:
Second PR:
|
@michaelfeil FYI, in the test, poetry made me modify the import format of typing in async_engine.py(which is odd cause in other places import is not that strict). Otherwise, it cannot pass the make lint # 3.12. Last, this pr achieve image inputs to Engine ONLY but for Server it will be accomplished in future pr like michael said above. |
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.
Overall nice work.
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #353 +/- ##
==========================================
- Coverage 78.03% 77.97% -0.06%
==========================================
Files 35 35
Lines 2549 2574 +25
==========================================
+ Hits 1989 2007 +18
- Misses 560 567 +7 ☔ View full report in Codecov by Sentry. |
…r PIL.Image.Image
…r PIL.Image.Image
…r PIL.Image.Image
…talled users, and define type hint for PIL.Image.Image
…talled users, and define type hint for PIL.Image.Image
…talled users, and define type hint for PIL.Image.Image
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.
PR Summary
This pull request implements support for both URL strings and PIL Image objects as input for image embedding in the Infinity project, addressing issue #258.
- Added functionality in
engine.py
andbatch_handler.py
to handle mixed input types (URLs and PIL Images) for theimage_embed
method - Introduced new types and error handling in
primitives.py
to support PIL Image objects and improve type checking for image-related classes - Modified
utils.py
to resolve images from both URLs and PIL Image objects, with improved error handling and flexibility - Added a new test case
test_clip_embed_pil_image_input
intest_engine.py
to verify PIL Image input functionality - Updated
sync_engine.py
to align with the new image embedding capabilities, supporting mixed input types
7 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings
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.
Approved. Before merging, please resolve the comments I left.
…test& poetry lock file
@michaelfeil |
Thanks Gao for your contribution, awesome work. Excited for more! |
My pleasure! Looking into the benchmark stuff soon. |
Hi everyone. I'm a developer using Infinity to build LLM deployment&inference platform and now hope to contribute this wonderful project! I've met this exact issue(#258) before and bypassed it by "image_emb, _ = await self.engine._batch_handler._schedule(images)". But this isn't intuitive or usable when inputs are mixed with urls and Image objects.
So I try to solve this issue with michael's instructions and my ideas. @michaelfeil
And have basically accomplished the following:
Questions:
I suggest adding bytes stream input to this api. In my familiar situations, images are stored and shared among modules to reduce redundance of downloading; or just pass imgs using bytes stream among apis.