deepdetect_ruby 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d44f54c4ecf5c15c542c4bad2fb445ab51282200
4
+ data.tar.gz: 9f142b98c9dd4eeff44427d9df21b54ef018b479
5
+ SHA512:
6
+ metadata.gz: 4b15d6e806686c1db88e4a4e17faf3945f5d1997374dbd8003c84592462501cc85f60d466346b52a8a5d7e4ee98625d744357c70cfb29bc9ddcdf30e550bf4cc
7
+ data.tar.gz: 23b1701a4dfc40331fa3a60e21f60df60d1e52f51ccbb952636ba1eb258f1722f7398e9cda97492277ddeb71cea1c25a990d60d2a5954111271ea6f534abaf1f
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at ntamvl@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in deepdetect_ruby.gemspec
4
+ gemspec
5
+
6
+ gem 'rack'
7
+ gem 'awesome_print'
8
+ gem 'httparty'
9
+ # gem 'rest-client'
10
+ # gem 'curb'
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ deepdetect_ruby (1.0.pre.beta)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ awesome_print (1.7.0)
10
+ httparty (0.14.0)
11
+ multi_xml (>= 0.5.2)
12
+ multi_xml (0.5.5)
13
+ rack (2.0.1)
14
+ rake (10.4.2)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ awesome_print
21
+ bundler (~> 1.11)
22
+ deepdetect_ruby!
23
+ httparty
24
+ rack
25
+ rake (~> 10.0)
26
+
27
+ BUNDLED WITH
28
+ 1.13.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Tam Nguyen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Tam Nguyen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,245 @@
1
+ # DeepDetect for Ruby
2
+ DeepDetect is a Deep Learning API and server written in C++11. It makes the state-of-the-art Deep Learning easy to work with and can easily be integrated into existing applications.
3
+
4
+ ## DeepDetect supports the following features:
5
+ ### General
6
+ + High level & generic API for machine learning & deep learning
7
+ + JSON communication format
8
+ + Remote Python client library
9
+ + Embedded server with support for asynchronous training calls
10
+ + High performance, benefits from multicores and GPU
11
+ + Flexible input / output connectors
12
+ + Flexible template output format to simplify connection with external applications
13
+ + Removal of database dependency and sync, as everything is organized on the filesystem
14
+
15
+ ### Machine Learning / Deep Learning
16
+ + Support for state-of-the-art Deep Learning via Caffe library
17
+ + Templates for the most useful neural architectures (e.g. Googlenet, Alexnet, NiN, mlp, convnet, logistic regression)
18
+ + Range of built-in model assessment measures (e.g. F1, multiclass log loss, …)
19
+ + Support for multiple Machine Learning services, training and prediction calls in parallel
20
+ + Optimization for CPUs and GPUs
21
+ + Supervised learning, regression and prediction over images and other numerical and textual data
22
+
23
+ ### Data
24
+ + Built-in input connectors to ease the setup of a machine learning pipeline
25
+ + Easy management for large datasets of images
26
+ + Easy management and preprocessing for CSV data files
27
+ + Connector to handle large collections of images with on-the-fly data augmentation (e.g. rotations, mirroring)
28
+ + Connector to handle CSV files with preprocessing capabilities
29
+ + Connector to handle text files
30
+ + Output connectors for various external applications being able to be set up through templates via the API, without code (e.g. for Elasticsearch, XML, SQL, …)
31
+
32
+ # Architecture Diagram
33
+ ![DeepDetect Ruby App Diagram](https://c4.staticflickr.com/6/5479/30255507155_10d1fdc799_b.jpg)
34
+
35
+ ## Requirements
36
+ - Ubuntu 14.04 LTS
37
+ - Ruby 2.2.1 or above
38
+ - Rails 4.2.5 or above
39
+ - DeepDetect
40
+ - DeepDetect Dependencies:
41
+ - C++, gcc >= 4.8 or clang with support for C++11 (there are issues with Clang + Boost)
42
+ - eigen for all matrix operations
43
+ - glog for logging events and debug
44
+ - gflags for command line parsing
45
+ - OpenCV >= 2.4
46
+ - cppnetlib
47
+ - Boost
48
+ - curl
49
+ - curlpp
50
+ - utfcpp
51
+ - gtest for unit testing (optional)
52
+ - Caffe Dependencies:
53
+ - CUDA 7 or 6.5 is required for GPU mode.
54
+ - BLAS via ATLAS, MKL, or OpenBLAS.
55
+ - protobuf
56
+ - IO libraries hdf5, leveldb, snappy, lmdb
57
+
58
+ ## Installation
59
+ Welcome to your new gem! In this directory, you'll find the files you need in order to package your Ruby library into a gem.
60
+
61
+ Put your Ruby code in the file `lib/deepdetect_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
62
+
63
+ **Add this line to your application's Gemfile:**
64
+
65
+ ```ruby
66
+ gem 'deepdetect_ruby', git: "git@github.com:pixai/deepdetect-ruby.git"
67
+ ```
68
+ And then execute:
69
+ ```
70
+ $ bundle
71
+ ```
72
+ Or install it yourself as:
73
+ ```
74
+ $ gem install deepdetect_ruby
75
+ ```
76
+
77
+ ## Build DeepDetect
78
+ - On Ubuntu Linux, do:
79
+ ```
80
+ sudo apt-get install build-essential libgoogle-glog-dev libgflags-dev libeigen3-dev libopencv-dev libcppnetlib-dev libboost-dev libboost-iostreams-dev libcurlpp-dev libcurl4-openssl-dev protobuf-compiler libopenblas-dev libhdf5-dev libprotobuf-dev libleveldb-dev libsnappy-dev liblmdb-dev libutfcpp-dev cmake
81
+ ```
82
+ - Build from source code:
83
+ ```
84
+ cd
85
+ git clone git@github.com:beniz/deepdetect.git && cd deepdetect
86
+ mkdir build && cd build
87
+ cmake ..
88
+ make
89
+ ```
90
+
91
+ ## Usage
92
+ Configure on Rails at `config/application.rb`
93
+
94
+ *for single server*
95
+ ```ruby
96
+ DeepdetectRuby.configure do |config|
97
+ config.host = "http://api.pixai.com"
98
+ config.model_path = "/home/tamnguyen/models"
99
+ end
100
+ ```
101
+
102
+ *for multiple servers*
103
+ ```ruby
104
+ DeepdetectRuby.configure do |config|
105
+ config.model_path = "/home/tamnguyen/models"
106
+ config.is_scaling = true
107
+ config.servers = "http://staging.feels.com:8080, http://127.0.0.1:8080"
108
+ end
109
+ ```
110
+
111
+ **Example config at `config/application.rb`**
112
+ ```ruby
113
+ # begin load DeepDetect config
114
+ config_file_path = "#{Rails.root}/config/deepdetect.json"
115
+ model_hash = JSON.parse(File.read(config_file_path))
116
+ model_path = model_hash["model_path"]
117
+ DeepdetectRuby.configure do |config|
118
+ # config.host = "http://54.229.220.160:8080"
119
+ config.model_path = "#{model_path}"
120
+ config.debug = false
121
+ config.is_scaling = true
122
+ config.servers = "http://staging.feels.com:8080, http://127.0.0.1:8080"
123
+ end
124
+ # end load DeepDetect config
125
+ ```
126
+ *with `deepdetect.json` at `config/deepdetect.json`*
127
+ ```ruby
128
+ {
129
+ "model_path": "/home/ubuntu/projects/deepdetect/models"
130
+ }
131
+ ```
132
+ ## Create a deepdetect service
133
+ Example: Test creating a service
134
+ ```ruby
135
+ options = {
136
+ "name": "tress",
137
+ "mllib": "caffe",
138
+ "description": "trees classification",
139
+ "type": "supervised",
140
+ "connector": "image",
141
+ "height": 224,
142
+ "width": 224,
143
+ "nclasses": 304,
144
+ "repository": "/home/tamnguyen/models/trees"
145
+ }
146
+
147
+ DeepdetectRuby::Service.create(options)
148
+ ```
149
+ *with default options*
150
+ ```ruby
151
+ options = {
152
+ :name => "[name of service]",
153
+ :mllib => "caffe",
154
+ :description => "",
155
+ :type => "supervised",
156
+ :connector => "image",
157
+ :width => 224,
158
+ :height => 224,
159
+ :nclasses => 2,
160
+ :model_path => "[path to models on server]"
161
+ }
162
+ ```
163
+
164
+ ## Launch a training job
165
+ ```ruby
166
+ DeepdetectRuby::Train.launch(options = {}, is_custom_data = false)
167
+ ```
168
+
169
+ ## Get information on a training job
170
+ ```ruby
171
+ DeepdetectRuby::Train.get_status(options = {})
172
+ ```
173
+ *with default options*
174
+ ```ruby
175
+ options = {
176
+ :job => 1,
177
+ :timeout => 20,
178
+ :service => "[name of service]"
179
+ }
180
+ ```
181
+
182
+ ## Delete a training job
183
+ ```ruby
184
+ DeepdetectRuby::Train.delete(options = {})
185
+ ```
186
+ *with default options*
187
+ ```ruby
188
+ options = {
189
+ :job => 1,
190
+ :service => "[name of service]"
191
+ }
192
+ ```
193
+
194
+ ## Prediction
195
+ ```ruby
196
+ DeepdetectRuby::Predict.predict(options)
197
+ ```
198
+ *with default options*
199
+ ```ruby
200
+ options = {
201
+ :best => 2,
202
+ :gpu => true,
203
+ :service => "[name of service]",
204
+ :image_url => "[image url]",
205
+ :template => "[output template]"
206
+ }
207
+ ```
208
+
209
+ ## Fine tune model
210
+ ```ruby
211
+ DeepdetectRuby::Service.finetune(options)
212
+ ```
213
+ *with options*
214
+ ```ruby
215
+ options = {
216
+ :name => "[string - service name]",
217
+ :weights => "[filename of caffe model]",
218
+ :repository => "[repo path]",
219
+ :gpu => true,
220
+ :iterations => 10000,
221
+ :test_interval => 500,
222
+ :nclasses => 2,
223
+ :measure_index => 1,
224
+ :batch_size => 32,
225
+ :test_batch_size => 32
226
+ }
227
+ ```
228
+
229
+ ## Suggestion for Diagram of neural network models
230
+
231
+ In order to receive results with high accuracy, when applied to Pixai, this diagram of neural network models should be used as suggested below:
232
+ ![Chain of Models Diagram](https://c2.staticflickr.com/6/5492/29641623713_c43b64d5e3_b.jpg)
233
+
234
+ ## Development
235
+
236
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow experimentation.
237
+
238
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
239
+
240
+ ## Contribution
241
+ DeepDetect Ruby gem is designed and implemented by Tam Nguyen [tam@feels.com](tam@feels.com) or [ntamvl@gmail.com](ntamvl@gmail.com)
242
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pixai/deepdetect_ruby.
243
+
244
+ ## License
245
+ The gem is available as a private repository under the terms of the Feels License
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "deepdetect_ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'deepdetect_ruby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "deepdetect_ruby"
8
+ spec.version = DeepdetectRuby::VERSION
9
+ spec.authors = ["Tam Nguyen"]
10
+ spec.email = ["ntamvl@gmail.com"]
11
+
12
+ spec.summary = "DeepdetectRuby, a library for Ruby apps"
13
+ spec.description = "DeepdetectRuby, a library for Ruby apps"
14
+ spec.homepage = "https://github.com/ntamvl/deepdetect-ruby"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "httparty"
33
+ end