-
Notifications
You must be signed in to change notification settings - Fork 2.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
Draft demo #778
Draft demo #778
Conversation
Codecov Report
@@ Coverage Diff @@
## main #778 +/- ##
==========================================
+ Coverage 81.91% 82.81% +0.90%
==========================================
Files 17 21 +4
Lines 1255 1135 -120
==========================================
- Hits 1028 940 -88
+ Misses 227 195 -32
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
client/clip_client/client.py
Outdated
self._client.post( | ||
**payload, | ||
on=f'/encode/{model_name}'.rstrip('/'), | ||
inputs=self._iter_doc(content), | ||
on_done=partial(self._gather_result, results=results), | ||
) |
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.
self._client.post( | |
**payload, | |
on=f'/encode/{model_name}'.rstrip('/'), | |
inputs=self._iter_doc(content), | |
on_done=partial(self._gather_result, results=results), | |
) | |
self._client.post( | |
on=f'/encode/{model_name}'.rstrip('/'), | |
inputs=self._iter_doc(content), | |
on_done=partial(self._gather_result, results=results), | |
**payload, | |
) |
@jemmyshin Pleas rebase your PR to fix the conflict. |
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.
We should take care of the user experience. Let's polish the client API to offer an easy-to-use client regarding to user's perspective.
client/clip_client/client.py
Outdated
|
||
parameters = kwargs.pop('parameters', {}) | ||
model_name = parameters.get('model', '') | ||
payload = self._get_post_parameters(content, kwargs) |
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.
rename it as params
?
client/clip_client/client.py
Outdated
|
||
def index(self, content: Iterable['Document'], **kwargs): | ||
"""Index the embeddings created by server CLIP model. | ||
Given the document with embeddings, this function create an indexer which index |
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 docstr is not corrct. index
and query
functions both accept raw text/image docs without embeddings.
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.
What's more, we also implment async version, aindex
, aquery
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 index
should have the same function signature as encode
client/clip_client/client.py
Outdated
with self._pbar: | ||
self._client.post(on='/index', inputs=self._iter_doc(content), **payload) | ||
|
||
def search(self, content: List[str], **kwargs) -> DocumentArray: |
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.
search
should also accept either str
and Document
client/clip_client/client.py
Outdated
total=len(content) if hasattr(content, '__len__') else None, | ||
) | ||
results = DocumentArray() | ||
|
||
parameters = kwargs.pop('parameters', {}) |
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.
alright, pop
operator would raise an exception when the given key
does not exist.
@@ -114,10 +117,17 @@ def encode(self, content, **kwargs): | |||
total=len(content) if hasattr(content, '__len__') else None, | |||
) | |||
results = DocumentArray() | |||
|
|||
model_name = parameters.get('model', '') |
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.
raise error when parameters=None
@jemmyshin please rebase your PR to fix conflicts |
@@ -284,9 +292,16 @@ async def aencode(self, content, **kwargs): | |||
) | |||
|
|||
results = DocumentArray() | |||
|
|||
model_name = parameters.get('model', '') |
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.
parameters
can be None, and will raise error here. Please fix it
server/clip_server/demo-flow.yml
Outdated
jtype: AnnLiteIndexer | ||
with: | ||
dim: 512 | ||
data_path: /Users/jemfu/Desktop/laion400m/workspace |
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.
don't use absolute real path
|
||
with self._pbar: | ||
self._client.post( | ||
on='/index', |
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.
will we also support selection from different indexers?
@jemmyshin This PR has been merged to #816. I will close this PR first. let's work on the new PR. |
No description provided.