Questions tagged [torchvision]

Use this tag for questions, concepts, and issues related to the PyTorch computer vision library

TorchVision is a computer vision library for manipulating images. It contains utility functions for processing images so that they can be fed into neural networks. It also houses popular image datasets, deep CNN model architectures along with pretrained models.

More information about the API and the documentation can be found at: Torchvision

666 questions
25
votes
2 answers

How can I generate and display a grid of images in PyTorch with plt.imshow and torchvision.utils.make_grid?

I am trying to understand how torchvision interacts with mathplotlib to produce a grid of images. It's easy to generate images and display them iteratively: import torch import torchvision import matplotlib.pyplot as plt w =…
Jon Middleton
  • 363
  • 1
  • 3
  • 8
20
votes
4 answers

PyTorch - Getting the 'TypeError: pic should be PIL Image or ndarray. Got ' error

I am getting the error TypeError: pic should be PIL Image or ndarray. Got when I try to load a non-image dataset through the DataLoader. The versions of torch and torchvision are 1.0.1, and 0.2.2.post3, respectively. Python's…
talha06
  • 6,206
  • 21
  • 92
  • 147
19
votes
2 answers

What is running loss in PyTorch and how is it calculated

I had a look at this tutorial in the PyTorch docs for understanding Transfer Learning. There was one line that I failed to understand. After the loss is calculated using loss = criterion(outputs, labels), the running loss is calculated using…
Jitesh Malipeddi
  • 2,150
  • 3
  • 17
  • 37
17
votes
1 answer

Output and Broadcast shape mismatch in MNIST, torchvision

I am getting following error when using MNIST dataset in Torchvision RuntimeError: output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28] Here is my code: import torch from torchvision import datasets, transforms transform =…
Jibin Mathew
  • 4,816
  • 4
  • 40
  • 68
16
votes
4 answers

Is there any way I can download the pre-trained models available in PyTorch to a specific path?

I am referring to the models that can be found here: https://pytorch.org/docs/stable/torchvision/models.html#torchvision-models
12
votes
3 answers

PyTorch [1 if x > 0.5 else 0 for x in outputs ] with tensors

I have a list outputs from a sigmoid function as a tensor in PyTorch E.g output (type) = torch.Size([4]) tensor([0.4481, 0.4014, 0.5820, 0.2877], device='cuda:0', As I'm doing binary classification I want to turn all values bellow 0.5 to 0 and…
Brian Formento
  • 731
  • 2
  • 9
  • 24
11
votes
3 answers

How do I load a local model with torch.hub.load?

I need to avoid downloading the model from the web (due to restrictions on the machine installed). This works, but it downloads the model from the Internet model = torch.hub.load('pytorch/vision:v0.9.0', 'deeplabv3_resnet101', pretrained=True) I…
coding-dude.com
  • 758
  • 1
  • 8
  • 27
11
votes
5 answers

PyTorch : How to apply the same random transformation to multiple image?

I am writing a simple transformation for a dataset which contains many pairs of images. As a data augmentation, I want to apply some random transformation for each pair but the images in that pair should be transformed in the same way. For example,…
TFC
  • 466
  • 1
  • 5
  • 14
11
votes
3 answers

How to get the filename of a sample from a DataLoader?

I need to write a file with the result of the data test of a Convolutional Neural Network that I trained. The data include speech data collection. The file format needs to be "file name, prediction", but I am having a hard time to extract the file…
Almog Levi
  • 121
  • 1
  • 1
  • 5
9
votes
1 answer

No module named ‘torchvision.models.utils‘

When I use the environment of pytorch=1.10.0, torchvision=0.11.1 to run the code, I run to the statement from torchvision.models.utils import load_state_dict_from_url. The following error will appear when: >>> from torchvision.models.utils import…
Oscar Rangel
  • 848
  • 1
  • 10
  • 18
9
votes
2 answers

Error:RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase

I got error after running the following script: -- coding: utf-8 -- Import the Stuff import torch import torch.nn as nn import torch.optim as optim from torch.utils import data from torch.utils.data import DataLoader import torchvision.transforms as…
Ilvico
  • 293
  • 1
  • 3
  • 9
9
votes
4 answers

How downsample work in ResNet in pytorch code?

In this pytorch ResNet code example they define downsample as variable in line 44. and line 58 use it as function. How this downsample work here as CNN point of view and as python Code point of view. code example : pytorch ResNet i searched for if…
8
votes
4 answers

pytorch torchvision.datasets.ImageFolder FileNotFoundError: Found no valid file for the classes .ipynb_checkpoints

Tried to load training data with pytorch torch.datasets.ImageFolder in Colab. transform = transforms.Compose([transforms.Resize(400), transforms.ToTensor()]) dataset_path = 'ss/' dataset =…
8
votes
4 answers

How to install PyTorch with pipenv and save it to Pipfile and Pipfile.lock?

I’m currently using Pipenv to maintain the Python packages used in a specific project. Most of the downloads I’ve tried so far have worked as intended; that is, I enter pipenv install [package] and it installs the package into the virtual…
Matt Dubow
  • 81
  • 1
  • 2
8
votes
4 answers

No such operator torchvision::nms

When I try to run yoloV3 detect,it happend the error op = torch._C._jit_get_operation(qualified_op_name) RuntimeError: No such operator torchvision::nms Though this code is the source code of torchvision ,I try sevaral time to correct the code by…
Noodles
  • 169
  • 1
  • 2
  • 4
1
2 3
44 45