clarifai-rb 0.0.0 → 0.0.5
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/.gitignore +1 -9
- data/LICENSE +21 -0
- data/README.md +69 -0
- data/clarifai-rb-0.0.0.gem +0 -0
- data/clarifai-rb.gemspec +3 -3
- data/lib/clarifai/predict.rb +10 -6
- metadata +6 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4179f4487a6395107a0e3e00c12c764db429acf574a488bba241f8056f238949
|
4
|
+
data.tar.gz: 73159320d487030e06eb48ec9b6f7726ec1a13caf49e2e531b711a3000145691
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46b73560483545c1bdf24a8e7c778f1a0e649fe5ae6b9a3aa7a2b48a31b06f0ef4044d0f97157681fc81ca0b7503470615a3303d8f4589ea356ed14d9c12a25e
|
7
|
+
data.tar.gz: 5aa23ff7b94a44858bfff238e8023cf5b193bbc48d7c946cb6e89b9b00e6561caf2ff5fb767da23eebf47e90397a42badbcbef8af3983ba07f919b96563967ef
|
data/.gitignore
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 Muhamad Rizky Sya'ban
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# clarifai-rb
|
2
|
+
|
3
|
+
An unofficial Ruby wrapper for [Clarifai](https://www.clarifai.com/) V2 API with the latest `user_id` and `app_id` scoping.
|
4
|
+
|
5
|
+
## Contents
|
6
|
+
|
7
|
+
1. [Getting Started](https://github.com/shabanzo/clarifai-rb/blob/main/README.md#getting-started)
|
8
|
+
2. [Configuration](https://github.com/shabanzo/clarifai-rb/blob/main/README.md#configuration)
|
9
|
+
3. [Usage](https://github.com/shabanzo/clarifai-rb/blob/main/README.md#usage)
|
10
|
+
|
11
|
+
## Getting Started
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```
|
16
|
+
gem 'clarification'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
```
|
22
|
+
bundle install
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
```
|
28
|
+
gem install clarifai-rb
|
29
|
+
```
|
30
|
+
|
31
|
+
## Configuration
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Clarifai.configure do |config|
|
35
|
+
config.user_id = '<your_user_id>'
|
36
|
+
config.app_id = '<your_app_id>'
|
37
|
+
config.pat = '<your_pat>' # Personal Access Tokens
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
If you're using Rails, create a new file named `clarifai.rb` inside `config/initializers` and copy the configuration above.
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
For single url:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
predict_instance = Clarifai::Predict.new(model_id: '<your_model_id>')
|
49
|
+
predict_instance.call(
|
50
|
+
type: 'image',
|
51
|
+
urls: '<image_url>'
|
52
|
+
)
|
53
|
+
```
|
54
|
+
|
55
|
+
For multiple urls:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
predict_instance = Clarifai::Predict.new(model_id: '<your_model_id>')
|
59
|
+
predict_instance.call(
|
60
|
+
type: 'image',
|
61
|
+
urls: ['<image_url_1>', '<image_url_2>']
|
62
|
+
)
|
63
|
+
```
|
64
|
+
|
65
|
+
### Supported types:
|
66
|
+
|
67
|
+
1. image
|
68
|
+
2. video
|
69
|
+
3. text
|
Binary file
|
data/clarifai-rb.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "clarifai-rb"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
s.summary = "An unofficial Ruby wrapper for Clarifai API"
|
10
10
|
s.description = "Alpha Version - Predict using Clarifai"
|
11
11
|
s.authors = ["Muhamad Rizky Sya'ban"]
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
"https://rubygems.org/gems/clarifai-rb"
|
18
18
|
s.license = "MIT"
|
19
19
|
s.required_ruby_version = '>=2.2'
|
20
|
-
s.metadata['rubygems_mfa_required'] = 'true'
|
21
20
|
|
22
|
-
s.
|
21
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
22
|
+
s.metadata['documentation_uri'] = "https://github.com/shabanzo/clarifai-rb"
|
23
23
|
end
|
data/lib/clarifai/predict.rb
CHANGED
@@ -14,6 +14,7 @@ module Clarifai
|
|
14
14
|
raise "Type is not supported! (#{SUPPORTED_TYPES.join(', ')} only)" unless SUPPORTED_TYPES.include?(type)
|
15
15
|
raise 'Input data not supported! (Array of Strings or String only)' unless valid_params?(urls)
|
16
16
|
|
17
|
+
urls = [urls] unless urls.is_a?(Array)
|
17
18
|
http = setup_http_client
|
18
19
|
request = setup_predict_request(type, urls)
|
19
20
|
response = http.request(request)
|
@@ -63,14 +64,17 @@ module Clarifai
|
|
63
64
|
{ data: { image: { url: url } } }
|
64
65
|
end
|
65
66
|
|
66
|
-
def predict_body(type,
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
def predict_body(type, urls)
|
68
|
+
inputs = urls.map do |url|
|
69
|
+
{
|
70
|
+
data: {
|
71
|
+
"#{type}": {
|
72
|
+
url: url
|
73
|
+
}
|
71
74
|
}
|
72
75
|
}
|
73
|
-
|
76
|
+
end
|
77
|
+
{ inputs: inputs }.to_json
|
74
78
|
end
|
75
79
|
end
|
76
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clarifai-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muhamad Rizky Sya'ban
|
@@ -9,21 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-09-14 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: json
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.8'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.8'
|
12
|
+
dependencies: []
|
27
13
|
description: Alpha Version - Predict using Clarifai
|
28
14
|
email: rizkyshaban@gmail.com
|
29
15
|
executables: []
|
@@ -32,6 +18,9 @@ extra_rdoc_files: []
|
|
32
18
|
files:
|
33
19
|
- ".gitignore"
|
34
20
|
- Gemfile
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
23
|
+
- clarifai-rb-0.0.0.gem
|
35
24
|
- clarifai-rb.gemspec
|
36
25
|
- lib/clarifai.rb
|
37
26
|
- lib/clarifai/configuration.rb
|
@@ -41,6 +30,7 @@ licenses:
|
|
41
30
|
- MIT
|
42
31
|
metadata:
|
43
32
|
rubygems_mfa_required: 'true'
|
33
|
+
documentation_uri: https://github.com/shabanzo/clarifai-rb
|
44
34
|
post_install_message:
|
45
35
|
rdoc_options: []
|
46
36
|
require_paths:
|