clarifai-rails 0.2.0 → 0.2.1
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/README.md +18 -27
- data/clarifai-rails.gemspec +1 -1
- data/lib/clarifai/rails/image.rb +4 -6
- data/lib/clarifai/rails/version.rb +1 -1
- data/lib/generators/templates/clarifai.rb +2 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec6cb47fe9430f6955e30b556064dc36d935d91
|
4
|
+
data.tar.gz: cee70b8d106f79441f5eeb7196f4c187867ab71f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e5c0a11a0591358b5144905d8a74de5daead9fe359ca3e846fb9c92bd8efe872691580d87fb387bb6f1b7f1e7bc0b378ad7b30da2104b1fbe1084de0f3da4d6
|
7
|
+
data.tar.gz: 3a339979ad5f2a64f5c3f91725f4f45e4eac94989059425dda9681238f8f4bcd0aad56974d53bf7d8aeb52d371445463da218cdcfd09f5401f378804faa3a169
|
data/README.md
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
# Clarifai::Rails
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/clarifai/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
1
|
## Installation
|
6
2
|
|
7
3
|
Add this line to your application's Gemfile:
|
@@ -24,7 +20,7 @@ Or install it yourself as:
|
|
24
20
|
|
25
21
|
$ rails g clarifai:install
|
26
22
|
|
27
|
-
### Config
|
23
|
+
### Config API-KEY and Model code
|
28
24
|
|
29
25
|
Insert your application info in ```config/initializers/clarifai.rb```
|
30
26
|
|
@@ -34,6 +30,11 @@ Insert your application info in ```config/initializers/clarifai.rb```
|
|
34
30
|
Clarifai::Rails::Detector.new(image_url).image
|
35
31
|
```
|
36
32
|
|
33
|
+
Custom model code
|
34
|
+
```ruby
|
35
|
+
Clarifai::Rails::Detector.new(image_url, model_code).image
|
36
|
+
```
|
37
|
+
|
37
38
|
Return ```Clarifai::Rails::Image``` object
|
38
39
|
|
39
40
|
### For multiple images
|
@@ -42,14 +43,9 @@ Return ```Clarifai::Rails::Image``` object
|
|
42
43
|
Clarifai::Rails::Detector.new([image_url_1, image_url_2]).images
|
43
44
|
```
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
### If you want to download images before detect (Facebook images, ...)
|
48
|
-
|
46
|
+
Custom model code
|
49
47
|
```ruby
|
50
|
-
|
51
|
-
clarifai_detector.need_download!
|
52
|
-
clarifai_detector.images
|
48
|
+
Clarifai::Rails::Detector.new([image_url_1, image_url_2], model_code).images
|
53
49
|
```
|
54
50
|
|
55
51
|
Return array ```Clarifai::Rails::Image``` object
|
@@ -58,17 +54,17 @@ Return array ```Clarifai::Rails::Image``` object
|
|
58
54
|
|
59
55
|
With ```image``` is ```Clarifai::Rails::Image``` object
|
60
56
|
|
61
|
-
#### Get
|
57
|
+
#### Get concepts
|
62
58
|
|
63
59
|
```ruby
|
64
|
-
image.
|
60
|
+
image.concepts
|
65
61
|
```
|
66
|
-
Return for you is a String array, it is
|
62
|
+
Return for you is a String array, it is concepts list
|
67
63
|
|
68
|
-
#### Get
|
64
|
+
#### Get concepts with percent in image
|
69
65
|
|
70
66
|
```ruby
|
71
|
-
image.
|
67
|
+
image.concepts_with_percent
|
72
68
|
```
|
73
69
|
Return is a Hash with key is tag and value is percent
|
74
70
|
|
@@ -77,21 +73,16 @@ Return is a Hash with key is tag and value is percent
|
|
77
73
|
```ruby
|
78
74
|
image.url
|
79
75
|
```
|
80
|
-
Return
|
76
|
+
Return is a String
|
81
77
|
|
82
78
|
#### Get docid
|
83
79
|
|
84
80
|
```ruby
|
85
81
|
image.docid
|
86
82
|
```
|
87
|
-
Return
|
88
|
-
|
89
|
-
#### Get docid_str
|
83
|
+
Return is a Number
|
90
84
|
|
91
|
-
|
92
|
-
image.docid_str
|
93
|
-
```
|
94
|
-
Return ia a String
|
85
|
+
Return is a String
|
95
86
|
|
96
87
|
#### Check status
|
97
88
|
|
@@ -109,7 +100,7 @@ AND
|
|
109
100
|
```ruby
|
110
101
|
image.status_code
|
111
102
|
```
|
112
|
-
Return
|
103
|
+
Return is a String
|
113
104
|
|
114
105
|
Can you see more info at https://developer.clarifai.com/docs/status_codes
|
115
106
|
|
@@ -118,7 +109,7 @@ Can you see more info at https://developer.clarifai.com/docs/status_codes
|
|
118
109
|
```ruby
|
119
110
|
image.status_messages
|
120
111
|
```
|
121
|
-
Return
|
112
|
+
Return is a String
|
122
113
|
|
123
114
|
## Development
|
124
115
|
|
data/clarifai-rails.gemspec
CHANGED
data/lib/clarifai/rails/image.rb
CHANGED
@@ -7,11 +7,13 @@ module Clarifai
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def docid
|
10
|
-
json[:
|
10
|
+
json[:id]
|
11
11
|
end
|
12
12
|
|
13
13
|
def url
|
14
|
-
json[:url]
|
14
|
+
json[:input]['data']['image']['url']
|
15
|
+
rescue
|
16
|
+
nil
|
15
17
|
end
|
16
18
|
|
17
19
|
def concepts
|
@@ -33,10 +35,6 @@ module Clarifai
|
|
33
35
|
status[:description]
|
34
36
|
end
|
35
37
|
|
36
|
-
def docid_str
|
37
|
-
data[:docid_str]
|
38
|
-
end
|
39
|
-
|
40
38
|
def error
|
41
39
|
Clarifai::Rails::Error.detector(status_code)
|
42
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clarifai-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Khoa Nguyen
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.1.0.rc1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.1.0.rc1
|
55
55
|
description: Clarifai API Rails Client
|
56
56
|
email:
|
57
57
|
- thanhkhoait@gmail.com
|