Class: Multitagger::Provider::Clarifai

Inherits:
Object
  • Object
show all
Defined in:
lib/multitagger/provider/clarifai.rb

Instance Method Summary collapse

Constructor Details

#initialize(our_config) ⇒ Clarifai

Returns a new instance of Clarifai.



26
27
28
29
30
31
# File 'lib/multitagger/provider/clarifai.rb', line 26

def initialize(our_config)
  ClarifaiRuby.configure do |config|
    config.client_id = our_config["id"]
    config.client_secret = our_config["secret"]
  end
end

Instance Method Details

#tag(image) ⇒ Object



33
34
35
36
# File 'lib/multitagger/provider/clarifai.rb', line 33

def tag(image)
  response = ClarifaiRuby::MyTagRequest.new.get(image)
  response.tag_images.first.tags.map { |x| Tag.new(x.word, x.prob) }
end