Class: DeepStack
- Inherits:
-
Object
- Object
- DeepStack
- Includes:
- CustomModel, Detection, Face, Scene
- Defined in:
- lib/deep_stack/version.rb,
lib/deep_stack/face.rb,
lib/deep_stack/scene.rb,
lib/deep_stack/detection.rb,
lib/deep_stack/deep_stack.rb,
lib/deep_stack/custom_model.rb
Overview
DeepStack API
Defined Under Namespace
Modules: CustomModel, Detection, Face, Scene
Constant Summary collapse
- VERSION =
Returns Version of DeepStack helper libraries.
'1.5.0'
Instance Method Summary collapse
-
#api_post(path, *images, **args) ⇒ Hash
Make a POST request to DeepStack path target.
-
#close ⇒ Object
Close the HTTP connection to DeepStack server.
-
#initialize(base_url, api_key: nil, admin_key: nil, verify_mode: nil) ⇒ DeepStack
constructor
Create a deepstack object connected to the given URL.
Methods included from CustomModel
Methods included from Scene
Methods included from Detection
Methods included from Face
#delete_face, #delete_faces, #detect_faces, #face_list, #face_match, #recognize_faces, #register_face
Constructor Details
#initialize(base_url, api_key: nil, admin_key: nil, verify_mode: nil) ⇒ DeepStack
Create a deepstack object connected to the given URL
37 38 39 40 41 42 43 44 |
# File 'lib/deep_stack/deep_stack.rb', line 37 def initialize(base_url, api_key: nil, admin_key: nil, verify_mode: nil) @base_url = base_url @auth = { api_key: api_key, admin_key: admin_key }.select { |_k, v| v } # remove nil values uri = URI(base_url) = {} [:verify_mode] = verify_mode if verify_mode @http = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.instance_of?(URI::HTTPS), **) end |
Instance Method Details
#api_post(path, *images, **args) ⇒ Hash
Make a POST request to DeepStack path target
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/deep_stack/deep_stack.rb', line 55 def api_post(path, *images, **args) uri = build_uri(path) args = @auth.merge(args) result = nil 10.times do result = images ? post_files(uri, images.flatten, **args) : post(uri, args) break unless result.is_a?(Net::HTTPRedirection) uri.path = result['location'] end raise Net::HTTPClientException, 'Too many redirections' if result.is_a?(Net::HTTPRedirection) process_result(result) end |
#close ⇒ Object
Close the HTTP connection to DeepStack server
74 75 76 |
# File 'lib/deep_stack/deep_stack.rb', line 74 def close @http.finish if @http&.started? end |