0

i am working with stereo zed cam to extract the x and y values and store them as a list or array. i used custom dataset which is detect.py and trained those images. but i am getting and error. this is the half code.

from models.experimental import attempt_load
import torchvision.transforms as transforms

from utils.general import non_max_suppression

#set device
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

# Path to the yolov7 weights file
weights_path = 'runs/train/yolov7-cones/weights/best.pt'

model = attempt_load(weights_path, map_location=device)
model.to(device).eval()
img_size = 640
img = Image.open("inference/3cone.jpeg")
transform = transforms.Compose([
    transforms.Resize((640, 640)),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])

image = transform(img)
image = img.unsqueeze(0)
# add batch dimension

# create the model and pass the input tensor through it
model1 = model()
output = model1(image)


# check the shape and values of the output tensor
print(output.shape)
print(output)

this is the output:

  File "F:\yolov7-gpu\zed2.py", line 33, in <module>
    image = img.unsqueeze(0)
jodag
  • 19,885
  • 5
  • 47
  • 66
  • `img` is probably a `PIL.Image` not a `Tensor`. You probably meant `image = image.unsqueeze(0)`. – jodag Mar 14 '23 at 14:14
  • hey that one is solved but i am getting this as an error what to do? print(output.shape) AttributeError: 'tuple' object has no attribute 'shape' – sureya nachiappan Mar 14 '23 at 14:44

0 Answers0