Skip to content

Instantly share code, notes, and snippets.

@ShiftMinus
Last active July 9, 2017 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShiftMinus/c394b4307037be1caf5f3d92865eb27e to your computer and use it in GitHub Desktop.
Save ShiftMinus/c394b4307037be1caf5f3d92865eb27e to your computer and use it in GitHub Desktop.
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