You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Motivation
I think there is some redundancy in the get_img member function of the BaseDataSource. Related resources
In mmselfsup/datasets/data_sources/base.py. The get_img function of class BaseDataSource:
def get_img(self, idx):
if self.file_client is None:
self.file_client = mmcv.FileClient(**self.file_client_args)
if 'ImageNet-21k' in self.data_prefix:
filename = osp.join(self.data_prefix,
self.data_infos[idx].decode('utf-8'))
img_bytes = self.file_client.get(filename)
img = mmcv.imfrombytes(
img_bytes,
flag=self.color_type,
channel_order=self.channel_order)
elif self.data_infos[idx].get('img_prefix', None) is not None:
if self.data_infos[idx]['img_prefix'] is not None:
filename = osp.join(
self.data_infos[idx]['img_prefix'],
self.data_infos[idx]['img_info']['filename'])
else:
filename = self.data_infos[idx]['img_info']['filename']
img_bytes = self.file_client.get(filename)
img = mmcv.imfrombytes(
img_bytes,
flag=self.color_type,
channel_order=self.channel_order)
else:
img = self.data_infos[idx]['img']
img_bytes = self.file_client.get(filename)
img = mmcv.imfrombytes(
img_bytes, flag=self.color_type, channel_order=self.channel_order)
img = img.astype(np.uint8)
return Image.fromarray(img)
The filename variable may be not set on the if-else logic. So This may cause error in processing img_bytes = self.file_client.get(filename)
The img_bytes and img set twice when if-elif logic occur.
Additional context
I'm trying to implement a custom dataset without annotated data, and when I read the source code I had some questions here. If there is another reason for this design, please let me know.
Many thanks!
The text was updated successfully, but these errors were encountered:
Describe the feature
Motivation
I think there is some redundancy in the
get_img
member function of theBaseDataSource.
Related resources
In mmselfsup/datasets/data_sources/base.py. The
get_img
function of classBaseDataSource
:filename
variable may be not set on the if-else logic. So This may cause error in processingimg_bytes = self.file_client.get(filename)
img_bytes
andimg
set twice when if-elif logic occur.Additional context
I'm trying to implement a custom dataset without annotated data, and when I read the source code I had some questions here. If there is another reason for this design, please let me know.
Many thanks!
The text was updated successfully, but these errors were encountered: