brandontrabucco / da-fusion

Effective Data Augmentation With Diffusion Models
MIT License
222 stars 18 forks source link

OSError: Token is required (`token=True`), but no token found #4

Closed mgcyung closed 1 year ago

mgcyung commented 1 year ago

Hi, I have ran the fine_tune.py with a custom dataset with only one class called "Chrysomelida hindwing" and the learned_embeddings are generated. However, when I try to run generate_images.py, an error said "OSError: Token is required (token=True), but no token found. "

The command is as follows:

python3 generate_images.py --out=../train_dirs/hwlfc_01/generated_images \
--embed-path="../train_dirs/hwlfc_01/fine-tuned/hwlfc-0-16/Chrysomelida_hindwing/learned_embeds.bin" \
--erasure-ckpt-name None \
--prompt "a photo of a <Chrysomelida hindwing>"

And the full backtrace is as follows:

Traceback (most recent call last):
  File "generate_images.py", line 46, in <module>
    pipe = StableDiffusionPipeline.from_pretrained(
  File "/home/dell/.local/lib/python3.8/site-packages/diffusers/pipelines/pipeline_utils.py", line 884, in from_pretrained
    cached_folder = cls.download(
  File "/home/dell/.local/lib/python3.8/site-packages/diffusers/pipelines/pipeline_utils.py", line 1208, in download
    config_file = hf_hub_download(
  File "/home/dell/.local/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 120, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/dell/.local/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1181, in hf_hub_download
    headers = build_hf_headers(
  File "/home/dell/.local/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 120, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/dell/.local/lib/python3.8/site-packages/huggingface_hub/utils/_headers.py", line 117, in build_hf_headers
    token_to_send = get_token_to_send(token)
  File "/home/dell/.local/lib/python3.8/site-packages/huggingface_hub/utils/_headers.py", line 149, in get_token_to_send
    raise EnvironmentError(
OSError: Token is required (`token=True`), but no token found. You need to provide a token or be logged in to Hugging Face with `huggingface-cli login` or `huggingface_hub.login`. See https://huggingface.co/settings/tokens.
brandontrabucco commented 1 year ago

Hello mgcyung,

Thanks for getting in touch. Stable Diffusion access through HuggingFace requires you to be logged in to the HuggingFace CLI in the terminal where you ran the python script. You might find this quickstart guide helpful:

https://huggingface.co/docs/huggingface_hub/quick-start

In addition, based on this line of the textual inversion script, class names are converted into a special token like <Chrysomelida_hindwing>.

Let me know if these fix the issue!

Best, Brandon

mgcyung commented 1 year ago

Hello brandontrabucco,

Thank you for reaching out to me. I am glad to inform you that I have solved the problem by replacing the use_auth_token=True with use_auth_token=False in the from_pretrained function. I appreciate your suggestion and the quickstart guide you provided. It was very helpful in understanding the Stable Diffusion access through HuggingFace.

I also took note of the line you mentioned in the textual inversion script, where class names Chrysomelida hindwing are converted into a special token <Chrysomelida_hindwing> but not <Chrysomelida hindwing>.

Thank you once again for your assistance.

Best mgcyung

201811510210hjx commented 1 year ago

Hello brandontrabucco,

Thank you for reaching out to me. I am glad to inform you that I have solved the problem by replacing the use_auth_token=True with use_auth_token=False in the from_pretrained function. I appreciate your suggestion and the quickstart guide you provided. It was very helpful in understanding the Stable Diffusion access through HuggingFace.

I also took note of the line you mentioned in the textual inversion script, where class names Chrysomelida hindwing are converted into a special token <Chrysomelida_hindwing> but not <Chrysomelida hindwing>.

Thank you once again for your assistance.

Best mgcyung

Hello, can you tell us how to solve it?

brandontrabucco commented 1 year ago

A more detailed answer to this is in issue https://github.com/brandontrabucco/da-fusion/issues/9