rrjia opened a new issue #18262:
URL: https://github.com/apache/incubator-mxnet/issues/18262


   ## Description
   mxnet dataLoader error 
   I defined myself dataset, it work fine , but combine with 
gluon.data.dataLoader it can not work. 
   
   
   class MarketDataset(dataset.Dataset):
       def __init__(self, name, data_root_path, transform=None):
           self.data_dir = data_root_path
           self.name = name
           self.imgs = []
           self._transform = transform
           if self.name == "train":
               sub_dir = os.path.join(self.data_dir, "bounding_box_train")
           elif self.name == 'test':
               sub_dir = os.path.join(self.data_dir, "bounding_box_test")
           elif self.name == 'query':
               sub_dir = os.path.join(self.data_dir, "query")
           else:
               print("name error !! ")
               raise NotImplementedError('Dataset: {} not 
exist.'.format(self.name))
   
           file_names = os.listdir(sub_dir)
           for file_name in file_names:
               if ".jpg" in file_name and "-1" not in file_name:
                   file_path = os.path.join(sub_dir, file_name)
                   self.imgs.append(file_path)       
           self._id2label = {_id: index for index, _id in 
enumerate(self.unique_ids)}
   
       def __getitem__(self, idx):
           path = self.imgs[idx]
           target = self._id2label[self.id(path)]
   
           img = image.imread(path)
           if self.transform is not None:
               img = self.transform(img)
   
           return img, target
   
       def __len__(self):
           return len(self.imgs)
   
       @staticmethod
       def id(file_path):
           """
           :param file_path: unix style file path
           :return: person id
           """
           return int(os.path.split(file_path)[-1].split("_")[0])
   
       @staticmethod
       def camera(file_path):
           """
           :param file_path: unix style file path
           :return: camera id
           """
           return int(os.path.split(file_path)[-1].split("_")[1][1])
   
       @property
       def ids(self):
           """
           :return: person id list corresponding to dataset image paths
           """
           return [self.id(path) for path in self.imgs]
   
       @property
       def unique_ids(self):
           """
           :return: unique person ids in ascending order
           """
           return sorted(set(self.ids))
   
       @property
       def cameras(self):
           """
           :return: camera id list corresponding to dataset image paths
           """
           return [self.camera(path) for path in self.imgs]
   
   
   
   
   ### Error Message
     File 
"D:\programFiles\Anaconda3\lib\site-packages\mxnet\gluon\data\dataloader.py", 
line 451, in __next__
       batch = pickle.loads(ret.get()) if self._dataset is None else ret.get()
     File "D:\programFiles\Anaconda3\lib\multiprocessing\pool.py", line 670, in 
get
       raise self._value
     File "D:\programFiles\Anaconda3\lib\multiprocessing\pool.py", line 119, in 
worker
       result = (True, func(*args, **kwds))
     File 
"D:\programFiles\Anaconda3\lib\site-packages\mxnet\gluon\data\dataloader.py", 
line 407, in _thread_worker_fn
       return batchify_fn([dataset[i] for i in samples])
     File 
"D:\programFiles\Anaconda3\lib\site-packages\mxnet\gluon\data\dataloader.py", 
line 147, in default_mp_batchify_fn
       return [default_mp_batchify_fn(i) for i in data]
     File 
"D:\programFiles\Anaconda3\lib\site-packages\mxnet\gluon\data\dataloader.py", 
line 147, in <listcomp>
       return [default_mp_batchify_fn(i) for i in data]
     File 
"D:\programFiles\Anaconda3\lib\site-packages\mxnet\gluon\data\dataloader.py", 
line 149, in default_mp_batchify_fn
       data = np.asarray(data)
     File "D:\programFiles\Anaconda3\lib\site-packages\numpy\core\_asarray.py", 
line 85, in asarray
       return array(a, dtype, copy=False, order=order)
     File 
"D:\programFiles\Anaconda3\lib\site-packages\mxnet\gluon\data\dataset.py", line 
124, in __getitem__
       return self._fn(*item)
   TypeError: 'NDArray' object is not callable
   ## To Reproduce
   (If you developed your own code, please provide a short script that 
reproduces the error. For existing examples, please provide link.)
   
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to