source: internals/2016/aptoideimagesdetector/trunk/Source Code/Illustration2Vector/illustration2vec-master/analyse_image.py @ 16306

Last change on this file since 16306 was 16306, checked in by dferreira, 3 years ago

Image Analyser API with Illustration 2 Vector ready.

File size: 615 bytes
Line 
1import i2v
2from PIL import Image
3import os
4import glob
5import sys
6
7
8def analyse_explicit(illust2vec, image_dir):
9
10        img = Image.open(os.path.join(image_dir))
11
12        list = illust2vec.estimate_specific_tags([img], ["explicit", "safe"])
13   
14        if list[0]['explicit']>list[0]['safe']:
15                print "explicit"
16        else:
17                print "safe"
18
19if __name__ == "__main__":
20       
21        print "Loading Neural Network Model..."
22        illust2vec = i2v.make_i2v_with_chainer(
23    "illust2vec_tag_ver200.caffemodel", "tag_list.json")
24
25        for image_dir in sys.argv:
26                if image_dir!=sys.argv[0]:
27                        print "Analysing image..."
28                        analyse_explicit(illust2vec, image_dir)
Note: See TracBrowser for help on using the repository browser.