diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Custom Diffusion retrieve.py

Open rezkanas opened this issue 1 year ago β€’ 17 comments

Describe the bug

when running retrieve.py to produce class prior photo using laion datasset,, I run through below errors. url is bad in the code below... could be the root cause?

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

Reproduction

!python retrieve.py --class_prompt person --class_data_dir /mnt/c/Users/noobw/PycharmProjects/pythonProject/custom_diffusion_anas/class_prior --num_class_images 200

Logs

/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Traceback (most recent call last):
  File "/home/anasrezklinux/.local/lib/python3.10/site-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 "/home/anasrezklinux/test_pycharm_link/diffusers/examples/custom_diffusion/retrieve.py", line 87, in <module>
    retrieve(args.class_prompt, args.class_data_dir, args.num_class_images)
  File "/home/anasrezklinux/test_pycharm_link/diffusers/examples/custom_diffusion/retrieve.py", line 37, in retrieve
    class_images = client.query(text=class_prompt)
  File "/home/anasrezklinux/.local/lib/python3.10/site-packages/clip_retrieval/clip_client.py", line 84, in query
    return self.__search_knn_api__(text=text)
  File "/home/anasrezklinux/.local/lib/python3.10/site-packages/clip_retrieval/clip_client.py", line 153, in __search_knn_api__
    ).json()
  File "/home/anasrezklinux/.local/lib/python3.10/site-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)

System Info

  • diffusers version: 0.26.1
  • Platform: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
  • Python version: 3.10.12
  • PyTorch version (GPU?): 2.2.0+cu121 (True)
  • Huggingface_hub version: 0.20.3
  • Transformers version: 4.37.0
  • Accelerate version: 0.25.0
  • xFormers version: 0.0.24
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help?

@sayakpaul @patrickvonplaten

rezkanas avatar Feb 06 '24 23:02 rezkanas

The website "https://knn.laion.ai/knn-service is down

Ashutosh7982 avatar Feb 07 '24 07:02 Ashutosh7982

I realize that but then how can retrieve.py be run?

rezkanas avatar Feb 07 '24 08:02 rezkanas

Meaning?

sayakpaul avatar Feb 07 '24 08:02 sayakpaul

@sayakpaul, I don't understand your response. website is down, do I need to wait? or probably the url is broken?

rezkanas avatar Feb 07 '24 19:02 rezkanas

You can add these images manually with the following structure:

your_class_data_dir
β”œβ”€β”€ images
β”‚   β”œβ”€β”€ 01.jpg
β”‚   β”œβ”€β”€ 02.jpg
β”œβ”€β”€ caption.txt # captions line by line
└── images.txt # absolute path line by line

Also, remember the number of images should be the same as:

--num_class_images=200

OchiaiNao avatar Feb 07 '24 23:02 OchiaiNao

The website incurs ratelimiting issues because it's used by many folks. So, that is a constraint.

sayakpaul avatar Feb 08 '24 03:02 sayakpaul

It this fixed?

yiyixuxu avatar Feb 18 '24 06:02 yiyixuxu

@yiyixuxu it depends on the service that retrieve.py relies on. We cannot do much here.

sayakpaul avatar Feb 18 '24 06:02 sayakpaul

I also has the same issue

TruongQuocTruong avatar Feb 27 '24 16:02 TruongQuocTruong

Same error. Do u guys can run retrieve.py now?

daeunni avatar Mar 11 '24 03:03 daeunni

I have the same issue,

WuTao-CS avatar Mar 11 '24 08:03 WuTao-CS

The retrieve.py script relies on external services. Commenting with the same thing won’t help the issue :-)

sayakpaul avatar Mar 11 '24 08:03 sayakpaul

I have the same issue, are there any alternative URLs available?

Sakura-hub47 avatar Apr 02 '24 12:04 Sakura-hub47

I don't think there is.

sayakpaul avatar Apr 02 '24 12:04 sayakpaul

I don't think there is.

Hi, can you share a new link which includes the data (from retrieve.py) we want? So sorry to bother you.

boringKey avatar Apr 15 '24 16:04 boringKey

FYI as people doesn't seem to know:

retrieve.py is from clip-retrieval which connected to the LAION dataset.

LAION has a zero tolerance policy for illegal content and in an abundance of caution, we are temporarily taking down the LAION datasets to ensure they are safe before republishing them.

This was posted on the 19th of December, 2023 and it still down, so don't expect it to be up soon if it ever comes back.

asomoza avatar Apr 15 '24 22:04 asomoza

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar May 10 '24 15:05 github-actions[bot]