Class: Multitagger::Provider::Algorithmia
- Inherits:
-
Object
- Object
- Multitagger::Provider::Algorithmia
- Defined in:
- lib/multitagger/provider/algorithmia.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Algorithmia
constructor
A new instance of Algorithmia.
- #tag(image) ⇒ Object
Constructor Details
#initialize(config) ⇒ Algorithmia
Returns a new instance of Algorithmia.
6 7 8 |
# File 'lib/multitagger/provider/algorithmia.rb', line 6 def initialize(config) @client = ::Algorithmia.client(config["key"]) end |
Instance Method Details
#tag(image) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/multitagger/provider/algorithmia.rb', line 10 def tag(image) algo = @client.algo("deeplearning/IllustrationTagger/0.2.3") image_data = Base64.encode64(File.open(image, "rb").read) input = { "image" => "data:image/jpeg;base64,#{image_data}" } result = algo.pipe(input).result result["general"].map { |x| Tag.new(x.keys.first, x.values.first) } end |