clovaai/lffont

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (27, 2) + inhomogeneous part.

KangyueXiong opened this issue · 4 comments

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (27, 2) + inhomogeneous part.

Original Traceback (most recent call last):
File "/home/zeng/.conda/envs/xky/lib/python3.9/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/zeng/.conda/envs/xky/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 58, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/zeng/.conda/envs/xky/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 58, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/zeng/xky1/lffont-master/datasets/p1dataset.py", line 113, in getitem
trg_unis, trg_comp_ids = self.check_and_sample(trg_unis, trg_comp_ids)
File "/home/zeng/xky1/lffont-master/datasets/p1dataset.py", line 97, in check_and_sample
uni_comps = sample(uni_comps, self.n_sample_max)
File "/home/zeng/xky1/lffont-master/datasets/datautils.py", line 45, in sample
population = np.asarray(list(population))
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (23, 2) + inhomogeneous part.

8uos commented

Hi, I guess that the error is caused by mismatching python/numpy version.
It can solved by adding dtype="object" to line 45 of datautils.py.
Modifying population = np.asarray(list(population)) to population = np.asarray(list(population), dtype="object) will help you.

I get the picture. Thank you

Closing the issue, assuming the answer resolves the problem.
Please re-open the issue as necessary.