Skip to content
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

Issue in Transformation Step Code #1

Open
saraalemadi opened this issue Jul 20, 2023 · 3 comments
Open

Issue in Transformation Step Code #1

saraalemadi opened this issue Jul 20, 2023 · 3 comments

Comments

@saraalemadi
Copy link

Hi,

I am trying to replicate your experiments. I was able to successfully follow the Finetuning of Diffusion Model
step mentioned here. However, when I tried running the code provided for the Transformation step, I get the following error:

Traceback (most recent call last):
  File "scripts/augment.py", line 444, in <module>
    main()
  File "scripts/augment.py", line 355, in main
    print(outstr)
UnboundLocalError: local variable 'outstr' referenced before assignment

When I commented out: print(outstr) and changed the --dataset PACS_Augmentation to PACS, I got the following error:

File "scripts/augment.py", line 444, in <module>
    main()
  File "scripts/augment.py", line 353, in main
    dataset = onedomainPACS_withlabel(root = "../../Data/", test_envs = opt.domain_index, data_augmentation = False, image_size = 256)
NameError: name 'onedomainPACS_withlabel' is not defined

Therefore, I would greatly appreciate your clarification on how to run this step.

Thanks.
Sara A. Al-Emadi

@yu-rp
Copy link
Owner

yu-rp commented Jul 30, 2023

Dear Sara A. Al-Emadi,

The typo is corrected and the new code is

  if opt.dataset == "PACS_augmentation":
      dataset = onedomainPACS(root = "~/Data/", test_envs = opt.domain_index, data_augmentation = False, image_size = 256)

Thank you for your interest in our work and for pointing out this typo.

Best,
Runpeng

@yu-rp yu-rp closed this as completed Sep 1, 2023
@saraalemadi
Copy link
Author

Hi,

Thanks @yu-rp, the above solution resolved this error. However, I am getting the error below now, although I tried to resolve the issue of the dataset path by changing the path wherever it was called to where the dataset is located in my directory. However, for some reason "/home/yurunpeng" is still appended to the dataset path. Kindly let me know how to resolve this issue.

Thanks.

Regards,
Sara A. Al-Emadi

...
loaded samples [('/home/yurunpeng/Data/PACSm/art_painting/dog/pic_168.jpg', 0), ('/home/yurunpeng/Data/PACSm/art_painting/elephant/pic_133.jpg', 1), ('/home/yurunpeng/Data/PACSm/art_painting/horse/pic_059.jpg', 4), ('/home/yurunpeng/Data/PACSm/art_painting/house/pic_071.jpg', 5), ('/home/yurunpeng/Data/PACSm/art_painting/house/pic_195.jpg', 5)]
base modified samples [('/~/yurunpeng/Data/PACSm/art_painting/dog/pic_168.jpg', 0), ('/~/yurunpeng/Data/PACSm/art_painting/elephant/pic_133.jpg', 1), ('/~/yurunpeng/Data/PACSm/art_painting/horse/pic_059.jpg', 4), ('/~/yurunpeng/Data/PACSm/art_painting/house/pic_071.jpg', 5), ('/~/yurunpeng/Data/PACSm/art_painting/house/pic_195.jpg', 5)]
shuffled index exists at /DSI/Data/shuffled_samples/PACS_0.pt and loaded
Traceback (most recent call last):
  File "scripts/augment.py", line 445, in <module>
    main()
  File "scripts/augment.py", line 373, in main
    for e, xy_dict in enumerate(dataloader):
  File "anaconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 681, in __next__
    data = self._next_data()
  File "anaconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1376, in _next_data
    return self._process_data(data)
  File "anaconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1402, in _process_data
    data.reraise()
  File "/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/_utils.py", line 461, in reraise
    raise exception
FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "anaconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
    data = fetcher.fetch(index)
  File "anaconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "anaconda3/envs/ldm/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "DSI/DiffusionModel/stable-diffusion-main/ldm/data/datasets.py", line 133, in __getitem__
    x,y = self.dataset[index]
  File "anaconda3/envs/ldm/lib/python3.8/site-packages/torchvision/datasets/folder.py", line 230, in __getitem__
    sample = self.loader(path)
  File "anaconda3/envs/ldm/lib/python3.8/site-packages/torchvision/datasets/folder.py", line 269, in default_loader
    return pil_loader(path)
  File "anaconda3/envs/ldm/lib/python3.8/site-packages/torchvision/datasets/folder.py", line 247, in pil_loader
    with open(path, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/~/yurunpeng/Data/PACSm/art_painting/dog/pic_168.jpg'

@yu-rp
Copy link
Owner

yu-rp commented Sep 5, 2023

Hi @saraalemadi ,

Thank you for pointing out this issue. We have removed the path of our server from the code. To adapt to your environment, you may also consider using this function to modify the path.

Could you please let us know whether the new code works for you?

Best

@yu-rp yu-rp reopened this Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants