Reputation: 11
when I try to run the following code on Ubuntu with python = 3.11.9, pytorch = 2.3.1+cu121
from ultralytics import SAM
import cv2
import time
import numpy as np
import torch
model = SAM("mobile_sam.pt") # Load model
capture = cv2.VideoCapture('images/0-1.MOV')
t = []
while capture.isOpened():
ret, frame = capture.read()
if not ret:
break
frame = cv2.resize(frame, (640,480))
print('start interence... , ', type(frame))
t1 = time.time()
results = model.predict(frame) # Inference
print(f'done inference... , {time.time()-t1} ', type(results))
t.append(time.time()-t1)
capture.release()
I got an error like this:
Traceback (most recent call last):
File "/home/ubuntu/SLAM/SLAM/test.py", line 28, in <module>
results = model.predict(frame) # Inference
^^^^^^^^^^^^^^^^^^^^
RuntimeError: Non-empty 4D data tensor expected but got a tensor with sizes [1, 0, 576, 1024]
However, I run the same code successfully on my mac. And I want to find how to solve this probelm.
Upvotes: 1
Views: 34