deepstack 1.4.0 → 1.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '02929889eabbeeb8b76cd2f588cef7452ef0bb6dd3687fad749105e6956191e9'
4
- data.tar.gz: 2625f0bc5aac522d23461530dda2e581718c4f967c053db13c13ff0dcaa46f92
3
+ metadata.gz: 6d3a74d72c68a1aef4f04d6b3a04d67cb26c89daf0bdfa1ba85a1cbfd904bd76
4
+ data.tar.gz: 2cc1bfddab42ebbc72ef9e1a90c35cc577e5a46e0db8d3900c42bc24dd15af64
5
5
  SHA512:
6
- metadata.gz: fd37e76b9ad0fd30ddcc8a995fe2267d01f056cb3aa3a1d134b6335d91b6b300f61ce9929ab6b2e183ead1036135d2854a53858306395caadfaca7f2baf083d2
7
- data.tar.gz: 275bba97d88a57d51de45a0ae2be230df5d2a8c749324ea748cd2a16c9e45de9c8f6c44d0d61fd860985400093e1caec636f1905bfbcab680631b39087bfbffa
6
+ metadata.gz: b12be0063b456923b065db6d9ae277aa30a32bc2a4e1c895a646b039d4770bd36dd296effc788cb7ace506be23dd64a836d11e77210184eb278b0b82ddda1818
7
+ data.tar.gz: ed627f25f85c15551b0758e9d87ea002f0cb95efdec5a6c31a92dd9a11936fc7bdddf51a570e61ebffc5995ce869c17d703df277421578428c187f7a724d64d5
@@ -20,15 +20,27 @@ class DeepStack
20
20
  #
21
21
  # @param [String] base_url the url to DeepStack's server:port
22
22
  # @param [String] api_key an optional API-KEY to use when connecting to DeepStack
23
- # @param [String] admin_key an optional ADMIN-KEY to use when connecting to DeepStack
23
+ # @param [String] api_key an optional API-KEY to use when connecting to DeepStack
24
+ # @param [Integer] verify_mode sets the flags for server the certification verification at
25
+ # beginning of SSL/TLS session.
26
+ # +OpenSSL::SSL::VERIFY_NONE+ or +OpenSSL::SSL::VERIFY_PEER+ are acceptable.
24
27
  #
25
28
  # @example
26
29
  # DeepStack.new('http://127.0.0.1:5000')
27
30
  #
28
- def initialize(base_url, api_key: nil, admin_key: nil)
31
+ # # Using API KEY:
32
+ # DeepStack.new('http://127.0.0.1:5000', api_key: 'secret', admin_key: 'supersecret')
33
+ #
34
+ # # Connect to SSL with a self-signed certificate
35
+ # DeepStack.new('https://localhost:443', verify_mode: OpenSSL::SSL::VERIFY_NONE)
36
+ #
37
+ def initialize(base_url, api_key: nil, admin_key: nil, verify_mode: nil)
29
38
  @base_url = base_url
30
39
  @auth = { api_key: api_key, admin_key: admin_key }.select { |_k, v| v } # remove nil values
31
- @http_mutex = Mutex.new
40
+ uri = URI(base_url)
41
+ http_options = {}
42
+ http_options[:verify_mode] = verify_mode if verify_mode
43
+ @http = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.instance_of?(URI::HTTPS), **http_options)
32
44
  end
33
45
 
34
46
  #
@@ -60,9 +72,7 @@ class DeepStack
60
72
  # Close the HTTP connection to DeepStack server
61
73
  #
62
74
  def close
63
- @http_mutex.synchronize do
64
- @http.finish if @http&.started?
65
- end
75
+ @http.finish if @http&.started?
66
76
  end
67
77
 
68
78
  private
@@ -79,11 +89,8 @@ class DeepStack
79
89
  form_data = combine_images_and_args(images.flatten, **args)
80
90
  req = Net::HTTP::Post.new(uri)
81
91
  req.set_form(form_data, 'multipart/form-data')
82
- @http_mutex.synchronize do
83
- @http ||= Net::HTTP.start(uri.hostname, uri.port)
84
- @http.start unless @http.started?
85
- @http.request(req)
86
- end
92
+ @http.start unless @http.started?
93
+ @http.request(req)
87
94
  end
88
95
 
89
96
  def combine_images_and_args(*images, **args)
@@ -4,14 +4,15 @@ class DeepStack
4
4
  # Scene Recognition
5
5
  module Scene
6
6
  #
7
- # Return
7
+ # Call the scene recognition API to classify an image into one of the supported scenes.
8
8
  #
9
9
  # @param [Object] image binary data or a File object
10
10
  # @param [Hash] options additional fields for DeepStack, e.g. min_confidence: 0.5
11
11
  #
12
- # @return [Hash] if successful, DeepStack result hash {'label' => 'scene', 'confidence' => 2.2}
12
+ # @return [Hash] if successful, DeepStack result hash +{'label' => 'scene', 'confidence' => 2.2}+
13
13
  #
14
14
  # @return [nil] if error
15
+ #
15
16
  def identify_scene(image, **options)
16
17
  target = 'vision/scene'
17
18
  api_post(target, image, **options)
@@ -5,5 +5,5 @@
5
5
  #
6
6
  class DeepStack
7
7
  # @return [String] Version of DeepStack helper libraries
8
- VERSION = '1.4.0'
8
+ VERSION = '1.5.0'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deepstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Tanagra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-11 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: