Umar-Saeed-97 / Vehicle-Count

Object Detection | Object Tracking | YOLOv8 | ByteTrack
MIT License
73 stars 13 forks source link

Bug in ultralytics results.py #2

Open Thecoder1012 opened 1 year ago

Thecoder1012 commented 1 year ago

Hi Umar, I was trying to run your code but getting the error Traceback (most recent call last): File "/home/thecoder/Sample/yolov8_bytetracker.py", line 108, in vehicle_count(source_path = "data/src/test1.mp4", File "/home/thecoder/Sample/yolov8_bytetracker.py", line 68, in vehicle_count for result in model.track(source = source_path, tracker = 'bytetrack.yaml', show=True, stream=True, agnostic_nms=True): File "/home/thecoder/.local/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 43, in generator_context response = gen.send(None) File "/home/thecoder/.local/lib/python3.10/site-packages/ultralytics/yolo/engine/predictor.py", line 217, in stream_inference self.run_callbacks('on_predict_postprocess_end') File "/home/thecoder/.local/lib/python3.10/site-packages/ultralytics/yolo/engine/predictor.py", line 308, in run_callbacks callback(self) File "/home/thecoder/.local/lib/python3.10/site-packages/ultralytics/tracker/track.py", line 51, in on_predict_postprocess_end predictor.results[i] = predictor.results[i][idx] File "/home/thecoder/.local/lib/python3.10/site-packages/ultralytics/yolo/engine/results.py", line 114, in getitem setattr(r, k, getattr(self, k)[idx]) File "/home/thecoder/.local/lib/python3.10/site-packages/ultralytics/yolo/engine/results.py", line 64, in getitem return self.class(self.data[idx], self.orig_shape) TypeError: 'float' object cannot be interpreted as an integer

Can you solve it?

Umar-Saeed-97 commented 1 year ago

Without any code, it's difficult to provide a solution to the error you're facing. Could you provide some code or more information?

Thecoder1012 commented 1 year ago

I was just running your code that you have uploaded and facing this error.

Umar-Saeed-97 commented 1 year ago

Are you running the code on Colab or locally?

Thecoder1012 commented 1 year ago

I have checked it locally

Umar-Saeed-97 commented 1 year ago

Try running it on Colab as there might be an issue with the requirements.txt file. Just to mention, I too developed the project using Colab.

Thecoder1012 commented 1 year ago

Checked the code in colab but still the issue is there

WARNING ⚠️ Environment does not support cv2.imshow() or PIL Image.show()


ValueError Traceback (most recent call last) in <cell line: 2>() 1 # Performing vehicle count on the test video ----> 2 vehicle_count(source_path = "/content/Vehicle-Count/Data/Example Videos/test1.mp4", 3 destination_path = "/content/Vehicle-Count/Data/Example Results", 4 line_start = (337, 391), 5 line_end = (917, 387))

1 frames in vehicle_count(source_path, destination_path, line_start, line_end) 48 49 # Generate labels for the detections, including the tracker ID, class name, and confidence ---> 50 labels = [f"{tracker_id} {model.model.names[classid]} {confidence:0.2f}" 51 for , confidence, class_id, tracker_id 52 in detections]

in (.0) 49 # Generate labels for the detections, including the tracker ID, class name, and confidence 50 labels = [f"{tracker_id} {model.model.names[classid]} {confidence:0.2f}" ---> 51 for , confidence, class_id, tracker_id 52 in detections] 53

ValueError: too many values to unpack (expected 4)

Vicysabri commented 1 year ago

I have problems in this part. Can you help me?

Performing vehicle count on the test video

vehicle_count(source_path = "Data/Example Videos/test1.mp4", destination_path = "Data/Example Results", line_start = (337, 391), line_end = (917, 387))

error: requirements: YOLOv8 requirement "lap>=0.4" not found, attempting AutoUpdate... requirements: Command 'pip install --no-cache "lap>=0.4" ' returned non-zero exit status 1. ModuleNotFoundError: No module named 'lap'

can't install lap