torch

how to improve rotation in a spatial transformation network

how to improve rotation in a spatial transformation network Question: I am applying a spatial transformation network to a dataset I created. The dataset consists of boots and shoes that are slightly rotated (random rotation between 10° and 30°) as shown in the dataset images figure. I trained my model on the Fashionmnist dataset and …

Total answers: 1

How does "kwargs" is passed to a variable implicitly?

How does "kwargs" is passed to a variable implicitly? Question: A simple code from pytorch tutorial, which is used to load the data ”’ tr_data = datasets.FashionMNIST(root="data", train=True, download=True, transform=ToTensor()) ”’ However, when debug into the code as shown above. It use the "new" method without passing the "kwds". It seems the param "transform=ToTensor()" is …

Total answers: 1

Background removal with U2Net is too strong

Background removal with U2Net is too strong Question: I am successfully using U2Net to remove the background of images using the terminal and I am also using the nice interface of this repo to do the same thing just in an easier way and validate the similarity of the results. However, my issue is that …

Total answers: 1

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

How do I load a local model with torch.hub.load? Question: 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 have placed the .pth file and the hubconf.py file in the /tmp/ …

Total answers: 3

ImportError: cannot import name 'download_url_to_file'

ImportError: cannot import name 'download_url_to_file' Question: I tried to run a Python script that uses the download_url_to_file method inside the torch hub, but I got the following error: Traceback (most recent call last): File "crop-video.py", line 1, in <module> import face_alignment File "$PROGRAMS_PATH$PythonPython36libsite-packagesface_alignment-1.3.3-py3.6.eggface_alignment__init__.py", line 7, in <module> File "$PROGRAMS_PATH$PythonPython36libsite-packagesface_alignment-1.3.3-py3.6.eggface_alignmentapi.py", line 7, in <module> File "$PROGRAMS_PATH$PythonPython36libsite-packagesface_alignment-1.3.3-py3.6.eggface_alignmentutils.py", …

Total answers: 2

How to check whether tensor values in a different tensor pytorch?

How to check whether tensor values in a different tensor pytorch? Question: I have 2 tensors of unequal size a = torch.tensor([[1,2], [2,3],[3,4]]) b = torch.tensor([[4,5],[2,3]]) I want a boolean array of whether each value exists in the other tensor without iterating. something like a in b and the result should be [False, True, False] …

Total answers: 5

1D CNN on Pytorch: mat1 and mat2 shapes cannot be multiplied (10×3 and 10×2)

1D CNN on Pytorch: mat1 and mat2 shapes cannot be multiplied (10×3 and 10×2) Question: I have a time series with sample of 500 size and 2 types of labels and want to construct a 1D CNN with pytorch on them: class Simple1DCNN(torch.nn.Module): def __init__(self): super(Simple1DCNN, self).__init__() self.layer1 = torch.nn.Conv1d(in_channels=50, out_channels=20, kernel_size=5, stride=2) self.act1 = …

Total answers: 2

RuntimeError: Subtraction, the `-` operator, with a bool tensor is not supported

RuntimeError: Subtraction, the `-` operator, with a bool tensor is not supported Question: I am using this github repo: https://github.com/vchoutas/smplify-x and I am running a script. I get the following error. How can I fix it? I understand I might have to convert – to ~ however not sure where it exactly is. I don’t …

Total answers: 2

'use_cuda' set to True when cuda is unavailable. Make sure CUDA is available or set use_cuda=False

'use_cuda' set to True when cuda is unavailable. Make sure CUDA is available or set use_cuda=False Question: I am trying to create a Bert model for classifying Turkish Lan. here is my code: import pandas as pd import torch df = pd.read_excel (r’preparedDataNoId.xlsx’) df = df.sample(frac = 1) from sklearn.model_selection import train_test_split train_df, test_df = …

Total answers: 4

How to load a dataset starting from list of images Pytorch

How to load a dataset starting from list of images Pytorch Question: I have a service that receives images in a binary format from another service (let’s call it service B): from PIL import Image img_list = [] img_bin = get_image_from_service_B() image = Image.open(io.BytesIO(img_bin)) # Convert bytes to image using PIL When an image is …

Total answers: 1