Harshil Savaj
Harshil Savaj

Reputation: 1

ModuleNotFoundError: No module named 'torchvision.transforms.functional'; 'torchvision.transforms' is not a package

Im currently perfoming A object detection using Rasperrypi model 4B 8 GB ram.The Error is

Code : import torch import matplotlib.pyplot as plt import numpy as np import cv2 import uuid import os import time import torchvision as TF import torch

model=torch.hub.load('ultralytics/yolov5','custom',path='last1.pt',force_reload=True)

cap = cv2.VideoCapture(0)

while cap.isOpened(): ret, frame = cap.read()

# Make detections
results = model(frame)

# Convert the results to a format compatible with cv2.imshow
rendered_results = np.squeeze(results.render())
rendered_results = rendered_results.astype(np.uint8)

cv2.imshow('YOLO', rendered_results)

if cv2.waitKey(10) & 0xFF == ord('q'):
    break

cap.release() cv2.destroyAllWindows()

Output Error import torchvision.transforms.functional as TF ModuleNotFoundError: No module named 'torchvision.transforms.functional'; 'torchvision.transforms' is not a package

Help me with to perform the object detection using Pytorch

Upvotes: 0

Views: 2556

Answers (0)

Related Questions