jolibrain / deepdetect Goto Github PK
View Code? Open in Web Editor NEWDeep Learning API and Server in C++14 support for Caffe, PyTorch,TensorRT, Dlib, NCNN, Tensorflow, XGBoost and TSNE
Home Page: https://www.deepdetect.com/
License: Other
Deep Learning API and Server in C++14 support for Caffe, PyTorch,TensorRT, Dlib, NCNN, Tensorflow, XGBoost and TSNE
Home Page: https://www.deepdetect.com/
License: Other
Regression tasks need to be supported in addition to supervised tasks with a finite number of labels.
Applications range from multi-target prediction to image rescaling with deep learning.
Subtasks:
Eigen3 crashes on dimension error when computing the confusion matrix of a supervised classifier if nclasses
is below the true underlying number of classes.
Some theoretical frameworks, and typically neural nets, only take reals or integer as input. The CSV input connector should convert categorical string data to integers (one-hot-vector or other) automatically, and spit out the mapping to the user/caller as necessary.
This is an issue on long input transformations such as building the database of images prior to calling on Caffe for training. Solution is a flag within the processing loop of the input connector on long operations.
There's a PR to Caffe here: BVLC/caffe#1890
Requires some empirical testing after merging.
@beniz is there currently a way to use authentication in deepdetect, for example something like basic http authentication, i.e. special http header with username:password via https, or anything else? (btw: many thanks for this fantastic tool!)
Requesting f1
measure in output connector should allow to get the full confusion matrix back, when needed, through an additional measure option, e.g. cmatrix
.
This is an anchor post on how to build for gcc5 with new ABI, which is the recommended option on Ubuntu 15.10.
Warning: Ubuntu 15.10 has buggy libraries that are not correctly compiled with gcc5, requiring some of the kung-fu below. I have filed bug reports, will update when fixes occur.
curlpp
is wrongly compiled currently on Ubuntu 15.10 and will faill due to ABI mismatch. I've open a bug report but in the meantime the fix is to rebuild curlpp from https://github.com/datacratic/curlpp:sudo apt-get remove libcurlpp0
git clone https://github.com/datacratic/curlpp
cd curlpp
./autogen.sh
./configure --prefix=/usr --enable-ewarning=no
make
sudo make install
libcppnetlib0
is also wrongly built on Ubuntu 15.10, with bug report and the fix is here again to build our own version (don't do it from github repository as it appears to be messy, follow instructions below with version from https://launchpad.net/ubuntu/+source/cpp-netlib/0.11.1+dfsg1-4):wget https://launchpad.net/ubuntu/+archive/primary/+files/cpp-netlib_0.11.1%2Bdfsg1.orig.tar.gz
tar xvzf cpp-netlib_0.11.1+dfsg1.orig.tar.gz
cd cpp-netlib-0.11.1-final
mkdir build
cd build
cmake ..
make
sudo make install
That's it, deepdetect builds fine from me and all tests pass cleanly.
As explained in http://nerdfortress.com/2008/09/19/linux-xfs-does-not-support-direntd_type/ XFS does not support direntd and everything appears as a regular file.
This one post http://stackoverflow.com/a/29094555 also reports possible workaround by testing for DT_UNKNOWN and using lstat
on every file.
There is a weird leak behavior with Caffe:
First set of investigations appears to rule out the Caffe's net destruction, and first valgrind pass does not reveal much yet.
I have tried the step-by-step example in the doc for setting up an image classifier (http://www.deepdetect.com/tutorials/imagenet-classifier/) based on googlenet (successfull dede installation incl run test on commit 66ff4af). I am successfull in setting up the service ({"status":{"code":201,"msg":"Created"}}), but I am failing in tests as follows:
In: curl -X POST "http://localhost:8080/predict" -d "{"service":"imageserv","parameters":{"input":{"width":224,"height":224},"output":{"best":3}},"data":["http://i.ytimg.com/vi/0vxOhd4qlnA/maxresdefault.jpg"]}"
Out: {"status":{"code":500,"msg":"InternalError","dd_code":1007,"dd_msg":"./include/caffe/layer.hpp:389 / Check failed (custom): (ExactNumTopBlobs()) == (top.size())"}}
Comments:
Any ideas why I am failing the googlenet example?
Current CSV connector loads CSV file into memory. For large datasets with millions or billions of rows and potentially many thousands of features, this is impractical.
Branch large-scale-csv
holds the following features, unlocking the training from large CSV files independently from available memory:
Important: the shuffle
component of the CSV input connector is not available when using the above database-based storage of large CSV datasets. A direct consequence is that the dataset must be pre-shuffled and that the training and testing files must be prepared before being passed to the DeepDetect CSV input connector.
I get an aborted (core dumped)
message every so often and Deepdetect stops. I am using it to tag images with the imagenet model
Sometimes the issue is obvious such as a very large image or a dead link, but often it is just a normal image for no discernible reason.
Hi,
Great job on making Caffe as a service. I wanted to find out a few more details about the text classification capabilities in Deep Detect. Are you using a embed layer (word2vec or bag of words)? Can you point me to the relevant caffe layers and any article references?
Thanks!
V
Hi community,
I would like to implement binary hash code search application as it is written in this paper, 'Deep Learning of Binary Hash Code' to enable fast image similarity match. Specifically, I want to use googlenet and achieve the similarity search with elasticsearch on aws EC2.
Since we need to take the feature vector from the network as the hash code, I believe we need to output value from the hidden layer (One layer before the final output softmax layer) in convolutional network, but deepdetect library currently does not support the output of the values.
Please kindly help me if anyone have done this before.
I appreciate any kind of supports.
Thank you very much for providing this awesome library.
Masaki
See short discussion here, tensorflow/tensorflow#85
In fact, ability to save computation graph models as protobuffers then read them up and providing data at runtime, not too different than with Caffe.
The API has been designed to absorb more libraries, and this is a nice test case that should allow to expand to more complex models such as seq2seq without breaking compatibility through API.
Additional relevant doc:
Adding control of convolutional neural network architecture through a template for Caffe + API parameters (i.e. similar to the `"template":"mlp" and 'layers' parameters).
Typically, layers=["2CR32","2CR64","1000"]
should create a convolutional net with 2 consecutive 32 filters convolutional layers, followed by relu and pooling, then 2 consecutive 64 filters convolutional layers, then a full connected layer of 1000 neurons.
I am trying to convert the clothing dataset to a model compatible wth TensorFlow using https://github.com/ethereon/caffe-tensorflow.
I am getting the following error:
"Error encountered: Cannot determine dimensions of data layer.
See comments in function shape_identity for more info."
The comment on the shape_identity function says:
# Caffe infers the dimensions of the data from the source (eg: LMDB).
# We want to avoid reading datasets here. Fail for now.
# This can be temporarily fixed by transforming the data layer to
# Caffe's "input" layer (as is usually used in the "deploy" version).
# TODO: Find a better solution for this.
Can someone suggest the necessary changes in deploy.prototxt file?
A Python API client, to ease the interaction with the API.
Two pieces:
As a follow up to #1, see https://github.com/beniz/deepdetect/issues/1#issuecomment-137553339
Steps:
Discussing whether this does use the scheme recommended in BVLC/caffe#881 (comment) or some other (simpler ?) way that requires patching Caffe, might be required.
(Also, multi-target regression (and classification) do not mix well with the image
connector typically, that uses the repository name as the single class (no regression supported yet) label.)
Providing AMI is a good idea to ease deployment for some users.
Related links of interest:
- Deprecated Caffe AMI: https://github.com/BVLC/caffe/wiki/Ubuntu-14.04-ec2-instance
- Newly contributed Caffe AMI (that includes Torch): http://blog.titocosta.com/post/110345699197/public-~ec2-ami-with-torch-and-caffe-deep-learning
- Another Caffe AMI and Docker: BVLC/caffe#1092 (comment)
- An AMI for deep learning, and that contains Caffe: https://www.kaggle.com/forums/f/208/getting-started/t/11505/an-aws-ami-mainly-for-deep-learning
After a long wait, the official AMIs with support for Caffe, XGBoost and Tensorflow backends are available for both GPU and CPU:
See https://deepdetect.com/products/ami/ for thorough documentation.
@beniz: is there a straighforward way to finetune a CaffeNet using current deepdetect? I could not find in the API (http://www.deepdetect.com/api/#launch-a-training-job) anything related to "-weights" in the typical Caffe command line for finetuning 'caffe train -solver ... -weights ...'
Hello.
I've built DeepDetect docker image using kaixhin/cuda
(https://hub.docker.com/r/kaixhin/cuda/~/dockerfile/ ) as base image. Here https://gist.github.com/skeeph/a1722053872552c62594 is my Dockerfile. I've built it without any errors.
After that, I create image classification service from tutorial. It works properly, with gpu=false
.
But if i try to use gpu on prediction stage, by stating gpu=true
in service creating api call, i have next situation. Trying to classificate any image, i have error
{ "status": { "code": 500, "dd_code": 1007, "dd_msg": "src/caffe/common.cpp:142 / Check failed (custom): (error) == (cudaSuccess)", "msg": "InternalError" } }
I have server with installed NVidia Tesla K80.
What is my error? Is it possible to use gpu on prediction?
Thanks.
I was trying to build a system using the pretrained model available here: http://www.deepdetect.com/applications/model/
I downloaded the .tar.gz2 files for the clothing class. I then tried to build a simple python script using caffe to use the files provided with the pretrained model. But when I was creating the caffe Classifier class I faced a very strange error.
This is how I created the classifier class in caffe using Python,
network_model = "./deploy.prototxt"
pretrained_network = "./model_iter_300000.caffemodel"
net = caffe.Classifier(network_model,pretrained_network,mean=np.load("mean.npy"), raw_scale=255, channel_swap=(2, 1, 0), image_dims=(256,256))
The deploy.prototxt and the model_iter_300000.caffemodel are the files which are present inside the .tar.gz2 file
The mean.npy file is created using the mean.binaryproto file present inside the .tar.gz2 file.
and the error that I was getting was
I1130 08:07:26.102867 4413 net.cpp:248] Memory required for data: 1764597888
Traceback (most recent call last):
File "predict.py", line 32, in
mean=np.load("mean.npy"), raw_scale=256, channel_swap=(2, 1, 0), image_dims=(256,256))
File "/home/caffe/python/caffe/classifier.py", line 29, in **init**
in_ = self.inputs[0]
IndexError: list index out of range
Can any one help me with this strange error?
Thanks
I am trying to use model from https://github.com/GilLevi/AgeGenderDeepLearning
Everything starts normally but when I send request for prediction it fails with error:
INFO - Ignoring source layer data
dede: /usr/include/boost/smart_ptr/shared_ptr.hpp:653: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = caffe::MemoryDataLayer<float>; typename boost::detail::sp_member_access<T>::type = caffe::MemoryDataLayer<float>*]: Assertion `px != 0' failed.
INFO - Ignoring source layer lossAborted (core dumped)
This is the discussion / report ticket for the set of models available here:
http://www.deepdetect.com/applications/text_model/
These models range from sentiment analysis to ad blocking from just reading a URL. See full instructions on the page above.
Batch normalization significantly lowers training time, http://arxiv.org/pdf/1502.03167v3.pdf
This is to be based on Caffe PR BVLC/caffe#1965 unless some other implementation surfaces.
Two steps:
This is the discussion / report ticket for the set of models available here:
http://www.deepdetect.com/applications/model/
They include classification or clothes, furnitures, gender, planes, cars, etc... See full list and instructions on the page above.
Typically, starting dede
defaults on localhost:8080
and in some cases querying localhost
from API returns nothing. Switching to 127.0.0.1
clears the problem.
This issue in case it is a possibility that the binding issue comes from deepdetect embedded web server (based on boost).
Hi,
I've identified an issue that causes deepdetect to crash. It seems requests to an invalid domain cause an unhandled exception. This is similar to #45 but the issue is separate.
I'm using a recent build of deepdetect (Jan 11th, commit 6116a0c) on Ubuntu, which includes the fix that was made for #45
Request to a valid domain with a valid image -> good reply, returns with code 200:
curl -X POST "http://host.com:8080/predict" -d "{\"service\":\"imgnet\",\"parameters\":{\"input\":{\"width\":224,\"height\":224},\"output\":{\"best\":5}},\"data\":[\"https://upload.wikimedia.org/wikipedia/commons/c/cd/US-NASA-Seal-EO10849.jpg\"]}"
{"status":{"code":200,"msg":"OK"},"head":{"method":"/predict","time":1938.0,"service":"imgnet"},"body":{"predictions":{"uri":"https://upload.wikimedia.org/wikipedia/commons/c/cd/US-NASA-Seal-EO10849.jpg","classes":[{"prob":0.3491594195365906,"cat":"n04548280 wall clock"},{"prob":0.22876758873462678,"cat":"n03706229 magnetic compass"},{"prob":0.14928314089775086,"cat":"n02708093 analog clock"},{"prob":0.07048133760690689,"cat":"n04192698 shield, buckler"},{"last":true,"prob":0.0419003888964653,"cat":"n04355338 sundial"}]}}}
Request to a valid domain with an invalid image url -> returns with code 400
curl -X POST "http://host.com:8080/predict" -d "{\"service\":\"imgnet\",\"parameters\":{\"input\":{\"width\":224,\"height\":224},\"output\":{\"best\":5}},\"data\":[\"https://upload.wikimedia.org/wikipedia/commons/c/cd/US-NASA-Seal-EO108l49.jpg\"]}"
{"status":{"code":400,"msg":"BadRequest","dd_code":1005,"dd_msg":"Service Input Error"}}
Request to an invalid domain -> crashes, unhandled exception
curl -X POST "http://host.com:8080/predict" -d "{\"service\":\"imgnet\",\"parameters\":{\"input\":{\"width\":224,\"height\":224},\"output\":{\"best\":5}},\"data\":[\"https://upload.wikimedia_bad.org/wikipedia/commons/c/cd/US-NASA-Seal-EO108l49.jpg\"]}"
curl: (52) Empty reply from server
[1]+ Aborted (core dumped) nohup ./deepdetect/build/main/dede --host host.com
Thanks for your help with this issue.
Best,
Yann
Dear community
I am trying to create deepdetect server on aws ec2.
When I type this command, ./main/dede -host 0.0.0.0 -port 80
I get this following
DeepDetect [ commit 8080e7b80i999ba444e671780a80fa4d1afdai0 ]
Running DeepDetect HTTP server on 0.0.0.0:80
terminate called after throwing an instance of 'boost::exception_detail::clone_implboost::exception_detail::error_info_injector<std::runtime_error >'
what(): Error binding to socket.
Aborted (core dumped)
Does anyone know how to solve this issue?
I want to allow HTTP access.
Thank you very much for your kind help in advance.
Hi @beniz
Is it possible to implement deepdetect in mobile backend as service?
Error happens when making by following the official building steps:
(Titan X, with drivers and cuda 7.5, cudnn 3 properly installed)
git clone https://github.com/beniz/deepdetect.git
cd deepdetect
mkdir build
cd build
cmake .. -DUSE_CUDNN=ON
make
error messages:
......
NVCC src/caffe/layers/batch_reindex_layer.cu
NVCC src/caffe/layers/contrastive_loss_layer.cu
NVCC src/caffe/layers/slice_layer.cu
NVCC src/caffe/layers/tile_layer.cu
NVCC src/caffe/layers/elu_layer.cu
NVCC src/caffe/layers/silence_layer.cu
NVCC src/caffe/layers/softmax_layer.cu
NVCC src/caffe/layers/cudnn_softmax_layer.cu
NVCC src/caffe/layers/sigmoid_layer.cu
NVCC src/caffe/layers/im2col_layer.cu
NVCC src/caffe/layers/cudnn_conv_layer.cu
NVCC src/caffe/layers/eltwise_layer.cu
NVCC src/caffe/layers/exp_layer.cu
NVCC src/caffe/layers/prelu_layer.cu
NVCC src/caffe/layers/absval_layer.cu
NVCC src/caffe/layers/dropout_layer.cu
NVCC src/caffe/util/math_functions.cu
NVCC src/caffe/util/im2col.cu
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so
/usr/bin/ld: cannot find -lopenblas
collect2: error: ld returned 1 exit status
make[3]: *** [.build_release/lib/libcaffe.so] Error 1
make[2]: *** [caffe_dd/src/caffe_dd-stamp/caffe_dd-configure] Error 2
make[1]: *** [CMakeFiles/caffe_dd.dir/all] Error 2
make: *** [all] Error 2
It seems like caffe is not compiled successfully.
install is too complicated too many dependence. only want c or C++
Full error is :
ERROR - {"code":500,"msg":"InternalError","dd_code":1007,"dd_msg":"basic_string::_S_construct null not valid"}
Original report is beniz/quick_cdiscount#1
This is the integration of PR BVLC/caffe#2364 into Caffe custom build for DeepDetect.
In applications, useful for BOW models. The PR above takes data from CSR database (http://netlib.org/linalg/html_templates/node91.html#SECTION00931100000000000000), which should be automatically computed by input connector.
Spatial Transformers act as a warping / attention mechanism useful for a variety of tasks.
There's a handful of repositories implementing STN for Caffe, see BVLC/caffe#3114
However, STN have not made it into official Caffe yet, so it would need to be added to dd Caffe backend https://github.com/beniz/caffe/tree/master_dd_integ and rebased as Caffe recently changed the distribution of layers in C++ files.
Original paper: http://arxiv.org/abs/1506.02025
Implementations of interest:
Applications of interest:
OpenCV location should be detected by cmake.
A series of applications (e.g. #55) require access to the learnt features captured by a neural net's inner/hidden layers. (hyper-columns are not covered here).
This task requires:
mllib
parameter, e.g. extract_layer
to capture one ore more layer names of interest to be returned by predict
callbinarized
in the output
connectornet
Caffe object in caffelib.cpp
output
connector for unsupervised job (e.g. same task as clustering and returning points' coordinates)Discussion on these matters is always welcome.
Caffe being a fast moving library, some developers may be interested in running with their own version of Caffe.
DeepDetect by default relies on https://github.com/beniz/caffe/tree/master_dd_integ which closely tracks the Caffe master branch and includes a short set of patches, mainly for error handling (see BVLC/caffe#1683) and getting control over some internal variables.
Subtasks:
shared_mutex header is not in gcc 4.8.x and below, yielding compilation error
mlservice.h:30:24: fatal error: shared_mutex: No such file or directory
#include <shared_mutex>
An alternative would be to rely on boost shared_mutex instead.
Hi @beniz ,
faster RCNN like https://github.com/rbgirshick/py-faster-rcnn is a very useful application. It's implemented and trained in Caffe framework.
Do you have a plan to implement it in deepdeteect?
Thanks,
Current input connectors include CSV and images. This issue adds the support for text, and the ability to train supervised neural networks on arbitrary text collections.
Main subtasks:
Other options will follow in dedicated issues, such as:
I followed the install guides and got dede running on an AWS ec2 m3.large.
$ ./main/dede
libdc1394 error: Failed to initialize libdc1394
DeepDetect [ commit 6116a0c8984300438b4323bbad44c5d8ca9c2080 ]
Running DeepDetect HTTP server on localhost:8080
In going through the text training tutorial (http://www.deepdetect.com/tutorials/txt-training/), it runs and then crashes.
1 - Creating the service
$ curl -X PUT "http://localhost:8080/services/n20" -d "{\"mllib\":\"caffe\",\"description\":\"newsgroup classification service\",\"type\":\"supervised\",\"parameters\":{\"input\":{\"connector\":\"txt\"},\"mllib\":{\"template\":\"mlp\",\"nclasses\":20,\"layers\":[200,200],\"activation\":\"relu\"}},\"model\":{\"templates\":\"../templates/caffe/\",\"repository\":\"models/n20\"}}"
{"status":{"code":201,"msg":"Created"}}
$
2 - Training the service
curl -X POST "http://localhost:8080/train" -d "{\"service\":\"n20\",\"async\":true,\"parameters\":{\"mllib\":{\"gpu\":true,\"solver\":{\"iterations\":2000,\"test_interval\":200,\"base_lr\":0.05},\"net\":{\"batch_size\":300}},\"input\":{\"shuffle\":true,\"test_split\":0.2,\"min_count\":2,\"min_word_length\":2,\"count\":false},\"output\":{\"measure\":[\"mcll\",\"f1\"]}},\"data\":[\"models/n20/news20\"]}"
{"status":{"code":201,"msg":"Created"},"head":{"method":"/train","job":1,"status":"running"}}
3 - Checking on the job: RUNNING
$ curl -X GET "http://localhost:8080/train?service=n20&job=1"
{"status":{"code":200,"msg":"OK"},"head":{"method":"/train","job":1,"status":"running","time":6.0},"body":{"measure":{}}}
4 - Checking on the job: ERROR
$ curl -X GET "http://localhost:8080/train?service=n20&job=1"
{"status":{"code":200,"msg":"OK"},"head":{"method":"/train","job":1,"status":"error"},"body":{}}
5 - Meanwhile, over under ./main/dede
INFO - Creating layer inputl
INFO - Creating Layer inputl
INFO - inputl -> data
INFO - inputl -> label
ERROR - service n20 training status call failed
ERROR - {"code":500,"msg":"InternalError","dd_code":1007,"dd_msg":"./include/caffe/syncedmem.hpp:26 / Check failed (custom): *ptr"}
What am I doing wrong?
Linking CXX executable dede
/usr/bin/ld: ../src/libddetect.a(caffelib.cc.o): undefined reference to symbol '_ZN2cv6imreadERKNS_6StringEi'
/usr/local/lib/libopencv_imgcodecs.so.3.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
main/CMakeFiles/dede.dir/build.make:90: recipe for target 'main/dede' failed
make[2]: *** [main/dede] Error 1
CMakeFiles/Makefile2:160: recipe for target 'main/CMakeFiles/dede.dir/all' failed
make[1]: *** [main/CMakeFiles/dede.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2
Hello Beniz,
I keep getting linker errors when I'm trying to install:
"deepdetect/build/caffe_dd/src/caffe_dd/build/lib/libcaffe.so: undefined reference to `cudaEventRecord' "
Any idea which Makefile or config I need to change?
Thanks very much
In some cases, when a training service fails on CUDA memory allocation or other errors at model loading time, it seems the lock on Caffe BlockingQueue isn't released.
In server logs, this typically looks like server is hanging on:
INFO - Creating layer data
INFO - Creating Layer data
INFO - data -> data
INFO - data -> label
and upon debugging:
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x000000000046f473 in boost::condition_variable::wait (this=0x7eff7562d348, m=...) at /usr/include/boost/thread/pthread/condition_variable.hpp:73
#2 0x00007ffff5c69e38 in caffe::BlockingQueue<caffe::Datum*>::peek() ()
from /build/lib/libcaffe.so
Possibly comes from the Caffe Solver object not being released upon exception. To be investigated shortly.
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.