Class: Clarinet::Model
- Inherits:
-
Object
- Object
- Clarinet::Model
- Defined in:
- lib/clarinet/model.rb
Constant Summary collapse
- GENERAL =
'aaa03c23b3724a16a56b629203edc62c'
- FOOD =
'bd367be194cf45149e75f01d59f77ba7'
- TRAVEL =
'eee28c313d69466f836ab83287a54ed9'
- NSFW =
'e9576d86d2004ed1a38ba0cf39ecb4b1'
- WEDDINGS =
'c386b7a870114f4a87477c0824499348'
- COLOR =
'eeed0b6733a644cea07cf4c60f87ebb7'
- MAX_INPUT_COUNT =
128
Instance Attribute Summary collapse
- #app_id ⇒ String readonly
-
#created_at ⇒ String
readonly
Created at timestamp.
-
#id ⇒ String
readonly
Model id.
- #model_version ⇒ String readonly
-
#name ⇒ String
readonly
Model name.
- #output_info ⇒ Hash readonly
-
#raw_data ⇒ Hash
readonly
Raw API data used to construct this instance.
Instance Method Summary collapse
-
#delete_concepts(concepts) ⇒ Clarinet::Model
Remove concepts from a model.
-
#get_output_info ⇒ Clarinet::Model
Returns all the model’s output info.
-
#merge_concepts(concepts) ⇒ Clarinet::Model
Merge concepts to a model.
-
#overwrite_concepts(concepts) ⇒ Clarinet::Model
Overwrite concepts in a model.
-
#predict(inputs, config = {}) ⇒ Hash
Returns model ouputs according to inputs.
-
#train ⇒ Clarinet::Model
Create a new model version.
-
#versions(options = { page: 1, per_page: 20 }) ⇒ Hash
Returns a list of versions of the model.
Instance Attribute Details
#app_id ⇒ String (readonly)
30 31 32 |
# File 'lib/clarinet/model.rb', line 30 def app_id @app_id end |
#created_at ⇒ String (readonly)
27 28 29 |
# File 'lib/clarinet/model.rb', line 27 def created_at @created_at end |
#id ⇒ String (readonly)
21 22 23 |
# File 'lib/clarinet/model.rb', line 21 def id @id end |
#model_version ⇒ String (readonly)
36 37 38 |
# File 'lib/clarinet/model.rb', line 36 def model_version @model_version end |
#name ⇒ String (readonly)
24 25 26 |
# File 'lib/clarinet/model.rb', line 24 def name @name end |
#output_info ⇒ Hash (readonly)
33 34 35 |
# File 'lib/clarinet/model.rb', line 33 def output_info @output_info end |
#raw_data ⇒ Hash (readonly)
18 19 20 |
# File 'lib/clarinet/model.rb', line 18 def raw_data @raw_data end |
Instance Method Details
#delete_concepts(concepts) ⇒ Clarinet::Model
Remove concepts from a model
91 92 93 94 |
# File 'lib/clarinet/model.rb', line 91 def delete_concepts(concepts) concepts = [concepts] unless concepts.is_a? Array update 'remove', { concepts: concepts } end |
#get_output_info ⇒ Clarinet::Model
Returns all the model’s output info
55 56 57 58 |
# File 'lib/clarinet/model.rb', line 55 def get_output_info response_data = @app.client.model_output_info @id Clarinet::Model.new @app, response_data[:model] end |
#merge_concepts(concepts) ⇒ Clarinet::Model
Merge concepts to a model
99 100 101 102 |
# File 'lib/clarinet/model.rb', line 99 def merge_concepts(concepts) concepts = [concepts] unless concepts.is_a? Array update 'merge', { concepts: concepts } end |
#overwrite_concepts(concepts) ⇒ Clarinet::Model
Overwrite concepts in a model
107 108 109 110 |
# File 'lib/clarinet/model.rb', line 107 def overwrite_concepts(concepts) concepts = [concepts] unless concepts.is_a? Array update 'merge', { concepts: concepts } end |
#predict(inputs, config = {}) ⇒ Hash
Returns model ouputs according to inputs
69 70 71 72 73 74 75 76 77 |
# File 'lib/clarinet/model.rb', line 69 def predict(inputs, config = {}) video = config[:video] || false config.delete :video inputs = [inputs] unless inputs.is_a? Array inputs = inputs.map { |input| Clarinet::Utils.format_media_predict(input) } @app.client.outputs id, inputs, config end |
#train ⇒ Clarinet::Model
Note:
Training takes some time and the new version will not be immediately available.
Create a new model version
115 116 117 118 |
# File 'lib/clarinet/model.rb', line 115 def train response_data = @app.client.model_train @id Clarinet::Model.new @app, response_data[:model] end |
#versions(options = { page: 1, per_page: 20 }) ⇒ Hash
Returns a list of versions of the model
84 85 86 |
# File 'lib/clarinet/model.rb', line 84 def versions( = { page: 1, per_page: 20 }) @app.client.model_versions @id, end |