cfotache / pytorch_objectdetecttrack Goto Github PK
View Code? Open in Web Editor NEWObject detection in images, and tracking across video frames
Object detection in images, and tracking across video frames
I have changed model.cuda to model.cpu but I am getting a error in line 20 of detect_image(img) function, i.e input_img = Variable(image_tensor.type(Tensor)) saying that
Cannot initialize CUDA without ATen_cuda library
The whole program is at click here
Help me :D
tracked_objects = mot_tracker.update(detections.cpu())
this above line i am facing this below error
TypeError: tuple indices must be integers or slices, not tuple
Can you please add a LICENCE file to indicate what license this code is available under?
Hi! I am trying to use your code for object detection and tracking using Ubuntu 20.04. Detection on image works fine but when attempting on videos and trying to track, I get following warnings and errors:
/home/anam/anaconda3/envs/yolov3/lib/python3.6/site-packages/torch/nn/_reduction.py:44: UserWarning: size_average and reduce args will be deprecated, please use reduction='mean' instead.
warnings.warn(warning.format(ret))
/home/anam/Codes/YOLOv4/Yolov3/pytorch_objectdetecttrack/sort.py:33: NumbaWarning:
Compilation is falling back to object mode WITH looplifting enabled because Function "iou" failed type inference due to: non-precise type pyobject
During: typing of argument at /home/anam/Codes/YOLOv4/Yolov3/pytorch_objectdetecttrack/sort.py (38)
File "sort.py", line 38:
def iou(bb_test,bb_gt):
"""
xx1 = np.maximum(bb_test[0], bb_gt[0])
^
@jit
/home/anam/anaconda3/envs/yolov3/lib/python3.6/site-packages/numba/core/object_mode_passes.py:178: NumbaWarning: Function "iou" was compiled in object mode without forceobj=True.
File "sort.py", line 34:
@jit
def iou(bb_test,bb_gt):
^
state.func_ir.loc))
/home/anam/anaconda3/envs/yolov3/lib/python3.6/site-packages/numba/core/object_mode_passes.py:188: NumbaDeprecationWarning:
Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.
For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit
File "sort.py", line 34:
@jit
def iou(bb_test,bb_gt):
^
state.func_ir.loc))
Traceback (most recent call last):
File "object_detector.py", line 124, in
tracked_objects = mot_tracker.update(detections.cpu())
File "/home/anam/Codes/YOLOv4/Yolov3/pytorch_objectdetecttrack/sort.py", line 209, in update
matched, unmatched_dets, unmatched_trks = associate_detections_to_trackers(dets,trks)
File "/home/anam/Codes/YOLOv4/Yolov3/pytorch_objectdetecttrack/sort.py", line 153, in associate_detections_to_trackers
if(d not in matched_indices[:,0]):
TypeError: tuple indices must be integers or slices, not tuple
Wondering if you can help.
I have noticed that when tracking people, if one person walks in front of another there are a couple of frames where the person behind is not detected, and then detected again when the person in front has moved away. However, when this happens the ID of the person has changed. Is there any way to resolve this issue? I suppose not in this instance as there would be no reliable way to tell if this is a new person or not.
I have also noticed it occur on consecutive frames on the same person where one frame has not made a correct detection. In this case would it just be best to lower the detection threshold?
Thanks in advance
HI.
i am trying run tracker code in my pc(windows 10)but i got this error.this is my project.please help me
whenever I am trying object detection.py I am getting this error-
Traceback (most recent call last):
File "object_tracker.py", line 87, in
tracked_objects = mot_tracker.update(detections.cpu())
File "Z:\DEEP_Learning\original files\Yolo based model\using GPU\pytorch_objectdetecttrack\sort.py", line 208, in update
matched, unmatched_dets, unmatched_trks = associate_detections_to_trackers(dets,trks)
File "Z:\DEEP_Learning\original files\Yolo based model\using GPU\pytorch_objectdetecttrack\sort.py", line 147, in associate_detections_to_trackers
iou_matrix[d,t] = iou(det,trk)
RuntimeError: Expected object of type torch.FloatTensor but found type torch.DoubleTensor for argument #3 'other'
from filterpy.kalman import KalmanFilter
ModuleNotFoundError: No module named 'filterpy'
Help me, please
Hi Chris,
You have done a great job.
But While executing the object_tracker.py, I am getting the following error:
RuntimeError: Expected object of type torch.FloatTensor but found type torch.DoubleTensor for argument #3 'other'
Where am I going wrong ?
Thanks :)
When running object_tracker.py using yolov3-tiny weights and cfg file, I get the following:
RuntimeError: Given groups=1, weight of size 256 256 3 3, expected input[1, 384, 26, 26] to have 256 channels, but got 384 channels instead
Any help will be greatly appreciated..
What kind of modifications are required in the code to run "tiny yolov3" for object detection, apart from using different config file and weights ?
I'am getting the following error
File "/pytorch_objectdetecttrack/models.py", line 129, in forward
prediction = x.view(nB, nA, self.bbox_attrs, nG, nG).permute(0, 1, 3, 4, 2).contiguous()
RuntimeError: shape '[1, 3, 85, 12, 12]' is invalid for input of size 39780
Thanks
Traceback (most recent call last):
File "object_tracker.py", line 1, in
from models import *
File "/home/krsbi/TA-Bill/pytorch_objectdetecttrack/models.py", line 259
x, *losses = module[0](x, targets)
^
SyntaxError: invalid syntax
Can someone help me?
initiallly for one or two objects the id is generated in sequence later the is random as 8,21..... how to solve this
When running object_tracker.py, I get the following the error:
/home/ubuntu/.local/lib/python3.6/site-packages/torch/nn/_reduction.py:46: UserWarning: size_average and reduce args will be deprecated, please use reduction='mean' instead.
warnings.warn(warning.format(ret))
: cannot connect to X server
I'd really appreciate if anyone can tell me where is that server or how can I solve this problem?
https://github.com/cfotache/pytorch_objectdetecttrack/blob/master/utils/datasets.py#L92-L116
It would be helpful to include the label document so I can make sense of the code that goes inside the above area.. Not sure how to return the Labels.. seems I need to return a matrix of all classes? Based on a list of pre-filled classes? I want to train new classes with transfer learning and a dataset of images and bounding boxes..
currently my labels are a single text file for each image.. so I will open it and load the text file
MyExampleClass [859, 36, 2329, 1801]
And I seem to need to return a torch.from_numpy
likeso
if labels is not None:
filled_labels[range(len(labels))[:self.max_objects]] = labels[:self.max_objects]
filled_labels = torch.from_numpy(filled_labels)
is the filled_labels
an array of [[x1,y1,x2,y2,classification]....]
?
Hi, is there a NMS part for this notebook? Does anybody know how to Perform Non-maximum Suppression (NMS) based on this code?
Just wondering if you can upload the requirements.txt too, will make the installation and work easier.
Hello, would someone kindly help me with this error
DeprecationWarning: The linear_assignment_ module is deprecated in 0.21 and will be removed from 0.23. Use scipy.optimize.linear_sum_assignment instead.
DeprecationWarning)
Video size 1280 720
2
Traceback (most recent call last):
File "object_tracker.py", line 105, in
cls = classes[int(cls_pred)]
IndexError: list index out of range
When I try to run object_tracker.py, I get the following error.
x, *losses = module[0](x, targets) Syntax error: invalid syntax.
Any idea why?
#changes in code :
model = Darknet(config_path, img_size=img_size)
model.load_weights(weights_path)
#model.cuda()
device = torch.device("Cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
model.eval()
classes = utils.load_classes(class_path)
Tensor = torch.FloatTensor
Code runs and provide output also for seconds but after that its shows above error , Please help me ?
Hello, I got this error, when I tried to run the program with the custom datasets, anybody know how to resolve it?
('Video size', 640, 480)
(Stream:14631): GStreamer-CRITICAL **: 09:39:54.096: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed
OpenCV Error: Unsupported format or combination of formats (Gstreamer Opencv backend does not support this file type.) in CvVideoWriter_GStreamer::open, file /home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp, line 1534
VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps, frameSize, is_color)): raised OpenCV exception:
/home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp:1534: error: (-210) Gstreamer Opencv backend does not support this file type. in function CvVideoWriter_GStreamer::open
Traceback (most recent call last):
File "own_object_detection.py", line 276, in
detections = detect_image(pilimg)
File "own_object_detection.py", line 242, in detect_image
image_tensor = img_transforms(img).float()
File "build/bdist.linux-aarch64/egg/torchvision/transforms/transforms.py", line 61, in call
File "build/bdist.linux-aarch64/egg/torchvision/transforms/transforms.py", line 196, in call
File "build/bdist.linux-aarch64/egg/torchvision/transforms/functional.py", line 246, in resize
File "build/bdist.linux-aarch64/egg/PIL/Image.py", line 1892, in resize
TypeError: integer argument expected, got float
While drawing the bounding boxes in the image using plt.savefig(), I am getting the error of
ValueError: Image size of 3396073x2015469 pixels is too large. It must be less than 2^16 in each direction.
Can anyone please tell me how to resolve the issue and save the bounding boxes?
Complete error log:
plt.savefig(img_path.replace(".jpg", "-det.png"), dpi=500, bbox_inches='tight', pad_inches=0.0)
File "/home/sipaul/anaconda3/envs/pytorch/lib/python3.8/site-packages/matplotlib/pyplot.py", line 723, in savefig
res = fig.savefig(*args, **kwargs)
File "/home/sipaul/anaconda3/envs/pytorch/lib/python3.8/site-packages/matplotlib/figure.py", line 2203, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/home/sipaul/anaconda3/envs/pytorch/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 2119, in print_figure
result = print_method(
File "/home/sipaul/anaconda3/envs/pytorch/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 514, in print_png
FigureCanvasAgg.draw(self)
File "/home/sipaul/anaconda3/envs/pytorch/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 388, in draw
self.renderer = self.get_renderer(cleared=True)
File "/home/sipaul/anaconda3/envs/pytorch/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 404, in get_renderer
self.renderer = RendererAgg(w, h, self.figure.dpi)
File "/home/sipaul/anaconda3/envs/pytorch/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 92, in init
self._renderer = _RendererAgg(int(width), int(height), dpi)
ValueError: Image size of 3396073x2015469 pixels is too large. It must be less than 2^16 in each direction
Great work, thanks a lot for sharing!
Noticed this thing and seems a bug due to input format:
In original sort, the input format of det is
Computes IOU between two bboxes in the form [x1,y1,x2,y2]
in your code, the det is in format of [x1, y1, x2, y2, object_conf, class_score, class_pred], due to the yolov3 output.
suggested change:
iou_matrix[d,t] = iou(det[:4],trk[:4])
Let me know if it makes sense or not, thanks again!
Hye, what a great project! I tried to run the code however I am using a vgg16 model. I can't run the code since it said the dimension has too many indices on line 136 in utils file. May I know the dimension representing what? And do you have any suggestions or references to give?
This is a very interesting insight on object vision, is there a good tutorial to train a yolo on pytorch from scratch
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.