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 +4 -4
- data/lib/deep_stack/deep_stack.rb +18 -11
- data/lib/deep_stack/scene.rb +3 -2
- data/lib/deep_stack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d3a74d72c68a1aef4f04d6b3a04d67cb26c89daf0bdfa1ba85a1cbfd904bd76
|
4
|
+
data.tar.gz: 2cc1bfddab42ebbc72ef9e1a90c35cc577e5a46e0db8d3900c42bc24dd15af64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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]
|
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
|
-
|
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
|
-
|
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
|
-
@
|
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
|
-
@
|
83
|
-
|
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)
|
data/lib/deep_stack/scene.rb
CHANGED
@@ -4,14 +4,15 @@ class DeepStack
|
|
4
4
|
# Scene Recognition
|
5
5
|
module Scene
|
6
6
|
#
|
7
|
-
#
|
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)
|
data/lib/deep_stack/version.rb
CHANGED
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
|
+
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
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|