nicholaskajoh / ivy Goto Github PK
View Code? Open in Web Editor NEWVideo-based object counting software.
License: MIT License
Video-based object counting software.
License: MIT License
I set the colab environment up according to instructions and when I went on to run the main file, i got this error : cannot connect to X server
which is what pops up when there is no display to connect to. Is there any way to remove this display option and simply record the output somewhere, so that this might be working in a server?
Just for information, I used the --record
argument as well.
Hi @nicholaskajoh,
I would like to use the demo of your repo but I'm gettin the following error when running make
once I cloned the darknet repo and installed its dependencies in order to use YOLO. Also, I am using Ubuntu 18.04.1.
$ sudo make
nvcc -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] -Iinclude/ -Isrc/ -DGPU -I/usr/local/cuda/include/ --compiler-options "-Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DGPU" -c ./src/convolutional_kernels.cu -o obj/convolutional_kernels.o
nvcc fatal : Path to libdevice library not specified
Makefile:92: recipe for target 'obj/convolutional_kernels.o' failed
make: *** [obj/convolutional_kernels.o] Error 1
I supposed it could be something wrong with CUDA's path as suggested by this comment. Since the path in the Makefile its the same in /usr/local/cuda/include/
ifeq ($(GPU), 1)
COMMON+= -DGPU -I/usr/local/cuda/include/
CFLAGS+= -DGPU
LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand
endif
Tried the following command export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
as mentioned but could not fix it.
Any suggestion of what I'm doing wrong will be appreciated
First of all, I want to say that this is a wonderful project and I had a blast experimenting with it. Thank you very much.
However, one thing I noticed is that I was able to get a higher FPS (YOLO detector) when I switched out Joblib's Parallel code with just an ordinary for-loop at ObjectCounter.py (the line where you update_blob_tracker for every blob in blobs_list).
Is this a problem on my hardware (Windows, 8 core CPU, in case it is relevant)? Or is the overhead cost of parallelism outweighs the cost to update blobs' trackers?
Thank you in advance.
WEIGHTS_PATH=/home/nicholas/dev/Vehicle-Counting/detectors/yolo/downloads/yolov3.weights
CONFIG_PATH=/home/nicholas/dev/Vehicle-Counting/detectors/yolo/downloads/yolov3.cfg
CLASSES_PATH=/home/nicholas/dev/Vehicle-Counting/detectors/yolo/downloads/coco.classes.txt
CLASSES_OF_INTEREST_PATH=/home/nicholas/dev/Vehicle-Counting/detectors/yolo/downloads/coco_interest.classes.txt
Ỹou might would like to check the cv2 background subtraction function
cv2.createBackgroundSubtractorMOG2()
Hey, can you create a branch for the proposed module as discussed ? I've made some progress already would be creating a PR soon.
Thank for your code
But it's so slow
I see the document as below
"Real-time and video processing object detection using Tensorflow, OpenCV and Docker.
https://towardsdatascience.com/real-time-and-video-processing-object-detection-using-tensorflow-opencv-and-docker-2be1694726e5 "
Do you think if we use Docker as that document the speed will be improved or not?
Thank you
Thanks for your work.
Do you have the idea of improving the calculation speed? It is slow.
What do you think about adding https://github.com/HRNet/HRNet-Semantic-Segmentation/tree/HRNet-OCR?
It's SOTA right now for Cityscapes.
(base) PS C:\Users\poorn\Downloads\Vehicle-Counting-master\Vehicle-Counting-master> python Vehicle_Counting.py "./videos
/sample_traffic_scene.mp4"
Traceback (most recent call last):
File "Vehicle_Counting.py", line 6, in
from detectors.detector import get_bounding_boxes
File "C:\Users\poorn\Downloads\Vehicle-Counting-master\Vehicle-Counting-master\detectors\detector.py", line 5, in
from detectors.tfoda.tfoda_detector import get_bounding_boxes as tfoda_gbb
File "C:\Users\poorn\Downloads\Vehicle-Counting-master\Vehicle-Counting-master\detectors\tfoda\tfoda_detector.py", line 13, in
with open(os.getenv('CLASSES_PATH'), 'r') as classes_file:
TypeError: expected str, bytes or os.PathLike object, not NoneType
Its observed that video is run on loop unless user presses q to exit it manually.
Any way to stop this loop from running continuously?
Hello. Love the project so far. However, followed the readme exactly as you typed it by cloning/downloading the latest version as of today. I also installed all pre-requisites.
However, when I run it, I get the following error:
Traceback (most recent call last):
File "Vehicle_Counting.py", line 11, in
from utils.detection_roi import get_roi_frame, draw_roi
ModuleNotFoundError: No module named 'utils.detection_roi'
Because I downloaded the whole thing and am running from the folder structure as you have it layed out, I have confirmed that there is a utils folder and inside of the folder is the detection_roi file in there so I cannot figure out why it says not found.
Thanks!
Hi, where can i found model_final.pth
Hi,
would like to use your project for some local traffic analysis. I downloaded everything and followed the instructions. Installed YOLA.
I modified the .env.example file to just keep the YOLA detection stuff. However there are a number of file references that are not in the download (/data). Presumably I will need to copy from YOLA somewhere but I cannot find files with thos names and I do not know which files I should use/copy.
HAAR_CASCADE_PATH="./data/detectors/haarcascade/car.xml"
YOLO_CLASSES_PATH="./data/detectors/coco_classes.txt"
YOLO_CLASSES_OF_INTEREST_PATH="./data/detectors/coco_classes_of_interest.txt"
Please give me a clue. Thanks!
ps. Running this on Ubuntu 18.
Hey nicholas, please whats the license for the this project ?
its can be deect the speed pf vehcles?
can you please tell me how to do this?
Create .env from .env.example in the project root and edit as appropriate.
Hello i am very new to this can you guide me how i can run it on simple video or webcam, yolo as detector. Thanks
Path to video file not set.
YOLO_WEIGHTS_PATH, YOLO_CONFIG_PATH, YOLO_CLASSES_PATH, YOLO_CLASSES_OF_INTEREST_PATH, and/or YOLO_CONFIDENCE_THRESHOLD not set or invalid.
Traceback (most recent call last):
File "main.py", line 14, in
import settings
File "D:\Project1\ivy-master\settings.py", line 214, in
raise Exception('One or more environment variables are either invalid or not set. ' +
Exception: One or more environment variables are either invalid or not set. Please ensure all variables are properly set.
I am getting the following error when I try to run the main program -
E:\ivy>python -m main
Traceback (most recent call last):
File "C:\Users\sriks\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\sriks\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "E:\ivy\main.py", line 21, in
init_logger()
File "E:\ivy\util\logger.py", line 59, in init_logger
file_formatter = CustomJsonFormatter('(created) (logger) (level) (message)')
File "C:\Users\sriks\AppData\Local\Programs\Python\Python39\lib\site-packages\pythonjsonlogger\jsonlogger.py", line 112, in init
logging.Formatter.init(self, *args, **kwargs)
File "C:\Users\sriks\AppData\Local\Programs\Python\Python39\lib\logging_init.py", line 570, in init
self.style.validate()
File "C:\Users\sriks\AppData\Local\Programs\Python\Python39\lib\logging_init.py", line 423, in validate
raise ValueError("Invalid format '%s' for '%s' style" % (self._fmt, self.default_format[0]))
ValueError: Invalid format '(created) (logger) (level) (message)' for '%' style
@nicholaskajoh, I really appreciate your project.
An issue I am experiencing is I'm still receiving GStreamer warnings despite the HEADLESS=True setting in the .env file (I used the .env.example).
The error I received when I typed python3 -m main is as follows:
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
[ WARN:0] global /tmp/pip-install-oxrr8sjq/opencv-contrib-python/opencv/modules/videoio/src/cap_gstreamer.cpp (1761) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module qtdemux0 reported: Internal data stream error.
[ WARN:0] global /tmp/pip-install-oxrr8sjq/opencv-contrib-python/opencv/modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /tmp/pip-install-oxrr8sjq/opencv-contrib-python/opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
[2021-01-13 16:12:27,023] ERROR : Invalid video source ./data/videos/sample_traffic_scene.mp4 {'label': 'INVALID_VIDEO_SOURCE'}
The file sample_traffic_scene.mp4 is there though in the proper directory (I downloaded it from the Google Drive link given in README).
I'm running it on Ubuntu on a Jetson Nano. Python 3 version 3.6.9
SIr thank you for sharing this awesome project. I have a problem trying to running this project, I successfully passed the python -m pytest command even the python -m main command but when it "detects" something in this case a car I have this issue:
File "/home/davo/Downloads/TProjects/ivy/main.py", line 111, in run
object_counter.count(frame)
File "/home/davo/Downloads/TProjects/ivy/ObjectCounter.py", line 74, in count
self.blobs = add_new_blobs(_bounding_boxes, _classes, _confidences, self.blobs, self.frame, self.tracker, self.mcdf)
File "/home/davo/Downloads/TProjects/ivy/tracker.py", line 66, in add_new_blobs
_tracker = get_tracker(tracker, box, frame)
File "/home/davo/Downloads/TProjects/ivy/tracker.py", line 40, in get_tracker
return _kcf_create(bounding_box, frame)
File "/home/davo/Downloads/TProjects/ivy/tracker.py", line 30, in _kcf_create
tracker.init(frame, tuple(bounding_box))
TypeError: integer argument expected, got float
I am trying to debug this problem but I think I am stuck. I am using yolo as my detection algorithm. Thank you sir.
It's giving error like this : Vehicle-Counting-master/detectors/yolo/yolo_detector.py", line 20, in get_bounding_boxes
net = cv2.dnn.readNet(os.getenv('WEIGHTS_PATH'), os.getenv('CONFIG_PATH'))
cv2.error: OpenCV(4.1.0) /io/opencv/modules/dnn/src/dnn.cpp:3780: error: (-2:Unspecified error) Cannot determine an origin framework of files: in function 'readNet'
Please help me to resolve this
How to Track multiple Objects. It is showing that cv2.cv2 has not attribute TrackerCSRT_create.
Please help
Hey, is it correct that .env files are only usable on Linux based distributions?
Is there a way to use this on Windows - e.g. you could determine the os at the start and then just use default variables instead of the os.getenv command. If needed, I or other users could switch these out. It would be great for a more flexible usage regarding OS.
Thanks.
Hi
I have tried by cloning your repository.... getting erros as follows:
(i) If i run "python -m main" in terminal --> ImportError: No module named detectors.detector
(ii) If i run "python3 main.py" in terminal --> ModuleNotFoundError: No module named 'dotenv'
Thanks in advance
Hi!
I believe that you need to update your requirements file. It didn't work for me with opencv-contrib-python==4.0.0.21, but did work with opencv-contrib-python==4.1.0.25
Hi, I encounted new problem. When I used 'tfoda' to detect object of interest, an error was noted as follows. How can I do next to solve, and I cannot determine whether my pretrained model downloaded from 'https://github.com/opencv/opencv/wiki/TensorFlow-Object-Detection-API#use-existing-config-file-for-your-model', is wrong. I don't find weight and config file, could you please help me to continue?
Thanks in advance.
How can we add a custom detector to this module? I have a faster RCNN based detector which I added as a python file having the exact get_bounding_boxes() function which returns the bounding boxes, scores and the classes. I added it in the detectors directory but when I run the main.py file it gives:
"ERROR : Invalid detector model, algorithm or API specified (options: yolo, tfoda, detectron2, haarcascade) {'label': 'INVALID_DETECTION_ALGORITHM'}"
I checked in the .env file but I cannot seem to find what path may be added for the detector to run my fasterrcnn.py file instead of the given yolo.py, tfoda.py etc.
Could you help me out with this one?
Traceback (most recent call last):
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\nicholaskajoh-ivy-137884b\main.py", line 21, in
init_logger()
File "D:\nicholaskajoh-ivy-137884b\util\logger.py", line 59, in init_logger
file_formatter = CustomJsonFormatter('(created) (logger) (level) (message)')
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pythonjsonlogger\jsonlogger.py", line 112, in init
logging.Formatter.init(self, *args, **kwargs)
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\logging_init.py", line 576, in init
self.style.validate()
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\logging_init.py", line 429, in validate
raise ValueError("Invalid format '%s' for '%s' style" % (self._fmt, self.default_format[0]))
ValueError: Invalid format '(created) (logger) (level) (message)' for '%' style
Does anyone faced with this issue when trying to run the program?
after all the setup then run the code we found video processing too slow. how can improve the video processing or video speed rate
Can you tell me what the "coco_interest.classes.txt" looks like ?
or Where can I get this file?
if I consider object approaching towards the ref line as IN, How can I modify so that I can get the count of object going OUT of the ref line
hi, thanks for your job , when I use this demo , The process of video detection and counting is very low! FPS is very low。。。 why? And I found it nothing to do with gpu。。。。My gpu is 2080TI。 I tried to reduce the detection interest category, but it can't useful
So could you help me solve this problem? Thank you very much
Hello! In debug mode after running for sometime your software halts and exits with the following error on the terminal.
OpenCL error CL_INVALID_COMMAND_QUEUE (-36) during call: clEnqueueNDRangeKernel('tmm', dims=2, globalsize=640x10x1, localsize=64x1x1) sync=true
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.1.0) Error: Unknown error code -220 (OpenCL error CL_INVALID_COMMAND_QUEUE (-36) during call: clEnqueueMapBuffer(handle=2F5917C8, sz=1443360) => 00000000) in cv::ocl::OpenCLAllocator::deallocate_, file C:\projects\opencv-python\opencv\modules\core\src\ocl.cpp, line 4881
Please have a look at it. Thanks !!
Dear Author,
When executing this vehicle counter, vehicle ID is in hex format. How do I use normal IDs like 1,2,3.. etc instead of this format to track the same. Could you please suggest a workaround ?
Also, I am trying to use this approach to just track the vehicle in a ROI and do not want to count at the moment. I have excluded the counting part (attempt_count module) and just based on the mctf threshold I am deleting (del self.blobs[blob_id]) or just retaining the blob as such (self.blobs[blob_id] = blob) inside the loop blob_list. Is there any thing else I just should be paying attention to so the IDs are retained and tracked ?
Thank you !
Hello everyone and thank you @nicholaskajoh for this amazing repo. Wondering has anyone implemented this using the yolov5 object detector? The reason I ask is because I'm a little confused about the part mentioned to "Create a .env file (based on .env.example) in the project's root directory and edit as appropriate." How would that look like for a yolov5 model?
Regards,
Abu
TypeError: expected str, bytes or os.PathLike object, not NoneType
(ivy) PS C:\Users\Administrator\ivy> python main.py
Traceback (most recent call last):
File "main.py", line 143, in
init_logger()
File "C:\Users\Administrator\ivy\util\logger.py", line 55, in init_logger
pathlib.Path(log_files_directory).mkdir(parents=True, exist_ok=True)
File "D:\ProgramData\Anaconda3\envs\ivy\lib\pathlib.py", line 983, in new
self = cls._from_parts(args, init=False)
File "D:\ProgramData\Anaconda3\envs\ivy\lib\pathlib.py", line 640, in _from_parts
drv, root, parts = self._parse_args(args)
File "D:\ProgramData\Anaconda3\envs\ivy\lib\pathlib.py", line 624, in _parse_args
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Love the project, works great for the most part. However, I have seen many times during my testing that two main things happen and I am not sure how/why:
Both of these issues lead me to believe that the detector is not updating the tracker all of the time. I have the detection interval set to 5 and the tracking failures set to 15. The tracking failures never seem to get to 15. But, if a detection happens every 5 frames and there is no car anymore, why does the tracker keep a bounding box hanging around for a very long time? It seems to me that if the detector does not detect a car anymore, the bounding box/tracker can be removed? I know we have to be careful here because the detector could normally miss a detection every so often and the goal of the tracker is to keep tracking when this happens but it seems that there should be a timeout or something where after several missed detections, we can then go ahead and remove?
These two issues are causing some cars to be missed when crossing the line.
Also, I have tried both KCF and CSRT trackers along with both SSD and YOLO detectors, in many different combinations and the issues seem to still happen which tells me that the issue isn't with the tracker or detector but rather, the code that ties the two together.
Thoughts? Thanks!
Hi,
I have gone through document. It is really interesting. I am unable tracker module. I am getting the following error.ImportError: cannot import name 'izip_longest'. Can you help me to proceed further
Hi, Can anyone help me to solve this out?
Traceback (most recent call last):
File "Vehicle_Counting.py", line 168, in
vehicle_counter = VehicleCounter(frame, detector, tracker, droi, args.showdroi, mcdf, mctf, di, args.clposition)
File "Vehicle_Counting.py", line 38, in init
initial_bboxes = get_bounding_boxes(droi_frame, self.detector)
File "/content/drive/MyDrive/Colab Notebooks/summer1/Vehicle-Counting/detectors/detector.py", line 4, in get_bounding_boxes
return yolo_gbb(frame)
File "/content/drive/MyDrive/Colab Notebooks/summer1/Vehicle-Counting/detectors/yolo/yolo_detector.py", line 16, in get_bounding_boxes
net = cv2.dnn.readNet(os.path.join(location, 'yolov3.weights'), os.path.join(location, 'yolov3.cfg'))
cv2.error: OpenCV(4.1.0) /io/opencv/modules/dnn/src/darknet/darknet_importer.cpp:214: error: (-212:Parsing error) Failed to parse NetParameter file: /content/drive/MyDrive/Colab Notebooks/summer1/Vehicle-Counting/detectors/yolo/yolov3.weights in function 'readNetFromDarknet'
Hi nicholas,
Which IDE are you using for this code?
Best Regards,
PeterPham
I'm new to this can u help me to run this code.when I download the zip.i got many errors .like path not set.I changed the path of video to my respective path but again showing errors.
when i ENABLE_GPU_ACCELERATION=True, processing my video is running slow. My GPU is Nvidia RTX 2080 TI.
hi, thanks for your great job. When I used tfoda for vehicle detection and counting, I encounted some problems that maybe need your help. I want to how to get the file 'coco.classes.txt' and 'coco_interest.class.txt'.
Thanks a lot in advance.
This ivy project is very good!
everyone says that SORT is faster than KCF.
But in my another project that i used Yolo + SORT, i found that the KCF in this repo is faster than SORT
Why is that?
Hi, I'm trying to run your project and followed the instruction in setup but can't seem to get it to work. Apparently, I still needs to get the pretrained Yolo3 weights from another source.
So I suggest you state it in the setup and add a source to the weight as well.
I think it can be gotten from by running wget https://pjreddie.com/media/files/yolov3.weights
Just to be sure, is it the same weight you used ?
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.