diff --git a/paddlehub/compat/module/module_v1.py b/paddlehub/compat/module/module_v1.py index ea2f555a5cc7c496526dfa4ccd14bf83aa0410de..8d856b5c6bd67f9ab54021f4daafdd4cb3d5e3f6 100644 --- a/paddlehub/compat/module/module_v1.py +++ b/paddlehub/compat/module/module_v1.py @@ -180,6 +180,14 @@ class ModuleV1(object): @classmethod def load(cls, directory: str) -> EasyDict: module_info = cls.load_module_info(directory) + + # Generate a uuid based on the class information, and dynamically create a new type. + # If we do not do this, the information generated later will overwrite the information + # previously generated. + cls_uuid = utils.md5(module_info.name + module_info.author + module_info.author_email + module_info.type + + module_info.summary + module_info.version + directory) + cls = type(cls_uuid, (cls, ), {}) + cls.name = module_info.name cls.author = module_info.author cls.author_email = module_info.author_email diff --git a/paddlehub/module/manager.py b/paddlehub/module/manager.py index e59893b076a99611835868908f8fe9e6e2d0bec5..6a66f16c696bc7a7ad511f26e750ef9de6f0db28 100644 --- a/paddlehub/module/manager.py +++ b/paddlehub/module/manager.py @@ -234,7 +234,11 @@ class LocalModuleManager(object): '''List all installed HubModule.''' for subdir in os.listdir(self.home): fulldir = os.path.join(self.home, subdir) - self._local_modules[subdir] = HubModule.load(fulldir) + try: + self._local_modules[subdir] = HubModule.load(fulldir) + except: + log.logger.warning('An error was encountered while loading {}'.format(subdir)) + return [module for module in self._local_modules.values()] def _install_from_url(self, url: str) -> HubModule: