arunponnusamy / cvlib Goto Github PK
View Code? Open in Web Editor NEWA simple, high level, easy to use, open source Computer Vision library for Python.
Home Page: http://arunponnusamy.com/cvlib/
License: MIT License
A simple, high level, easy to use, open source Computer Vision library for Python.
Home Page: http://arunponnusamy.com/cvlib/
License: MIT License
I have a pile of images and I want to find and exclude all images that contain any bit of text. I already used this library to exclude images containing people so I wonder how to adjust the library to add the text object as well.
I am not interested in any OCR and such, just the presence of a new bounding box with text description on it.
im having an issue with tensorflow-gpu
Originally posted by @ConceptCodes in #9 (comment)
When I try to recognize a picture taken with a wide-angle lens, there are many objects that cannot be recognized
Error:
output_layers = [layer_names[i[0]-1] for i in net.getUnconnectedOutLayers()]
After:
output_layers = [layer_names[i - 1] for i in net.getUnconnectedOutLayers()]
Hello @arunponnusamy , Thank you for the great lib, I wonder if limiting the dnn output to one face would make the detection a bit faster?
Detection time is ~0.3 on my core i5 460M @2.53GHz
Any tips for boosting the detection time?
Thanks
I run this below code. it does not detect objects. detecting window also not working. please anyone help me
import cv2
import matplotlib.pyplot as plt
import cvlib as cv
import urllib.request
import numpy as np
from cvlib.object_detection import draw_bbox
import concurrent.futures
url='http://192.169.1.4/cam-hi.jpg'
im=None
def run1():
cv2.namedWindow("detection", cv2.WINDOW_AUTOSIZE)
while True:
img_resp=urllib.request.urlopen(url)
imgnp=np.array(bytearray(img_resp.read()),dtype=np.uint8)
im = cv2.imdecode(imgnp,-1)
bbox, label, conf = cv.detect_common_objects(im, confidence=0.6, model="yolov3-tiny")
print(bbox, label, conf)
im = draw_bbox(im, bbox, label, conf)
cv2.imshow("live transmission",im)
key=cv2.waitKey(5)
if key==ord('q'):
break
cv2.destroyAllWindows()
if name == 'main':
print("started")
with concurrent.futures.ProcessPoolExecutor() as executer:
f1= executer.submit(run1)
In am trying to detect a face in the image, which has single face. I exact copied your code. But the accuracy is very low. The length of list of faces is 7 (I dont know why its length is 7.).Moreover, see the result in the attached image. It is showing 2 rectangles on facial areas. Why it is not showing up to mark results, am I missing something?
The complete list is in a table here: https://pjreddie.com/darknet/imagenet/#Pre-Trained-Models that includes darknet53 and others. I can do a fork and I will submit a merge request when I get it working. Thanks
Hello,
I am currently using your implementation against a webcam, and currently its detecting both male and female as MALE.
Is this expected?
Cheers!
As of rather recently I am unable to use object_detection, whereas everything else seems to work rather fine.
It boils down to that error message:
Traceback (most recent call last):#################################################################################### |
File "detector_mine.py", line 35, in <module>
bbox, label, conf = cv.detect_common_objects(rect_img, confidence=0.75, enable_gpu=True')
File "/home/user/.local/lib/python3.8/site-packages/cvlib/object_detection.py", line 135, in detect_common_objects
outs = net.forward(get_output_layers(net))
File "/home/user/.local/lib/python3.8/site-packages/cvlib/object_detection.py", line 29, in get_output_layers
output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()]
File "/home/user/.local/lib/python3.8/site-packages/cvlib/object_detection.py", line 29, in <listcomp>
output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()]
IndexError: invalid index to scalar variable.
It runs fine on my old Win10/11 installation from a couple of months ago, however accessing the same script from a WSL machine on the exact same PC results in the error above. I'm also getting the same from a new macOS setup.
Hey, first of all, thanks for the great lib. I've been playing around with face detection on the Mc-Master Pain Shoulder dataset to extract bounding boxes and am facing some issues.
In some cases, detect_faces returns multiple bounding boxes. No big deal, except that it gives a greater confidence to the wrongly detected background parts for no apparent reason.
Any idea why this could be happening ? Or how I can detect mishaps like this one ? If you have any idea how I can fix this let me know, I'd be glad to contribute.
Thanks
In the cvlib package, is there a method to use file shape_predictor_68_face_landmarks.dat
?
The current script assumes the yolo weights are present in the default user directory inside ~cvlib
. This causes a problem if we run the script from a detached daemon. I'd like to suggest a config
path which specifies the path to read the yolo configs from.
Hello,
First of all I am beginner in this field and thanks in advance.
I have just tried the same code you provided but, the picture I am getting as an output is the same is the input. there are no squares indicating objects.
The output I get is: (the arrays are empty so it seems nothing gets detected)
(base) Davids-MacBook-Pro:Object_Detection davidlopez$ cd /Users/davidlopez/Documents/Object_Detection ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /anaconda3/bin/python /Users/davidlopez/.vscode/extensions/ms-python.python-2019.1.0/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 56195 /Users/davidlopez/Documents/Object_Detection/Obj_detection.py
Using TensorFlow backend.
[] [] []
my code is:
import cvlib as cv
from cvlib.object_detection import draw_bbox
import sys
import cv2
image = cv2.imread('varios1.jpg')
bbox, label, conf = cv.detect_common_objects(image)
print(bbox, label, conf)
out = draw_bbox(image, bbox, label, conf)
cv2.imshow("object_detection", out)
cv2.waitKey()
cv2.imwrite("object_detection.jpg", out)
cv2.destroyAllWindows()
I need to train a custom face detector model. What dataset have you used to make face detector part of this model?
Is it a public dataset?
if it's a public dataset, can you share the link of that?
if anyone is interested, I have this currently running in Colab: https://github.com/nyck33/anonymous_face/blob/master/profile_faces_dlib_cnn_video.ipynb
It should work but I'll update later.
i tried to do 01 Motion Detection with Webcam.py but i have error. please help me
(base) C:\Users\vuhun>cd desktop
(base) C:\Users\vuhun\Desktop>Motion Detection with Webcam.py
[ WARN:0] videoio(MSMF): OnReadSample() is called with error status: -1072875855
[ WARN:0] videoio(MSMF): async ReadSample() call is failed with error status: -1072875855
[ WARN:1] videoio(MSMF): can't grab frame. Error: -1072875855
[ WARN:1] videoio(MSMF): can't grab frame. Error: -2147483638
[ WARN:1] videoio(MSMF): can't grab frame. Error: -2147483638
[ WARN:1] terminating async callback
(base) C:\Users\vuhun\Desktop>
Hi, I'm working in a project using face-recognition package but in cpu it's really slow so instead of doing the face detection with that I wanted to use this one buuut now I don't know how to compare the faces.
face_recognition.compare_faces(saved_faces, faces, tolerance)
So this is where I use the cvlib detection and compare using face_recognition but never makes a positive.
I'm really new with this, so I anyone could help me understand how to or even if I could make it work
any documentation how to run this on a GPU?
Hello, do you plan to release a version which uses the much faster yolov4?
And when could I expect it?
hey @arunponnusamy I installed cvlib via pip and try a simple code like
import cvlib as cv
import cv2
cap=cv2.VideoCapture("std_camera.mp4")
while True:
ret,image=cap.read()
faces, confidences = cv.detect_face(image)
print(faces)
print(confidences)
if cv2.waitKey(1) & 0xFF==ord('q'):
break
cv2.release()
cv2.destroyAllWindows()
but it has an attribute error logging module 'cvlib' has no attribute 'detect_face'
I also tried it with python3 but still got that error.
I am using cvlib package in my python project. If I run python file in Linux command line its work fine without any error.
I want make it executable one file for Linux. I used PyInstaller packaged it. When run its throwing
The 'cvlib' distribution was not found and is required by the application
I am using :
Python : 3.6
PyInstaller : 3.5.
Cvlib: 0.2.2
Flask: 1.1.1.
I am trying to run object_detection_webcam.py.
[ WARN:0] videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:0] videoio(MSMF): async ReadSample() call is failed with error status: -1072875772 [ WARN:1] videoio(MSMF): can't grab frame. Error: -1072875772 Could not read frame
It is unable to read the frame. Could you help me understand what went wrong?
Thanks.
import cvlib
then...
AttributeError: module 'tensorflow.python.keras.backend' has no attribute 'get_graph'
What should I do?
Hi,
I would like to know how can I train the yolov3 on my data.
Add requirements.txt so that opencv-python and tensorflow is automatically installed when contributing.
I want to find a face of given persons that are already fed using their face images
That is , if I gave a photo of obama and run a video (in videocapture) that contains Obama , then it have to draw a rectangle around the face and write a name tag in the rectange corner
I able to do this using face_recognation ilbrary but don't know how to do this using cvlib ?
Sometimes the bounding boxes returned by the detect_faces method are invalid.
I'm having a issue where some bounding boxes have the same start and end x (zero total width) and sometimes the start_y is LARGER than end_y.
Any idea why this might be? These boxes are clearly not as intended
Thanks for this useful library. I'd love to see tiny yolo integration too
When I try to use a function, do i get the error:
Traceback (most recent call last):
File "E:/python/test-object-detectie1.py", line 4, in
bbox, label, conf = cv.detect_common_objects('object_detection_input.jpg')
File "C:\Users\MyUserName\AppData\Local\Programs\Python\Python310\lib\site-packages\cvlib\object_detection.py", line 77, in detect_common_objects
Height, Width = image.shape[:2]
AttributeError: 'str' object has no attribute 'shape'
Can someone help me?
Is there a list with all classes and thier colors? Like, Person -> violet
I use python 3.6.2 and when i run this code import cvlib
, it's has an error, i have installed all the packages recommend but it's doesn't work.
Using TensorFlow backend.
Traceback (most recent call last):
File "/home/pocpon/anaconda/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/pocpon/anaconda/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/pocpon/anaconda/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/pocpon/anaconda/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/pocpon/anaconda/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcudnn.so.7: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pocpon/cvlib/cvlib/__init__.py", line 8, in <module>
from .gender_detection import detect_gender
File "/home/pocpon/cvlib/cvlib/gender_detection.py", line 4, in <module>
from keras.utils import get_file
File "/home/pocpon/anaconda/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/home/pocpon/anaconda/lib/python3.6/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/home/pocpon/anaconda/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/home/pocpon/anaconda/lib/python3.6/site-packages/keras/backend/__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "/home/pocpon/anaconda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "/home/pocpon/anaconda/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/pocpon/anaconda/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/pocpon/anaconda/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/pocpon/anaconda/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/pocpon/anaconda/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/pocpon/anaconda/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/pocpon/anaconda/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/pocpon/anaconda/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcudnn.so.7: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
`
```
Hi,
In addition to detecting objects from a video, I want to count. I'm following the code here :
https://github.com/arunponnusamy/cvlib/blob/master/examples/object_detection_webcam_yolov3_tiny.py. Is that possible with cvlib?
The following is what I tried for vehicle counting.
vehiclesum.append(label.count('car') + label.count('truck') + label.count('motorcycle') + label.count('bus'))
Hello, I am doing a simple test; I take a picture with 5 faces, each in a different position, then try to detect the faces, but the "faces" list is empty.
Here is the image I used: https://drive.google.com/open?id=1v8C-SP0nsZ4aLuyLu8f3tjA7uI6JaQ2R
This is the code:
import cvlib as cv
import cv2
imgColor = cv2.imread('D:/images/rostro_poses.jpg', -1)
faces, confidences = cv.detect_face(imgColor)
for face,conf in zip(faces,confidences):
(startX,startY) = face[0],face[1]
(endX,endY) = face[2],face[3]
cv2.rectangle(imgColor, (startX,startY), (endX,endY), (255,0,0), 2)
cv2.imshow('something', imgColor)
Thanks for the help.
C:\xampp\htdocs\faceD>python cvlib.py
Using TensorFlow backend.
WARNING:tensorflow:From C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
2019-07-15 20:47:44.195976: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
WARNING:tensorflow:From C:\ProgramData\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use rate
instead of keep_prob
. Rate should be set to rate = 1 - keep_prob
.
WARNING:tensorflow:From C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
Traceback (most recent call last):
File "cvlib.py", line 12, in
import cvlib as cv
File "C:\xampp\htdocs\faceD\cvlib.py", line 42, in
face, confidence = cv.detect_face(frame)
AttributeError: module 'cvlib' has no attribute 'detect_face'
[ WARN:0] terminating async callback
when you import cvlib, you get following exception:
Exception has occurred: ImportError
cannot import name 'formatargspec' from 'inspect' (...\scoop\apps\python\current\Lib\inspect.py)
File ".......py", line 5, in
import cvlib as cv
ImportError: cannot import name 'formatargspec' from 'inspect' (...\scoop\apps\python\current\Lib\inspect.py)"
Hi there.
I am trying to run the CVLib and its examples code in pycharm and downloading the cvlib through pip3.exe.
but I got struck while installing tensorflow.
error-
"could not find a version that satisfies the requirement tensorflow python 3.7"
could you please advise me regard this?
I am using the object detection script, which searches for ~80 objects in the image. Is it possible to refine this to only search for selected objects?
I made a Colab ready notebook with changes to face_detection.py
in examples folder if anyone is interested:
Unfortunately I only know how to output as .avi
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.