thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.08k forks source link

Is there any way to use this without OpenCV? #26

Closed abagshaw closed 7 years ago

abagshaw commented 7 years ago

I'm trying to use this but I'd really rather use this without OpenCV - is that possible?

thtrieu commented 7 years ago

PIL or skimage can be great substitutions, but all require modifying source code. You may do this yourself (hint: all code involves processing images is in ./net/yolo/test.py) or I'll do it, but there would be no time guarantee though.

Great suggestion btw.

abagshaw commented 7 years ago

That makes sense - if I have some time I might have a go at it. Maybe I'm wrong - but it appears that cv2 is imported and used in more files than just ./net/yolo/test.p, for example ./utils/im_transform.py and ./net/help.py?

thtrieu commented 7 years ago

You're right. ./utils/im_transform.py is for training data augmentation, while ./net/help.py is for camera demonstration. I supposed you just want to use the trained weights for something else.

abagshaw commented 7 years ago

You're right - I'm not interested in training my own data. Ok thanks for that information - if I get anywhere with this I'll let you know, thanks!

lunardog commented 7 years ago

Related to the above, it seems the conda package for opencv2 conflicts with python 3.


The following specifications were found to be in conflict:
  - opencv 2.4.11*
  - python 3.5*
Use "conda info <package>" to see the dependencies for each package.

What is the best way to get the current codebase running? I'm trying compiling OpenCV, but feels like an overkill for the few places it's used.

thtrieu commented 7 years ago

Agreed. I am working on abstracting away image I/O. In the meantime, please change to PIL or some equivalent as suggested above.

bmabey commented 7 years ago

@lunardog The menpo channel has a compatible python 3 opencv package. A conda env file like the following may work:

name: darkflow
channels:
   - menpo
dependencies:
  - python=3.5
  - opencv3
  - numpy
  - scipy
  - notebook
  - pillow
  - pip:
    - tensorflow
abagshaw commented 7 years ago

Any updates on this? Has anyone managed to get a lighter image library working with darkflow?

thtrieu commented 7 years ago

Hey @abagshaw I am sorry I was too busy, at least in the next 01 month. There is this guy @ryansun1900 who understands the code in this repository very well. Maybe he can help you out.

Prakash19921206 commented 7 years ago

if you don't mind, may i know why u don't want to use opencv? i think its great library..., it has UMat object(Transparent API), which makes use of graphic card for processing. in C++ it is:

UMat frame;  //note if you use UMat and don't have graphic card, then image will be processed using processor, else it will be processed using graphic card (Thanks to T-API)
VideoCapture cap(0);
cap>>frame;  //overloaded operator, copies image directly to UMat object from web camera

with few syntax changes, above code is almost same in python. also not to mention it also has ffmpeg integration, so u can use IP cameras directly

VideoCapture cap("IP_ADDRESS"); //C++ ` camera = cv2.VideoCapture('IP_ADDRESS') #Python`

abagshaw commented 7 years ago

To be honest, I've kind of warmed up to OpenCV the more I've used it over the past little while. The reason why I was wanting to switch to something else is that it's a fairly hefty library to include when it's only being used in a few places for image transformations and drawing predictions (I suppose it's being used a little more now with the video integration).

Ideally if there was some other lighter and leaner image processing library that can handle the same np.ndarray that OpenCV uses than that could be used for the core image transformations. That way if someone is using darkflow only for predicting images and no other fancy stuff (camera, video, etc.) they don't have to install the whole OpenCV library. Honestly though this should be fairly low on the priority list...if it's on the priority list at all. Getting YOLO 9000 would be much more exciting for me :)

andreapiso commented 7 years ago

You could do everything in tensorflow. Tensor are basically equivalent to numpy arrays and tensorflow does have tensors to hold images and methods to do image processing stuff (resize, pad , crop, etc...) also this would allow you to use the tensorflow input queue pipeline...