bghira / SimpleTuner

A general fine-tuning kit geared toward diffusion models.
GNU Affero General Public License v3.0
1.76k stars 165 forks source link

`(PromptHandler) Could not locate image` #494

Closed MohamedAliRashad closed 4 months ago

MohamedAliRashad commented 4 months ago

I am meeting this error and i don't know what exactly i did wrong. This is multidatabackend.json content:

[
    {
      "id": "civitai-images",
      "type": "local",
      "crop": true,
      "crop_aspect": "square",
      "crop_style": "center",
      "resolution": 0.5,
      "minimum_image_size": 0.25,
      "maximum_image_size": 1.0,
      "target_downsample_size": 1.0,
      "resolution_type": "area",
      "cache_dir_vae": "cache/vae/sd3/civitai-images",
      "instance_data_dir": "/shared_volume/development/text_to_image/high_quality_dataset/civitai_images",
      "disabled": false,
      "prepend_instance_prompt": false,
      "skip_file_discovery": "",
      "caption_strategy": "parquet",
      "metadata_backend": "parquet",
      "parquet": {
        "path": "/shared_volume/development/text_to_image/high_quality_dataset/final_prompts.parquet",
        "filename_column": "file_name",
        "caption_column": "long_prompt",
        "fallback_caption_column": "long_prompt",
        "width_column": "width",
        "height_column": "height",
        "identifier_includes_extension": true
      }
    },
    {
      "id": "text-embeds",
      "type": "local",
      "dataset_type": "text_embeds",
      "default": true,
      "cache_dir": "cache/vae/sd3/civitai-images",
      "disabled": false,
      "write_batch_size": 128
    }
  ]

And this is the full error:

2024-06-19 07:48:45,086 [ERROR] (PromptHandler) Could not locate image /shared_volume/development/text_to_image/high_quality_dataset/civitai_images/10285834.jpg via stem 10285834.jpg in sampler_backend civitai-images with filename column file_name, caption column long_prompt, and a parquet database with 2078 entries. Using filename as prompt.
2024-06-19 07:48:45,090 [ERROR] (PromptHandler) Could not locate image /shared_volume/development/text_to_image/high_quality_dataset/civitai_images/10276818.jpg via stem 10276818.jpg in sampler_backend civitai-images with filename column file_name, caption column long_prompt, and a parquet database with 2078 entries. Using filename as prompt.
2024-06-19 07:48:45,090 [ERROR] (PromptHandler) Could not locate image /shared_volume/development/text_to_image/high_quality_dataset/civitai_images/10330062.jpg via stem 10330062.jpg in sampler_backend civitai-images with filename column file_name, caption column long_prompt, and a parquet database with 2078 entries. Using filename as prompt.
2024-06-19 07:48:45,092 [ERROR] (PromptHandler) Could not locate image /shared_volume/development/text_to_image/high_quality_dataset/civitai_images/10285834.jpg via stem 10285834.jpg in sampler_backend civitai-images with filename column file_name, caption column long_prompt, and a parquet database with 2078 entries. Using filename as prompt.
2024-06-19 07:48:45,098 [ERROR] (PromptHandler) Could not locate image /shared_volume/development/text_to_image/high_quality_dataset/civitai_images/10330062.jpg via stem 10330062.jpg in sampler_backend civitai-images with filename column file_name, caption column long_prompt, and a parquet database with 2078 entries. Using filename as prompt.
2024-06-19 07:48:45,103 [ERROR] (PromptHandler) Could not locate image /shared_volume/development/text_to_image/high_quality_dataset/civitai_images/10715865.jpg via stem 10715865.jpg in sampler_backend civitai-images with filename column file_name, caption column long_prompt, and a parquet database with 2078 entries. Using filename as prompt.
bghira commented 4 months ago

chances are the file_name column doesn't have 10285834.jpg

MohamedAliRashad commented 4 months ago

@bghira No, It's avialable

bghira commented 4 months ago

you'll have to set the log level to debug and then try to run it again and see debug.log

bghira commented 4 months ago

@MohamedAliRashad if you can upload that parquet file somewhere i can take a look at it.

MohamedAliRashad commented 4 months ago

@bghira It's based on the same structure as the image datasets in huggingface You can find an example here: https://huggingface.co/datasets/MohamedRashad/midjourney-detailed-prompts

bghira commented 4 months ago

i don't see the file_name column in that. can you use:

parquet-tools csv file.parquet | head -n2

to show me a single row of your actual parquet table

MohamedAliRashad commented 4 months ago

@bghira I hope this helps you

file_name,image_description,prompt,negative_prompt,stats,width,height,long_prompt
10957242.jpg,"The image depicts a human skull with a set of human legs attached to it, creating a figure that stands upright. The skull is positioned at the top, with the jaw slightly open, and the teeth visible. The legs are positioned below the skull, with the feet flat on the ground, giving the impression that the skull is the head of the figure. The figure is set against a neutral, dark background, which contrasts with the pale color of the skull and bones. The overall effect is eerie and somewhat macabre, as it combines the features of a human skull with the anatomy of a human body.","skull with legs, standing",,"{'commentCount': 4, 'cryCount': 27, 'dislikeCount': 0, 'heartCount': 205, 'laughCount': 239, 'likeCount': 485}",768,768," A hauntingly eerie illustration of a human skull with fully articulated legs, standing upright, jaw slightly ajar revealing teeth, set against a stark, dark background, with the skull's pale bones starkly contrasting the surrounding shadows, capturing a surreal fusion of human anatomy and skeletal structure in a single, chilling composition."
11070298.jpg,"This image depicts a vibrant underwater scene with a large, animated blue whale as the central figure. The whale has orange fins and a white underbelly, and it appears to be swimming gracefully through the water. The background is filled with a variety of colorful coral reefs and marine life, including smaller fish of different shapes and colors. The water is a clear blue, and the light filtering through from the surface creates a serene and inviting atmosphere. The overall impression is one of a lively and biodiverse underwater ecosystem.","zPDXL, astonishing ((underwater)) landscape, colored fishes, reef,",zPDXL-neg,"{'commentCount': 1, 'cryCount': 25, 'dislikeCount': 0, 'heartCount': 171, 'laughCount': 76, 'likeCount': 544}",832,1216," A vibrant underwater scene with a majestic animated blue whale as the central figure, swimming gracefully through the crystal-clear blue water. The whale boasts striking orange fins and a pristine white underbelly, surrounded by a kaleidoscope of colorful coral reefs and diverse marine life. Smaller fish of various shapes and hues dart around the whale, adding to the lively atmosphere. The serene light filtering down from the surface bathes the scene in a tranquil glow, highlighting the rich biodiversity of this underwater ecosystem."
MohamedAliRashad commented 4 months ago

@bghira I pulled latest changes and a new error shown up

Traceback (most recent call last):
  File "/shared_volume/development/text_to_image/SimpleTuner/train_sdxl.py", line 2231, in <module>
    main()
  File "/shared_volume/development/text_to_image/SimpleTuner/train_sdxl.py", line 1491, in main
    for step, batch in random_dataloader_iterator(train_backends):
  File "/shared_volume/development/text_to_image/SimpleTuner/helpers/data_backend/factory.py", line 929, in random_dataloader_iterator
    yield (step, next(chosen_iter))
                 ^^^^^^^^^^^^^^^^^
  File "/shared_volume/development/text_to_image/SimpleTuner/.venv/lib/python3.11/site-packages/torch/utils/data/dataloader.py", line 631, in __next__
    data = self._next_data()
           ^^^^^^^^^^^^^^^^^
  File "/shared_volume/development/text_to_image/SimpleTuner/.venv/lib/python3.11/site-packages/torch/utils/data/dataloader.py", line 674, in _next_data
    index = self._next_index()  # may raise StopIteration
            ^^^^^^^^^^^^^^^^^^
  File "/shared_volume/development/text_to_image/SimpleTuner/.venv/lib/python3.11/site-packages/torch/utils/data/dataloader.py", line 621, in _next_index
    return next(self._sampler_iter)  # may raise StopIteration
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/shared_volume/development/text_to_image/SimpleTuner/.venv/lib/python3.11/site-packages/torch/utils/data/sampler.py", line 287, in __iter__
    for idx in self.sampler:
  File "/shared_volume/development/text_to_image/SimpleTuner/helpers/multiaspect/sampler.py", line 459, in __iter__
    to_yield = self._validate_and_yield_images_from_samples(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/shared_volume/development/text_to_image/SimpleTuner/helpers/multiaspect/sampler.py", line 383, in _validate_and_yield_images_from_samples
    image_metadata["instance_prompt_text"] = PromptHandler.magic_prompt(
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/shared_volume/development/text_to_image/SimpleTuner/helpers/prompts.py", line 352, in magic_prompt
    instance_prompt = PromptHandler.prepare_instance_prompt_from_parquet(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/shared_volume/development/text_to_image/SimpleTuner/helpers/prompts.py", line 240, in prepare_instance_prompt_from_parquet
    image_caption = metadata_backend.caption_cache_entry(image_filename_stem)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'JsonMetadataBackend' object has no attribute 'caption_cache_entry'
MohamedAliRashad commented 4 months ago

@bghira It worked, I just needed to make metadata_backend also parquet

bghira commented 4 months ago

but in the first post here, it was!

MohamedAliRashad commented 4 months ago

@bghira I moved it to json to match the tutorial