Conversation
2.[feature] stream data evaluation
| data_type = self.data_converter.get_data_type(file_path) | ||
| # organize the input data as the smpl data | ||
| if data_type is SMPLDataTypeEnum.AMASS: | ||
| self.logger.info('Received AMASS data, converting to SMPL(X) data') | ||
| data = self.data_converter.from_amass(file_path) |
There was a problem hiding this comment.
Too many file IO, both get_data_type and from_amass load file from file_path. Something like this will be faster:
...
def get_data_type(self, file: Union[str, io.BytesIO]) -> str:
...
with open(file_path, 'rb') as f:
data_type = self.data_converter.get_data_type(file_path)
....
smpl_data = self.data_converter.from_amass(file_path)| """ | ||
| self.logger = logger | ||
|
|
||
| def get_data_type(self, filepath: str) -> str: |
There was a problem hiding this comment.
get_data_type, from_humandata and from_amass looks more like static methods. Try static class and add this
def __new__(cls):
raise NotImplementedError("SMPLDataConverter cannot be instantiated")
| if gender is None: | ||
| gender = 'neutral' | ||
| self.logger.warning( | ||
| f'Cannot find gender record in {human_data}.meta, ' + |
There was a problem hiding this comment.
I doubt the readability of this log. Can you provide an example from an actual usage where a warning is raised here?
| return SMPLDataTypeEnum.UNKNOWN | ||
|
|
||
| def from_humandata(self, | ||
| filepath: str) -> Optional[Union[SMPLData, SMPLXData]]: |
There was a problem hiding this comment.
| filepath: str) -> Optional[Union[SMPLData, SMPLXData]]: | |
| filepath: str) -> Optional[Union[SMPLData, SMPLXData, None]]: |
|
|
||
| res = SMPLData(gender=gender, logger=self.logger) | ||
| res.from_param_dict(param_dict) | ||
| mask = np.ones((n_frames, ), dtype=np.uint8) |
There was a problem hiding this comment.
| mask = np.ones((n_frames, ), dtype=np.uint8) |
| return res | ||
|
|
||
| def from_amass(self, | ||
| filepath: str) -> Optional[Union[SMPLData, SMPLXData]]: |
There was a problem hiding this comment.
| filepath: str) -> Optional[Union[SMPLData, SMPLXData]]: | |
| filepath: str) -> Optional[Union[SMPLData, SMPLXData, None]]: |
| data.dump(file_path) | ||
| elif data_type is SMPLDataTypeEnum.HUMANDATA: | ||
| self.logger.info('Received HumanData, converting to SMPL(X) data') | ||
| data = self.data_converter.from_humandata(file_path) |
There was a problem hiding this comment.
Easier to find out what type the return value is.
| data = self.data_converter.from_humandata(file_path) | |
| smpl_data = self.data_converter.from_humandata(file_path) |
What if self.data_converter returns None?
| return True | ||
|
|
||
|
|
||
| class SMPLDataConverter: |
There was a problem hiding this comment.
We've already got data converters for dataset, shall we have a different name here?
Add SMPL data converter that: