deepstack 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: caf4cf801a5a99ff308e5afc06ed19dac86d8348388c519880770d482fd1bb0b
4
- data.tar.gz: de77bacb1bd1ffb46c4dff277ab16e1195ef423f005ad98394b49cab6e248fa3
3
+ metadata.gz: be874725c205c1b4c704649e99506f362fc711eeff315d9616deb112f7caecd5
4
+ data.tar.gz: f3a54bde1b2d8a533e9af9c58154a9004c7133f3e383d8e612a91d6052187fe1
5
5
  SHA512:
6
- metadata.gz: 6836c3bc1e6dc367542c4bd9e3e089ddf2cf3a7e612d6230dfabf3f3a38a4651965eead00bba50dd5916e5a9d8fcc44c624f3743b17165fbda24cff8c9ea7ec8
7
- data.tar.gz: 5f5c98987f6fae82a67ef8fa57a557aa300bd22da6108a8575eabe6e3ac8d1f301f57caad1f86b533629b503d53db4bb40e101ff630abddce1b2659637e2b177
6
+ metadata.gz: 9c7d7c9f0abe1465489936961e9cc297c1e9961b2e6afe6b2612fea975b5b0cc0c24a95748fd6fe14e5b45e480d15a27237ad5e5b01d4f84a8617258a659fcc1
7
+ data.tar.gz: d4d9f966dd440a3cd3031c3ba64b029d0f94b427945d64b77cd23aea3f1a900de2fea85a2f24ddd49fca8c1c821c7e3c6b7c63a9e120fc38e481ed1452ec388b
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DeepStack
4
+ # Custom Model
5
+ module CustomModel
6
+ #
7
+ # Return predictions using a custom model
8
+ #
9
+ # @param [String] model custom model name
10
+ # @param [Object] image binary data or a File object
11
+ # @param [Hash] options additional fields for DeepStack, e.g. min_confidence: 0.5
12
+ #
13
+ # @return [Array] if successful, an array of DeepStack predictions
14
+ #
15
+ # @return [nil] if error
16
+ #
17
+ def custom_model(model, image, **options)
18
+ target = "vision/custom/#{model}"
19
+ api_post(target, image, **options)&.dig('predictions')
20
+ end
21
+ # @deprecated Use {custom_model} instead
22
+ alias custom_inference custom_model
23
+ end
24
+ end
@@ -5,7 +5,7 @@ require 'json'
5
5
  require_relative 'face'
6
6
  require_relative 'detection'
7
7
  require_relative 'scene'
8
- require_relative 'custom'
8
+ require_relative 'custom_model'
9
9
  require_relative 'version'
10
10
 
11
11
  # DeepStack API
@@ -13,7 +13,7 @@ class DeepStack
13
13
  include DeepStack::Face
14
14
  include DeepStack::Detection
15
15
  include DeepStack::Scene
16
- include DeepStack::Custom
16
+ include DeepStack::CustomModel
17
17
 
18
18
  #
19
19
  # Create a deepstack object connected to the given URL
@@ -61,8 +61,7 @@ class DeepStack
61
61
  #
62
62
  def close
63
63
  @http_mutex.synchronize do
64
- @http&.finish
65
- @http = nil
64
+ @http.finish if @http&.started?
66
65
  end
67
66
  end
68
67
 
@@ -82,6 +81,7 @@ class DeepStack
82
81
  req.set_form(form_data, 'multipart/form-data')
83
82
  @http_mutex.synchronize do
84
83
  @http ||= Net::HTTP.start(uri.hostname, uri.port)
84
+ @http.start unless @http.started?
85
85
  @http.request(req)
86
86
  end
87
87
  end
@@ -5,5 +5,5 @@
5
5
  #
6
6
  class DeepStack
7
7
  # @return [String] Version of DeepStack helper libraries
8
- VERSION = '1.2.0'
8
+ VERSION = '1.3.0'
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deepstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Tanagra
@@ -17,7 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - lib/deep_stack/custom.rb
20
+ - lib/deep_stack/custom_model.rb
21
21
  - lib/deep_stack/deep_stack.rb
22
22
  - lib/deep_stack/detection.rb
23
23
  - lib/deep_stack/face.rb
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class DeepStack
4
- # Custom Model
5
- module Custom
6
- #
7
- # Register a custom inference method for convenience.
8
- # The custom method is called "identify_<modelname>"
9
- # Example:
10
- # deepstack.register_custom_model('license_plate')
11
- # deepstack.identify_license_plate(image)
12
- #
13
- # @param [Array] models a list of one or more custom model names to register
14
- #
15
- # @return [<Type>] <description>
16
- #
17
- def self.register_model(*models)
18
- models.flatten.each do |model|
19
- method_name = 'identify_'.concat model.gsub(/-+/, '_') # convert - to _
20
- define_method(method_name) do |image, **options|
21
- custom_inference(model, image, options)
22
- end
23
- end
24
- end
25
-
26
- #
27
- # Return predictions using a custom model
28
- #
29
- # @param [String] model custom model name
30
- # @param [Object] image binary data or a File object
31
- # @param [Hash] options additional fields for DeepStack, e.g. min_confidence: 0.5
32
- #
33
- # @return [Array] if successful, an array of DeepStack predictions
34
- #
35
- # @return [nil] if error
36
- #
37
- def custom_inference(model, image, **options)
38
- target = "vision/custom/#{model}"
39
- api_post(target, image, options)&.dig('predictions')
40
- end
41
- end
42
- end