yandex_image_moderation 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02bdb7bdb855be5fd3a7e4cfe30510dff3e6cdd2
4
- data.tar.gz: 389cc34648ed382ba58134c74230922725d2bd8c
3
+ metadata.gz: ef3579e7512a9cd9cfa60837f38badb5ec7e380d
4
+ data.tar.gz: b23f32d78f39be6df41ef40d363e0f26b5269e11
5
5
  SHA512:
6
- metadata.gz: 421ce9d15b0acdd26f0ff6068a2cda7b69d7a043dd93dc3d7dfaf2cb4d9790b082a8d079a305132cabacd1830572697911f06c7725b009308a8698f2fa2bdb58
7
- data.tar.gz: b631b6ad51c9e12579fdc1dae177baf48b55b418bd143d36a1381cd57a43dacca8cc0b61e0f93e916c4f163bfff525081b9e03c97549be76e4f4536f6db691fd
6
+ metadata.gz: 20ea97770c8d5796cf943c6e668e23d48a9b5ee2be9d62e3592d38d7a44baeaed225658a96e57d4f36c3295bb2ca7ba5f7397709cd73cb260a68b284f2488157
7
+ data.tar.gz: c0527d5796968f9f9d56877f87648984d68eecac14a3dfe8afc9d17bb226671bba6d1bb8f46fbd724bc8c6dbcf045490687723d1dcf108c834eee36f0d232748
data/README.md CHANGED
@@ -45,12 +45,86 @@ end
45
45
 
46
46
  To moderate an image (remember: Yandex API works with JPEG only) just call a *moderate* methods with a path to the image file as a parameter:
47
47
 
48
- ```ruby
49
- result = YandexImageModeration.moderate('/var/www/uploads/test.jpg')
50
- puts result
51
-
52
-
53
- ```
48
+ answer = YandexImageModeration.moderate('/var/www/uploads/test.jpg')
49
+ # => #<YandexImageModeration::Result:0x0055ae52e8a7a0
50
+ @data=
51
+ {"status"=>"ok",
52
+ "revision"=>"33e3dfd4d",
53
+ "revisionDate"=>"2016-08-29 17:06:06 +0300",
54
+ "result"=>
55
+ {"classification"=>
56
+ {"gender"=>
57
+ {"predictedClass"=>"male",
58
+ "scores"=>{"female"=>0.0752159, "male"=>0.924784}},
59
+ "moderation"=>
60
+ {"predictedClass"=>"other",
61
+ "scores"=>
62
+ {"other"=>0.998316,
63
+ "erotic"=>1.01304e-05,
64
+ "inappropriateOrChild"=>0.00149277,
65
+ "approvedPersonNotChild"=>3.49765e-05,
66
+ "many"=>0.000146203}},
67
+ "pornography"=>
68
+ {"predictedClass"=>"other",
69
+ "scores"=>{"explicit"=>9.50646e-09, "other"=>0.99999999049354}},
70
+ "ad"=>
71
+ {"predictedClass"=>"not_ads",
72
+ "scores"=>{"ads"=>0.0229261, "not_ads"=>0.977074}}}}},
73
+ @result=
74
+ {"gender"=>
75
+ {"predictedClass"=>"male",
76
+ "scores"=>{"female"=>0.0752159, "male"=>0.924784}},
77
+ "moderation"=>
78
+ {"predictedClass"=>"other",
79
+ "scores"=>
80
+ {"other"=>0.998316,
81
+ "erotic"=>1.01304e-05,
82
+ "inappropriateOrChild"=>0.00149277,
83
+ "approvedPersonNotChild"=>3.49765e-05,
84
+ "many"=>0.000146203}},
85
+ "pornography"=>
86
+ {"predictedClass"=>"other",
87
+ "scores"=>{"explicit"=>9.50646e-09, "other"=>0.99999999049354}},
88
+ "ad"=>
89
+ {"predictedClass"=>"not_ads",
90
+ "scores"=>{"ads"=>0.0229261, "not_ads"=>0.977074}}},
91
+ @status="ok">
92
+
93
+ You can check if the request was successful or not:
94
+
95
+ answer.good?
96
+ # => true
97
+ answer.bad?
98
+ # => false
99
+ answer.status
100
+ # => "ok"
101
+
102
+ Then you can access to the resulting data directly through the *result* attribute:
103
+
104
+ answer.result['ad']['predictedClass']
105
+ # => "not_ads"
106
+
107
+ Also you can check either the image was classified as porn, erotic or ad and get scores for the classifications (scores are between 0 and 1):
108
+
109
+ answer.porn?
110
+ # => false
111
+ answer.erotic?
112
+ # => false
113
+ answer.ad?
114
+ # => false
115
+ answer.porn_score
116
+ # => 9.50646e-09
117
+ answer.erotic_score
118
+ # => 1.01304e-05
119
+ answer.ad_score
120
+ # => 0.0229261
121
+
122
+ And another one shortcut is provided - for getting predicted class during moderation:
123
+
124
+ answer.predicted_class
125
+ # => "other"
126
+
127
+ For a clarification on the returned data, predicted classes and scores please consult Yandex Image Moderation API documentation.
54
128
 
55
129
  ## Contributing
56
130
 
@@ -1,3 +1,3 @@
1
1
  module YandexImageModeration
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yandex_image_moderation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Tsvetkov
@@ -110,5 +110,5 @@ rubyforge_project:
110
110
  rubygems_version: 2.4.5
111
111
  signing_key:
112
112
  specification_version: 4
113
- summary: yandex_image_moderation-0.1.0
113
+ summary: yandex_image_moderation-0.1.1
114
114
  test_files: []