rom1504 / clip-retrieval

Easily compute clip embeddings and build a clip retrieval system with them
https://rom1504.github.io/clip-retrieval/
MIT License
2.42k stars 213 forks source link

server question? #306

Closed xinli2008 closed 10 months ago

xinli2008 commented 1 year ago

hello, i have installed the clip-retrieval package and try the demo code as follows:

`from clip_retrieval.clip_client import ClipClient, Modality

client = ClipClient(url="https://knn.laion.ai/knn-service", indice_name="laion5B-L-14")

results = client.query(text="an image of a cat")

results[0] ` but the error happens: Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib/python3.8/json/init.py", line 357, in loads return _default_decoder.decode(s) File "/usr/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.8/dist-packages/clip_retrieval/clip_client.py", line 84, in query return self.search_knn_api(text=text) File "/usr/local/lib/python3.8/dist-packages/clip_retrieval/clip_client.py", line 131, in search_knn_api return requests.post( File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

results = client.query(text="an image of a cat") Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib/python3.8/json/init.py", line 357, in loads return _default_decoder.decode(s) File "/usr/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.8/dist-packages/clip_retrieval/clip_client.py", line 84, in query return self.search_knn_api(text=text) File "/usr/local/lib/python3.8/dist-packages/clip_retrieval/clip_client.py", line 131, in search_knn_api return requests.post( File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It seems that something happened with the server? @

Sandeep-Narahari commented 1 year ago

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib/python3.10/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/usr/lib/python3.10/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/content/diffusers/examples/custom_diffusion/retrieve.py", line 92, in retrieve(args.class_prompt, args.class_data_dir, args.num_class_images) File "/content/diffusers/examples/custom_diffusion/retrieve.py", line 37, in retrieve class_images = client.query(text=class_prompt) File "/usr/local/lib/python3.10/dist-packages/clip_retrieval/clip_client.py", line 84, in query return self.search_knn_api(text=text) File "/usr/local/lib/python3.10/dist-packages/clip_retrieval/clip_client.py", line 152, in search_knn_api ).json() File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I am facing the same issue , any on here to help , any update on this Thank you

rom1504 commented 1 year ago

Automated throttling happens when too many requests are being queued.

Try to slow down your request rate and retry

What is your use case ?

On Thu, Sep 7, 2023, 11:25 Sandeep Narahari @.***> wrote:

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, *kwargs) File "/usr/lib/python3.10/json/init*.py", line 346, in loads return _default_decoder.decode(s) File "/usr/lib/python3.10/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/content/diffusers/examples/custom_diffusion/retrieve.py", line 92, in retrieve(args.class_prompt, args.class_data_dir, args.num_class_images) File "/content/diffusers/examples/custom_diffusion/retrieve.py", line 37, in retrieve class_images = client.query(text=class_prompt) File "/usr/local/lib/python3.10/dist-packages/clip_retrieval/clip_client.py", line 84, in query return self.search_knn_api(text=text) File "/usr/local/lib/python3.10/dist-packages/clip_retrieval/clip_client.py", line 152, in search_knn_api ).json() File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I am facing the same issue , any on here to help , any update on this Thank you

— Reply to this email directly, view it on GitHub https://github.com/rom1504/clip-retrieval/issues/306#issuecomment-1709697160, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437RLTMKUSWXLC2GLPN3XZGAGZANCNFSM6AAAAAA3WJKSCM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Sandeep-Narahari commented 1 year ago

Before training the custom diffusion model there is a step which to(collect 200 real images using clip-retrieval which are combined with the target images in the training dataset as a regularization. This prevents overfitting to the the given target image ) https://github.com/huggingface/diffusers/blob/main/examples/custom_diffusion/retrieve.py https://github.com/huggingface/diffusers/tree/main/examples/custom_diffusion

Sandeep-Narahari commented 1 year ago

I will be using this for production purpose , so how can I solve this issue @rom1504 , Thanks

rom1504 commented 1 year ago

If you want to use it for production I advise you host the index yourself. See the guide for how to do it in the readme

On Thu, Sep 7, 2023, 20:10 Sandeep Narahari @.***> wrote:

I will be using this for production purpose , so how can I solve this issue @rom1504 https://github.com/rom1504 , Thanks

— Reply to this email directly, view it on GitHub https://github.com/rom1504/clip-retrieval/issues/306#issuecomment-1710509917, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437VPXLFIJNTAUGZLHHLXZH5Z3ANCNFSM6AAAAAA3WJKSCM . You are receiving this because you were mentioned.Message ID: @.***>

daeunni commented 10 months ago

@Sandeep-Narahari Hi, I have a same issue. Did you address it?

rom1504 commented 10 months ago

324