فهرست منبع

delete paddlehub for download pretrain_weights

FlyingQianMM 5 سال پیش
والد
کامیت
404d3965f5
2فایلهای تغییر یافته به همراه47 افزوده شده و 47 حذف شده
  1. 46 46
      paddlex/cv/models/utils/pretrain_weights.py
  2. 1 1
      setup.py

+ 46 - 46
paddlex/cv/models/utils/pretrain_weights.py

@@ -203,30 +203,30 @@ def get_pretrain_weights(flag, class_name, backbone, save_dir):
             backbone)
 
         #        if backbone == 'AlexNet':
-        #            url = image_pretrain[backbone]
-        #            fname = osp.split(url)[-1].split('.')[0]
-        #            paddlex.utils.download_and_decompress(url, path=new_save_dir)
-        #            return osp.join(new_save_dir, fname)
-        try:
-            logging.info(
-                "Connecting PaddleHub server to get pretrain weights...")
-            hub.download(backbone, save_path=new_save_dir)
-        except Exception as e:
-            logging.error(
-                "Couldn't download pretrain weight, you can download it manualy from {} (decompress the file if it is a compressed file), and set pretrain weights by your self".
-                format(image_pretrain[backbone]),
-                exit=False)
-            if isinstance(e, hub.ResourceNotFoundError):
-                raise Exception("Resource for backbone {} not found".format(
-                    backbone))
-            elif isinstance(e, hub.ServerConnectionError):
-                raise Exception(
-                    "Cannot get reource for backbone {}, please check your internet connection"
-                    .format(backbone))
-            else:
-                raise Exception(
-                    "Unexpected error, please make sure paddlehub >= 1.6.2")
-        return osp.join(new_save_dir, backbone)
+        url = image_pretrain[backbone]
+        fname = osp.split(url)[-1].split('.')[0]
+        paddlex.utils.download_and_decompress(url, path=new_save_dir)
+        return osp.join(new_save_dir, fname)
+        #try:
+        #    logging.info(
+        #        "Connecting PaddleHub server to get pretrain weights...")
+        #    hub.download(backbone, save_path=new_save_dir)
+        #except Exception as e:
+        #    logging.error(
+        #        "Couldn't download pretrain weight, you can download it manualy from {} (decompress the file if it is a compressed file), and set pretrain weights by your self".
+        #        format(image_pretrain[backbone]),
+        #        exit=False)
+        #    if isinstance(e, hub.ResourceNotFoundError):
+        #        raise Exception("Resource for backbone {} not found".format(
+        #            backbone))
+        #    elif isinstance(e, hub.ServerConnectionError):
+        #        raise Exception(
+        #            "Cannot get reource for backbone {}, please check your internet connection"
+        #            .format(backbone))
+        #    else:
+        #        raise Exception(
+        #            "Unexpected error, please make sure paddlehub >= 1.6.2")
+        #return osp.join(new_save_dir, backbone)
     elif flag in ['COCO', 'CITYSCAPES']:
         new_save_dir = save_dir
         if hasattr(paddlex, 'pretrain_dir'):
@@ -241,28 +241,28 @@ def get_pretrain_weights(flag, class_name, backbone, save_dir):
         elif flag == 'CITYSCAPES':
             url = cityscapes_pretrain[backbone]
         fname = osp.split(url)[-1].split('.')[0]
-        #        paddlex.utils.download_and_decompress(url, path=new_save_dir)
-        #        return osp.join(new_save_dir, fname)
-        try:
-            logging.info(
-                "Connecting PaddleHub server to get pretrain weights...")
-            hub.download(backbone, save_path=new_save_dir)
-        except Exception as e:
-            logging.error(
-                "Couldn't download pretrain weight, you can download it manualy from {} (decompress the file if it is a compressed file), and set pretrain weights by your self".
-                format(url),
-                exit=False)
-            if isinstance(hub.ResourceNotFoundError):
-                raise Exception("Resource for backbone {} not found".format(
-                    backbone))
-            elif isinstance(hub.ServerConnectionError):
-                raise Exception(
-                    "Cannot get reource for backbone {}, please check your internet connection"
-                    .format(backbone))
-            else:
-                raise Exception(
-                    "Unexpected error, please make sure paddlehub >= 1.6.2")
-        return osp.join(new_save_dir, backbone)
+        paddlex.utils.download_and_decompress(url, path=new_save_dir)
+        return osp.join(new_save_dir, fname)
+        #try:
+        #    logging.info(
+        #        "Connecting PaddleHub server to get pretrain weights...")
+        #    hub.download(backbone, save_path=new_save_dir)
+        #except Exception as e:
+        #    logging.error(
+        #        "Couldn't download pretrain weight, you can download it manualy from {} (decompress the file if it is a compressed file), and set pretrain weights by your self".
+        #        format(url),
+        #        exit=False)
+        #    if isinstance(hub.ResourceNotFoundError):
+        #        raise Exception("Resource for backbone {} not found".format(
+        #            backbone))
+        #    elif isinstance(hub.ServerConnectionError):
+        #        raise Exception(
+        #            "Cannot get reource for backbone {}, please check your internet connection"
+        #            .format(backbone))
+        #    else:
+        #        raise Exception(
+        #            "Unexpected error, please make sure paddlehub >= 1.6.2")
+        #return osp.join(new_save_dir, backbone)
     else:
         logging.error("Path of retrain weights '{}' is not exists!".format(
             flag))

+ 1 - 1
setup.py

@@ -30,7 +30,7 @@ setuptools.setup(
     setup_requires=['cython', 'numpy'],
     install_requires=[
         "pycocotools;platform_system!='Windows'", 'pyyaml', 'colorama', 'tqdm',
-        'paddleslim==1.1.1', 'visualdl>=2.0.0', 'paddlehub>=1.8.2',
+        'paddleslim==1.0.1', 'visualdl>=2.0.0', 'paddlehub>=1.8.2',
         'shapely>=1.7.0', "opencv-python"
     ],
     classifiers=[