Open HoTuanLong opened 1 year ago
Could you copy-paste the complete error message?
Of course, this is the output of my issue. Please keep in mind that the labels' names have been changed from PACS to 0123, respectively.
=============Global iter is 0 =============== Traceback (most recent call last): File "/home/ubuntu/long.ht/CCST/federated/fed_run.py", line 703, in
result = future.result() File "/home/ubuntu/miniconda3/envs/ccst/lib/python3.10/concurrent/futures/_base.py", line 451, in result return self.get_result() File "/home/ubuntu/miniconda3/envs/ccst/lib/python3.10/concurrent/futures/_base.py", line 403, in get_result raise self._exception File "/home/ubuntu/miniconda3/envs/ccst/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/home/ubuntu/long.ht/CCST/federated/fed_run.py", line 487, in process_client train_loss, train_acc = train_meta(models[client_idx], train_loaders[client_idx], optimizers[client_idx], loss_fun, client_num, device_client, args, iter_idx, logger) File "/home/ubuntu/long.ht/CCST/federated/fed_run.py", line 100, in train_meta for it, data in enumerate(train_loader): File "/home/ubuntu/miniconda3/envs/ccst/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 628, in next data = self._next_data() File "/home/ubuntu/miniconda3/envs/ccst/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 671, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/home/ubuntu/miniconda3/envs/ccst/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 58, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/ubuntu/miniconda3/envs/ccst/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 58, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/ubuntu/long.ht/CCST/data/ImageLoader.py", line 317, in getitem tar_freq = self.amp_loader.get_amp() File "/home/ubuntu/long.ht/CCST/data/ImageLoader.py", line 238, in get_amp tar_freq = np.load(os.path.join(tar_freq_path)) File "/home/ubuntu/miniconda3/envs/ccst/lib/python3.10/site-packages/numpy/lib/npyio.py", line 405, in load fid = stack.enter_context(open(os_fspath(file), "rb")) FileNotFoundError: [Errno 2] No such file or directory: '/home/ubuntu/long.ht/CCST/datasets/PACS/1/fit/0/pic_006.npy
In addition, my data structure will be like this:
Sorry for getting back late for you. This is the pre-computed FFT amplitude of the images for the FedDG method. You can refer to the Official FedDG Repo to see how to compute the amplitude.
Thank you for your reply.
But maybe the prepare_dataset.py
in the FedDG repo has not been completed. How do you generate the .npy file? Could you share your source or guide me to compute, please?
The following is their prepare_dataset.py
, im_trg
is not defined and where is amp
will be used?
def extract_amp_spectrum(img_np):
# trg_img is of dimention CxHxW (C = 3 for RGB image and 1 for slice)
fft = np.fft.fft2( img_np, axes=(-2, -1) )
amp_np, pha_np = np.abs(fft), np.angle(fft)
return amp_sample
for client_idx in range(client_number):
for data_idx, each_data_path in enumerate(client_data_list[client_idx]):
img = Image.open(each_data_path)
img = img.resize( (384,384), Image.BICUBIC )
img_np = np.asarray(im_trg)
amp = extract_amp_spectrum(img_np)
np.save('./client{}/freq_amp_npy/amp_sample{}'.fprmat(client_idx, data_idx))
I am attempting to run feddg using the following command:
python fed_run.py --mode fedavg --dg_method 'feddg' --source art_painting cartoon sketch --target photo --log
Unfortunately, I have encountered an error which states that there are missing files called
img_{sample_name}.npy
. I was wondering if you could kindly provide me with instructions on how to create the npy file for the data and assist me in resolving this issue.