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
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):
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
import torch
from torch.utils.model_zoo import tqdm
from ._utils import (
from .._internally_replaced_utils import (
_download_file_from_remote_location,
_is_remote_location_available,
)
......
import torch
from ._register_extension import _get_extension_path
from ._internally_replaced_utils import _get_extension_path
_HAS_OPS = False
......
......@@ -8,7 +8,7 @@ from typing import List, Tuple
import numpy as np
import torch
from .._register_extension import _get_extension_path
from .._internally_replaced_utils import _get_extension_path
try:
......
import torch
from enum import Enum
from .._register_extension import _get_extension_path
from .._internally_replaced_utils import _get_extension_path
try:
......
import torch
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
......
......@@ -4,7 +4,7 @@ import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as cp
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 typing import Any, List, Tuple
......
......@@ -4,7 +4,7 @@ import torch.nn.functional as F
from torchvision.ops import MultiScaleRoIAlign
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 .generalized_rcnn import GeneralizedRCNN
......
......@@ -4,7 +4,7 @@ from torch import nn
from torchvision.ops import MultiScaleRoIAlign
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 .backbone_utils import resnet_fpn_backbone, _validate_trainable_layers
......
......@@ -5,7 +5,7 @@ from torch import nn
from torchvision.ops import MultiScaleRoIAlign
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 .backbone_utils import resnet_fpn_backbone, _validate_trainable_layers
......
......@@ -7,7 +7,7 @@ from torch import nn, Tensor
from typing import Dict, List, Tuple, Optional
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 .anchor_utils import AnchorGenerator
......
......@@ -11,7 +11,7 @@ from .anchor_utils import DefaultBoxGenerator
from .backbone_utils import _validate_trainable_layers
from .transform import GeneralizedRCNNTransform
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
__all__ = ['SSD', 'ssd300_vgg16']
......
......@@ -12,7 +12,7 @@ from .anchor_utils import DefaultBoxGenerator
from .backbone_utils import _validate_trainable_layers
from .. import mobilenet
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']
......
......@@ -4,7 +4,7 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
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
__all__ = ['GoogLeNet', 'googlenet', "GoogLeNetOutputs", "_GoogLeNetOutputs"]
......
......@@ -3,7 +3,7 @@ import warnings
import torch
from torch import nn, Tensor
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
......
......@@ -3,7 +3,7 @@ import warnings
import torch
from torch import Tensor
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
__all__ = ['MNASNet', 'mnasnet0_5', 'mnasnet0_75', 'mnasnet1_0', 'mnasnet1_3']
......
import torch
from torch import nn
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
......
......@@ -5,7 +5,7 @@ from torch import nn, Tensor
from torch.nn import functional as F
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
......
......@@ -3,7 +3,7 @@ import torch
import torch.nn as nn
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 (
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