"vscode:/vscode.git/clone" did not exist on "4b3458f70afd4e5fb22ecbbee41577a2e352cfd9"
Unverified Commit 183a7221 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

[FBcode->GH] Group all internally replaced utils into a single file (#4095)

parent d391a0e9
...@@ -2,6 +2,20 @@ import os ...@@ -2,6 +2,20 @@ import os
import importlib.machinery import importlib.machinery
def _download_file_from_remote_location(fpath: str, url: str) -> None:
pass
def _is_remote_location_available() -> bool:
return False
try:
from torch.hub import load_state_dict_from_url
except ImportError:
from torch.utils.model_zoo import load_url as load_state_dict_from_url
def _get_extension_path(lib_name): def _get_extension_path(lib_name):
lib_dir = os.path.dirname(__file__) lib_dir = os.path.dirname(__file__)
......
def _download_file_from_remote_location(fpath: str, url: str) -> None:
pass
def _is_remote_location_available() -> bool:
return False
...@@ -17,7 +17,7 @@ import pathlib ...@@ -17,7 +17,7 @@ import pathlib
import torch import torch
from torch.utils.model_zoo import tqdm from torch.utils.model_zoo import tqdm
from ._utils import ( from .._internally_replaced_utils import (
_download_file_from_remote_location, _download_file_from_remote_location,
_is_remote_location_available, _is_remote_location_available,
) )
......
import torch import torch
from ._register_extension import _get_extension_path from ._internally_replaced_utils import _get_extension_path
_HAS_OPS = False _HAS_OPS = False
......
...@@ -8,7 +8,7 @@ from typing import List, Tuple ...@@ -8,7 +8,7 @@ from typing import List, Tuple
import numpy as np import numpy as np
import torch import torch
from .._register_extension import _get_extension_path from .._internally_replaced_utils import _get_extension_path
try: try:
......
import torch import torch
from enum import Enum from enum import Enum
from .._register_extension import _get_extension_path from .._internally_replaced_utils import _get_extension_path
try: try:
......
import torch import torch
import torch.nn as nn import torch.nn as nn
from .utils import load_state_dict_from_url from .._internally_replaced_utils import load_state_dict_from_url
from typing import Any from typing import Any
......
...@@ -4,7 +4,7 @@ import torch.nn as nn ...@@ -4,7 +4,7 @@ import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
import torch.utils.checkpoint as cp import torch.utils.checkpoint as cp
from collections import OrderedDict from collections import OrderedDict
from .utils import load_state_dict_from_url from .._internally_replaced_utils import load_state_dict_from_url
from torch import Tensor from torch import Tensor
from typing import Any, List, Tuple from typing import Any, List, Tuple
......
...@@ -4,7 +4,7 @@ import torch.nn.functional as F ...@@ -4,7 +4,7 @@ import torch.nn.functional as F
from torchvision.ops import MultiScaleRoIAlign from torchvision.ops import MultiScaleRoIAlign
from ._utils import overwrite_eps from ._utils import overwrite_eps
from ..utils import load_state_dict_from_url from ..._internally_replaced_utils import load_state_dict_from_url
from .anchor_utils import AnchorGenerator from .anchor_utils import AnchorGenerator
from .generalized_rcnn import GeneralizedRCNN from .generalized_rcnn import GeneralizedRCNN
......
...@@ -4,7 +4,7 @@ from torch import nn ...@@ -4,7 +4,7 @@ from torch import nn
from torchvision.ops import MultiScaleRoIAlign from torchvision.ops import MultiScaleRoIAlign
from ._utils import overwrite_eps from ._utils import overwrite_eps
from ..utils import load_state_dict_from_url from ..._internally_replaced_utils import load_state_dict_from_url
from .faster_rcnn import FasterRCNN from .faster_rcnn import FasterRCNN
from .backbone_utils import resnet_fpn_backbone, _validate_trainable_layers from .backbone_utils import resnet_fpn_backbone, _validate_trainable_layers
......
...@@ -5,7 +5,7 @@ from torch import nn ...@@ -5,7 +5,7 @@ from torch import nn
from torchvision.ops import MultiScaleRoIAlign from torchvision.ops import MultiScaleRoIAlign
from ._utils import overwrite_eps from ._utils import overwrite_eps
from ..utils import load_state_dict_from_url from ..._internally_replaced_utils import load_state_dict_from_url
from .faster_rcnn import FasterRCNN from .faster_rcnn import FasterRCNN
from .backbone_utils import resnet_fpn_backbone, _validate_trainable_layers from .backbone_utils import resnet_fpn_backbone, _validate_trainable_layers
......
...@@ -7,7 +7,7 @@ from torch import nn, Tensor ...@@ -7,7 +7,7 @@ from torch import nn, Tensor
from typing import Dict, List, Tuple, Optional from typing import Dict, List, Tuple, Optional
from ._utils import overwrite_eps from ._utils import overwrite_eps
from ..utils import load_state_dict_from_url from ..._internally_replaced_utils import load_state_dict_from_url
from . import _utils as det_utils from . import _utils as det_utils
from .anchor_utils import AnchorGenerator from .anchor_utils import AnchorGenerator
......
...@@ -11,7 +11,7 @@ from .anchor_utils import DefaultBoxGenerator ...@@ -11,7 +11,7 @@ from .anchor_utils import DefaultBoxGenerator
from .backbone_utils import _validate_trainable_layers from .backbone_utils import _validate_trainable_layers
from .transform import GeneralizedRCNNTransform from .transform import GeneralizedRCNNTransform
from .. import vgg from .. import vgg
from ..utils import load_state_dict_from_url from ..._internally_replaced_utils import load_state_dict_from_url
from ...ops import boxes as box_ops from ...ops import boxes as box_ops
__all__ = ['SSD', 'ssd300_vgg16'] __all__ = ['SSD', 'ssd300_vgg16']
......
...@@ -12,7 +12,7 @@ from .anchor_utils import DefaultBoxGenerator ...@@ -12,7 +12,7 @@ from .anchor_utils import DefaultBoxGenerator
from .backbone_utils import _validate_trainable_layers from .backbone_utils import _validate_trainable_layers
from .. import mobilenet from .. import mobilenet
from ..mobilenetv3 import ConvBNActivation from ..mobilenetv3 import ConvBNActivation
from ..utils import load_state_dict_from_url from ..._internally_replaced_utils import load_state_dict_from_url
__all__ = ['ssdlite320_mobilenet_v3_large'] __all__ = ['ssdlite320_mobilenet_v3_large']
......
...@@ -4,7 +4,7 @@ import torch ...@@ -4,7 +4,7 @@ import torch
import torch.nn as nn import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
from torch import Tensor from torch import Tensor
from .utils import load_state_dict_from_url from .._internally_replaced_utils import load_state_dict_from_url
from typing import Optional, Tuple, List, Callable, Any from typing import Optional, Tuple, List, Callable, Any
__all__ = ['GoogLeNet', 'googlenet', "GoogLeNetOutputs", "_GoogLeNetOutputs"] __all__ = ['GoogLeNet', 'googlenet', "GoogLeNetOutputs", "_GoogLeNetOutputs"]
......
...@@ -3,7 +3,7 @@ import warnings ...@@ -3,7 +3,7 @@ import warnings
import torch import torch
from torch import nn, Tensor from torch import nn, Tensor
import torch.nn.functional as F import torch.nn.functional as F
from .utils import load_state_dict_from_url from .._internally_replaced_utils import load_state_dict_from_url
from typing import Callable, Any, Optional, Tuple, List from typing import Callable, Any, Optional, Tuple, List
......
...@@ -3,7 +3,7 @@ import warnings ...@@ -3,7 +3,7 @@ import warnings
import torch import torch
from torch import Tensor from torch import Tensor
import torch.nn as nn import torch.nn as nn
from .utils import load_state_dict_from_url from .._internally_replaced_utils import load_state_dict_from_url
from typing import Any, Dict, List from typing import Any, Dict, List
__all__ = ['MNASNet', 'mnasnet0_5', 'mnasnet0_75', 'mnasnet1_0', 'mnasnet1_3'] __all__ = ['MNASNet', 'mnasnet0_5', 'mnasnet0_75', 'mnasnet1_0', 'mnasnet1_3']
......
import torch import torch
from torch import nn from torch import nn
from torch import Tensor from torch import Tensor
from .utils import load_state_dict_from_url from .._internally_replaced_utils import load_state_dict_from_url
from typing import Callable, Any, Optional, List from typing import Callable, Any, Optional, List
......
...@@ -5,7 +5,7 @@ from torch import nn, Tensor ...@@ -5,7 +5,7 @@ from torch import nn, Tensor
from torch.nn import functional as F from torch.nn import functional as F
from typing import Any, Callable, Dict, List, Optional, Sequence from typing import Any, Callable, Dict, List, Optional, Sequence
from torchvision.models.utils import load_state_dict_from_url from .._internally_replaced_utils import load_state_dict_from_url
from torchvision.models.mobilenetv2 import _make_divisible, ConvBNActivation from torchvision.models.mobilenetv2 import _make_divisible, ConvBNActivation
......
...@@ -3,7 +3,7 @@ import torch ...@@ -3,7 +3,7 @@ import torch
import torch.nn as nn import torch.nn as nn
from torch.nn import functional as F from torch.nn import functional as F
from torchvision.models.utils import load_state_dict_from_url from ..._internally_replaced_utils import load_state_dict_from_url
from torchvision.models.googlenet import ( from torchvision.models.googlenet import (
GoogLeNetOutputs, BasicConv2d, Inception, InceptionAux, GoogLeNet, model_urls) GoogLeNetOutputs, BasicConv2d, Inception, InceptionAux, GoogLeNet, model_urls)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment