internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pytorch/vision

Issue:
Document the "scipy" extra
Torchvision's `setup.py` defines a `scipy` extra that pulls in the `scipy` dependency that is needed by some of Torchvision's modules. This lets you use `torchvision[scipy]` as an argument to `pip install`, which is good, since it's a way to explicitly state that you're installing SciPy as a dependency of Torchvision.

However, this extra doesn't seem to be documented anywhere, so it's unclear whether doing `pip install torchvision[scipy]` is officially supported. It would be nice if this was documented in the README or elsewhere.


Discussion:
I agree. We haven't documented scipy (or `pycocotools`) because they are not hard-requirements, and only a few functions of torchvision depends on them.

But it might be good to document that somewhere, maybe in the functions that use them?

Can you send a PR improving the documentation?

Resolving patch:
diff --git a/torchvision/datasets/caltech.py b/torchvision/datasets/caltech.py
--- a/torchvision/datasets/caltech.py
+++ b/torchvision/datasets/caltech.py
@@ -10,6 +10,10 @@
 class Caltech101(VisionDataset):
     """`Caltech 101 <http://www.vision.caltech.edu/Image_Datasets/Caltech101/>`_ Dataset.
 
+    .. warning::
+
+        This class needs `scipy <https://docs.scipy.org/doc/>`_ to load target files from `.mat` format.
+
     Args:
         root (string): Root directory of dataset where directory
             ``caltech101`` exists or will be saved to if download is set to True.
diff --git a/torchvision/datasets/svhn.py b/torchvision/datasets/svhn.py
--- a/torchvision/datasets/svhn.py
+++ b/torchvision/datasets/svhn.py
@@ -13,6 +13,10 @@ class SVHN(VisionDataset):
     we assign the label `0` to the digit `0` to be compatible with PyTorch loss functions which
     expect the class labels to be in the range `[0, C-1]`
 
+    .. warning::
+
+        This class needs `scipy <https://docs.scipy.org/doc/>`_ to load data from `.mat` format.
+
     Args:
         root (string): Root directory of dataset where directory
             ``SVHN`` exists.
diff --git a/torchvision/models/googlenet.py b/torchvision/models/googlenet.py
--- a/torchvision/models/googlenet.py
+++ b/torchvision/models/googlenet.py
@@ -103,7 +103,7 @@ def __init__(self, num_classes=1000, aux_logits=True, transform_input=False, ini
         else:
             self.aux1 = None
             self.aux2 = None
-            
+
         self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
         self.dropout = nn.Dropout(0.2)
         self.fc = nn.Linear(1024, num_classes)


Test patch:
Repository: pytorch/vision

Issue:
DeprecationWarning of imp
Hi, I got the following DeprecationWarning. [`imp`](https://docs.python.org/3/library/imp.html) is now deprecated and is recommended to move to `importlib` instead.

```
 /home/xxx/.miniconda/lib/python3.7/site-packages/torchvision/io/video.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp
```
DeprecationWarning of imp
Hi, I got the following DeprecationWarning. [`imp`](https://docs.python.org/3/library/imp.html) is now deprecated and is recommended to move to `importlib` instead.

```
 /home/xxx/.miniconda/lib/python3.7/site-packages/torchvision/io/video.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp
```


Discussion:
Thanks for opening the issue!

We can change it to `importlib`, but probably after Jan 2020, when we will be dropping support for Python 2.

PRs welcome!
I understand. Thanks.
Let's keep the issue open, as this is something that we will be doing anyway very soon
Thanks for opening the issue!

We can change it to `importlib`, but probably after Jan 2020, when we will be dropping support for Python 2.

PRs welcome!
I understand. Thanks.
Let's keep the issue open, as this is something that we will be doing anyway very soon

Resolving patch:
diff --git a/torchvision/extension.py b/torchvision/extension.py
--- a/torchvision/extension.py
+++ b/torchvision/extension.py
@@ -3,13 +3,21 @@
 
 def _register_extensions():
     import os
-    import imp
+    import importlib
     import torch
 
     # load the custom_op_library and register the custom ops
     lib_dir = os.path.dirname(__file__)
-    _, path, _ = imp.find_module("_C", [lib_dir])
-    torch.ops.load_library(path)
+    loader_details = (
+        importlib.machinery.ExtensionFileLoader,
+        importlib.machinery.EXTENSION_SUFFIXES
+    )
+
+    extfinder = importlib.machinery.FileFinder(lib_dir, loader_details)
+    ext_specs = extfinder.find_spec("_C")
+    if ext_specs is None:
+        raise ImportError
+    torch.ops.load_library(ext_specs.origin)
 
 
 try:
diff --git a/torchvision/io/_video_opt.py b/torchvision/io/_video_opt.py
--- a/torchvision/io/_video_opt.py
+++ b/torchvision/io/_video_opt.py
@@ -1,5 +1,5 @@
 
-import imp
+import importlib
 import math
 import os
 import warnings
@@ -14,9 +14,17 @@
 
 try:
     lib_dir = os.path.join(os.path.dirname(__file__), "..")
-    _, path, description = imp.find_module("video_reader", [lib_dir])
-    torch.ops.load_library(path)
-    _HAS_VIDEO_OPT = True
+
+    loader_details = (
+        importlib.machinery.ExtensionFileLoader,
+        importlib.machinery.EXTENSION_SUFFIXES
+    )
+
+    extfinder = importlib.machinery.FileFinder(lib_dir, loader_details)
+    ext_specs = extfinder.find_spec("video_reader")
+    if ext_specs is not None:
+        torch.ops.load_library(ext_specs.origin)
+        _HAS_VIDEO_OPT = True
 except (ImportError, OSError):
     pass
 


Test patch:
Repository: pytorch/vision

Issue:
pretrain models for FCN and DeepLabV3
Is it possible to provide the pretrain weight for deeplabv3 and FCN?
right now when i do:
`model = torchvision.models.segmentation.fcn_resnet50(pretrained=True)`
I receive this:

> NotImplementedError: pretrained fcn_resnet50_coco is not supported as of now


Discussion:
Hi,

We do provide pre-trained weights, but for now only for ResNet 101 backbone.

Could you try that one instead?
@fmassa 
Thanks for your reply.
I tried it. Resnet101 works fine, however, I cannot use it due to memory limitation.
Do you think that it would be possible to provide the weights for resnet 50 as well?
I could look into it after ECCV deadline, but I won't have bandwidth before that unfortunately :-/
I understand. Thank you @fmassa 
@fmassa Just a gentle reminder regarding the pre-trained models for FCN50   :)
@isalirezag, if you are, like me, using a 4GB card and cannot start training because indeed calculating the gradients for the whole network is too much, you can train only the classifier part or the last layers of the backbone, that will work with 4GB. 
@mthrok could you have a look into this?
I just launched the trainings for both `fcn_resnet50` and `deeplabv3_resnet50`.
Let's keep the issue open until the new models are uploaded to torchvision
We got the following result;


| Model  | Mean IoU | Global Accuracy |
| ------------- | ------------- | ------------- |
| fcn_resnet50  | 60.5  | 91.4 |
| deeplabv3_resnet50  | 66.4 | 92.4 |

We are preparing for the model release.


Resolving patch:
diff --git a/torchvision/models/segmentation/segmentation.py b/torchvision/models/segmentation/segmentation.py
--- a/torchvision/models/segmentation/segmentation.py
+++ b/torchvision/models/segmentation/segmentation.py
@@ -9,9 +9,9 @@
 
 
 model_urls = {
-    'fcn_resnet50_coco': None,
+    'fcn_resnet50_coco': 'https://download.pytorch.org/models/fcn_resnet50_coco-1167a1af.pth',
     'fcn_resnet101_coco': 'https://download.pytorch.org/models/fcn_resnet101_coco-7ecb50ca.pth',
-    'deeplabv3_resnet50_coco': None,
+    'deeplabv3_resnet50_coco': 'https://download.pytorch.org/models/deeplabv3_resnet50_coco-cd0a2569.pth',
     'deeplabv3_resnet101_coco': 'https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth',
 }
 


Test patch:
diff --git a/test/test_models.py b/test/test_models.py
--- a/test/test_models.py
+++ b/test/test_models.py
@@ -42,9 +42,11 @@ def get_available_video_models():
 # before they are compared to the eager model outputs. This is useful if the
 # model outputs are different between TorchScript / Eager mode
 script_test_models = {
+    'deeplabv3_resnet50': {},
     'deeplabv3_resnet101': {},
     'mobilenet_v2': {},
     'resnext50_32x4d': {},
+    'fcn_resnet50': {},
     'fcn_resnet101': {},
     'googlenet': {
         'unwrapper': lambda x: x.logits
Repository: pytorch/vision

Issue:
Failed to download CelebA in Colab
## 🐛 Bug

It fails to download the following files **img_align_celeba.zip**

## To Reproduce

Steps to reproduce the behavior:

1. `from torchvision import datasets`
`trainset = datasets.CelebA(root='./data/', split='train', target_type="attr", transform=transform, download=True)`

Error:
```
Traceback (most recent call last):
  File "transfer_learning.py", line 123, in <module>
    trainset = datasets.CelebA(root='./data/', split='train', transform=transform, download=True)
  File "/usr/local/lib/python3.6/dist-packages/torchvision/datasets/celeba.py", line 66, in __init__
    self.download()
  File "/usr/local/lib/python3.6/dist-packages/torchvision/datasets/celeba.py", line 120, in download
    with zipfile.ZipFile(os.path.join(self.root, self.base_folder, "img_align_celeba.zip"), "r") as f:
  File "/usr/lib/python3.6/zipfile.py", line 1131, in __init__
    self._RealGetContents()
  File "/usr/lib/python3.6/zipfile.py", line 1198, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
```

## Expected behavior

## Environment

```
PyTorch version: 1.5.0+cu101
Is debug build: No
CUDA used to build PyTorch: 10.1

OS: Ubuntu 18.04.3 LTS
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
CMake version: version 3.12.0

Python version: 3.6
Is CUDA available: No
CUDA runtime version: 10.1.243
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5

Versions of relevant libraries:
[pip3] numpy==1.18.5
[pip3] torch==1.5.0+cu101
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.3.1
[pip3] torchvision==0.6.0+cu101
[conda] Could not collect
```

## Additional context

<!-- Add any other context about the problem here. -->



Discussion:
Duplicate of #1920. @fmassa I'm on it.

Resolving patch:
diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py
--- a/torchvision/datasets/utils.py
+++ b/torchvision/datasets/utils.py
@@ -118,6 +118,10 @@ def list_files(root, suffix, prefix=False):
     return files
 
 
+def _quota_exceeded(response: "requests.models.Response") -> bool:
+    return "Google Drive - Quota exceeded" in response.text
+
+
 def download_file_from_google_drive(file_id, root, filename=None, md5=None):
     """Download a Google Drive file from  and place it in root.
 
@@ -150,6 +154,14 @@ def download_file_from_google_drive(file_id, root, filename=None, md5=None):
             params = {'id': file_id, 'confirm': token}
             response = session.get(url, params=params, stream=True)
 
+        if _quota_exceeded(response):
+            msg = (
+                f"The daily quota of the file {filename} is exceeded and it "
+                f"can't be downloaded. This is a limitation of Google Drive "
+                f"and can only be overcome by trying again later."
+            )
+            raise RuntimeError(msg)
+
         _save_response_content(response, fpath)
 
 


Test patch:
Repository: pytorch/vision

Issue:
Resize sometimes fails
https://github.com/pytorch/vision/blob/300ef76d3b6e9c33c58cd124e5f5514a927cadf1/torchvision/transforms/functional_tensor.py#L589

The specific line above will sometimes cause the image to be returned unresized with no warning even when an explicit size (h,w) is given. This will also cause problems to the transform `RandomResizedCrop`.


Discussion:

Resolving patch:
diff --git a/torchvision/transforms/functional_tensor.py b/torchvision/transforms/functional_tensor.py
--- a/torchvision/transforms/functional_tensor.py
+++ b/torchvision/transforms/functional_tensor.py
@@ -586,8 +586,8 @@ def resize(img: Tensor, size: List[int], interpolation: int = 2) -> Tensor:
         else:
             size_w = int(size_h * w / h)
 
-    if (w <= h and w == size_w) or (h <= w and h == size_h):
-        return img
+        if (w <= h and w == size_w) or (h <= w and h == size_h):
+            return img
 
     # make image NCHW
     need_squeeze = False


Test patch:
diff --git a/test/test_functional_tensor.py b/test/test_functional_tensor.py
--- a/test/test_functional_tensor.py
+++ b/test/test_functional_tensor.py
@@ -337,7 +337,7 @@ def test_resize(self):
             if dt is not None:
                 # This is a trivial cast to float of uint8 data to test all cases
                 tensor = tensor.to(dt)
-            for size in [32, [32, ], [32, 32], (32, 32), ]:
+            for size in [32, 26, [32, ], [32, 32], (32, 32), [26, 35]]:
                 for interpolation in [BILINEAR, BICUBIC, NEAREST]:
                     resized_tensor = F_t.resize(tensor, size=size, interpolation=interpolation)
                     resized_pil_img = F_pil.resize(pil_img, size=size, interpolation=interpolation)
diff --git a/test/test_transforms_tensor.py b/test/test_transforms_tensor.py
--- a/test/test_transforms_tensor.py
+++ b/test/test_transforms_tensor.py
@@ -226,7 +226,7 @@ def test_resize(self):
             if dt is not None:
                 # This is a trivial cast to float of uint8 data to test all cases
                 tensor = tensor.to(dt)
-            for size in [32, [32, ], [32, 32], (32, 32), ]:
+            for size in [32, 34, [32, ], [32, 32], (32, 32), [34, 35]]:
                 for interpolation in [BILINEAR, BICUBIC, NEAREST]:
 
                     resized_tensor = F.resize(tensor, size=size, interpolation=interpolation)
@@ -250,7 +250,7 @@ def test_resized_crop(self):
 
         for scale in [(0.7, 1.2), [0.7, 1.2]]:
             for ratio in [(0.75, 1.333), [0.75, 1.333]]:
-                for size in [(32, ), [32, ], [32, 32], (32, 32)]:
+                for size in [(32, ), [44, ], [32, ], [32, 32], (32, 32), [44, 55]]:
                     for interpolation in [NEAREST, BILINEAR, BICUBIC]:
                         transform = T.RandomResizedCrop(
                             size=size, scale=scale, ratio=ratio, interpolation=interpolation
Repository: pytorch/vision

Issue:
Root directory of Fashion MNIST
## 📚 Documentation

Hi there,

The [docs of FashionMNIST ](https://pytorch.org/docs/stable/torchvision/datasets.html#torchvision.datasets.FashionMNIST) dataset says:

**root** (_string_) – Root directory of dataset where `Fashion-MNIST/processed/training.pt` and `Fashion-MNIST/processed/test.pt` exist.

It should instead be:

**root** (_string_) – Root directory of dataset where `FashionMNIST/processed/training.pt` and `FashionMNIST/processed/test.pt` exist.

since when I manually place `processed/training.pt` and `processed/test.pt` into a folder named `Fashion-MNIST`, I get a `RuntimeError: Dataset not found`. Turning `Fashion-MNIST` into `FashionMNIST` solves the issue. When `download=True`, the system also generates the files in a folder named `FashionMNIST` not `Fashion-MNIST`.

This is not an extremely important bug, but it may save some time in the future for some people experiencing bugs due to this. 



Discussion:
Hi @ibayramli2001, thanks for the report. Do you want to send a PR fixing this?

Resolving patch:
diff --git a/torchvision/datasets/mnist.py b/torchvision/datasets/mnist.py
--- a/torchvision/datasets/mnist.py
+++ b/torchvision/datasets/mnist.py
@@ -169,8 +169,8 @@ class FashionMNIST(MNIST):
     """`Fashion-MNIST <https://github.com/zalandoresearch/fashion-mnist>`_ Dataset.
 
     Args:
-        root (string): Root directory of dataset where ``Fashion-MNIST/processed/training.pt``
-            and  ``Fashion-MNIST/processed/test.pt`` exist.
+        root (string): Root directory of dataset where ``FashionMNIST/processed/training.pt``
+            and  ``FashionMNIST/processed/test.pt`` exist.
         train (bool, optional): If True, creates dataset from ``training.pt``,
             otherwise from ``test.pt``.
         download (bool, optional): If true, downloads the dataset from the internet and


Test patch:
Repository: pytorch/vision

Issue:
Docs of some functions written are missing
## 📚 Documentation

A simple issue, Docs are missing on the torchvision website for following functions written in torchvision.

I guess we should add these docs on the webpage, as end-users will benefit from using these functions. 

Most people will not look at source code to find these functions but refer to docs.

Missing docs that I found

- [x] Image reading functions [here](https://github.com/pytorch/vision/blob/master/torchvision/io/image.py)
We have docs for video io functions, so maybe image should too be there.

- [x] Torchvision ops from [boxes.py](https://github.com/pytorch/vision/blob/master/torchvision/ops/boxes.py). Docs are added for NMS. but we are missing IoU, Box area and some classes. Partly fixed in #2642 

Please do let me know if some other docs or missing as well.

Also, I can raise a PR to fix these, please do let me know if it is needed!






Discussion:
@oke-aditya thanks for reporting :) 

Concerning "Image reading functions", it is only `master` version and does not exist yet in the stable version, right ?

About torchvision ops from boxes.py, yes, seems like some docstrings are missing in https://pytorch.org/docs/stable/torchvision/ops.html which can be easily added.

So, yes, please, send a PR for fixing missing functions in docs for boxes.py.


For image reading functions, docs do not exist for both, master as well as stable. 

Please verify once [io.rst](https://github.com/pytorch/vision/blob/master/docs/source/io.rst)

Yes, you are right, docs for master version are also missing image reading functions. A PR for that could also help :)

Resolving patch:
diff --git a/torchvision/io/__init__.py b/torchvision/io/__init__.py
--- a/torchvision/io/__init__.py
+++ b/torchvision/io/__init__.py
@@ -15,7 +15,6 @@
     write_video,
 )
 
-
 __all__ = [
     "write_video",
     "read_video",
diff --git a/torchvision/ops/__init__.py b/torchvision/ops/__init__.py
--- a/torchvision/ops/__init__.py
+++ b/torchvision/ops/__init__.py
@@ -1,4 +1,4 @@
-from .boxes import nms, box_iou
+from .boxes import nms, batched_nms, remove_small_boxes, clip_boxes_to_image, box_area, box_iou
 from .new_empty_tensor import _new_empty_tensor
 from .deform_conv import deform_conv2d, DeformConv2d
 from .roi_align import roi_align, RoIAlign
@@ -14,7 +14,8 @@
 
 
 __all__ = [
-    'deform_conv2d', 'DeformConv2d', 'nms', 'roi_align', 'RoIAlign', 'roi_pool',
+    'deform_conv2d', 'DeformConv2d', 'nms', 'batched_nms', 'remove_small_boxes',
+    'clip_boxes_to_image', 'box_area', 'box_iou', 'roi_align', 'RoIAlign', 'roi_pool',
     'RoIPool', '_new_empty_tensor', 'ps_roi_align', 'PSRoIAlign', 'ps_roi_pool',
     'PSRoIPool', 'MultiScaleRoIAlign', 'FeaturePyramidNetwork'
 ]


Test patch:
Repository: pytorch/vision

Issue:
Has anyone successfully compiled the C++ API on Windows, including the cuda code?
I have tried many versions of torchvision, none seems to work for me. (on Windows)
1, The old version 0.5.0 simply does not include cuda code into the build. 
2, Then I tried 0.6.0, it has the "-openmp" not support error. After a lot of searching and trying, I solved it by deleting one line in the torchvision.vcxproj.
3, 0.6.0 finally gets to compile, but it gives "unresolved external symbol" error if i want to use nms_cuda, according to this issue #2139, the cuda impl of operators are not included in torchvision.lib.
4, Then I tried the recent 0.7.0 tag and it gives "A single input file is required for a non-link phase when an outputfile is specified" error, this one (#2677) simply no one here knows how to solve it. Other resources suggests it might due to misplaced white space...

Could you point me to a version that works on Windows? Or simply no support for Windows?


cc @peterjc123 @nbcsm @guyang3532 @maxluk @gunandrose4u @smartcat2010 @mszhanyi


Discussion:

Resolving patch:
diff --git a/.circleci/regenerate.py b/.circleci/regenerate.py
--- a/.circleci/regenerate.py
+++ b/.circleci/regenerate.py
@@ -191,8 +191,8 @@ def cmake_workflows(indentation=6):
     jobs = []
     python_version = '3.8'
     for os_type in ['linux', 'windows', 'macos']:
-        # Right now CMake builds are failling on Windows (GPU)
-        device_types = ['cpu', 'gpu'] if os_type == 'linux' else ['cpu']
+        # Skip OSX CUDA
+        device_types = ['cpu', 'gpu'] if os_type != 'macos' else ['cpu']
         for device in device_types:
             job = {
                 'name': f'cmake_{os_type}_{device}',
@@ -200,7 +200,7 @@ def cmake_workflows(indentation=6):
             }
 
             job['cu_version'] = 'cu101' if device == 'gpu' else 'cpu'
-            if device == 'gpu':
+            if device == 'gpu' and os_type == 'linux':
                 job['wheel_docker_image'] = 'pytorch/manylinux-cuda101'
             jobs.append({f'cmake_{os_type}_{device}': job})
     return indent(indentation, jobs)


Test patch:
Repository: pytorch/vision

Issue:
Fix incorrect layout in transforms docs
## 📚 Documentation

Fix this incorrect layout of sections/subsections:
<img width="857" alt="Screen Shot 2020-10-01 at 14 28 43" src="https://user-images.githubusercontent.com/2459423/94809140-74b63800-03f2-11eb-91d8-731e475fe75d.png">

```

 - Scriptable transforms
        Transforms on PIL Image
        Transforms on torch.*Tensor
        Conversion Transforms
        Generic Transforms
        Functional Transforms

```


Discussion:

Resolving patch:
diff --git a/torchvision/transforms/transforms.py b/torchvision/transforms/transforms.py
--- a/torchvision/transforms/transforms.py
+++ b/torchvision/transforms/transforms.py
@@ -161,11 +161,11 @@ class ToPILImage:
     Args:
         mode (`PIL.Image mode`_): color space and pixel depth of input data (optional).
             If ``mode`` is ``None`` (default) there are some assumptions made about the input data:
-             - If the input has 4 channels, the ``mode`` is assumed to be ``RGBA``.
-             - If the input has 3 channels, the ``mode`` is assumed to be ``RGB``.
-             - If the input has 2 channels, the ``mode`` is assumed to be ``LA``.
-             - If the input has 1 channel, the ``mode`` is determined by the data type (i.e ``int``, ``float``,
-               ``short``).
+            - If the input has 4 channels, the ``mode`` is assumed to be ``RGBA``.
+            - If the input has 3 channels, the ``mode`` is assumed to be ``RGB``.
+            - If the input has 2 channels, the ``mode`` is assumed to be ``LA``.
+            - If the input has 1 channel, the ``mode`` is determined by the data type (i.e ``int``, ``float``,
+            ``short``).
 
     .. _PIL.Image mode: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#concept-modes
     """


Test patch: