Last active
July 9, 2017 20:26
-
-
Save ShiftMinus/c394b4307037be1caf5f3d92865eb27e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
require 'json' | |
res = RestClient.post "http://demo.illustration2vec.net/upload",:image => File.new(ARGV[0]) | |
if res.code == 200 | |
tags = JSON.parse(res.body) | |
tags["prediction"].each do |k,v| | |
tags = v.flatten.select!.with_index {|x,i| i % 2 == 0} unless v.length < 1 | |
case k | |
when "rating" | |
puts "rating:#{v.first.shift}" | |
when "character" | |
tags.each {|t| puts "character:#{t}"} | |
when "copyright" | |
tags.each {|t| puts "series:#{t}"} | |
else | |
puts tags | |
end | |
end | |
else | |
abort "Server error: Code #{res.code}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment