source: internals/2016/aptoideimagesdetector/trunk/Source Code/analyse_app.py @ 16391

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

Database updated

File size: 1.8 KB
Line 
1# Diogo Ferreira, 2016
2# Aptoide
3# Main function to analyse the percentage of explicitness of an app
4
5from __future__ import division
6import i2v
7import pickle
8from Illustration2Vector.illustration2vec_master.analyse_image import analyse_explicit
9from Text_categorization.Text_categorization import text_cat
10
11
12def analyse_app(illust2vec, icons, screenshots, description):
13
14        images = []
15
16        for icon in icons:
17                images.append(analyse_explicit(illust2vec, icon))
18
19        for scr in screenshots:
20                images.append(analyse_explicit(illust2vec, scr))
21
22        if len(images)==0:
23                return 0
24        else:
25                print images
26                maximum = 0
27                for im in images:
28                        if im[1]>maximum:
29                                maximum = im[1]
30
31                print maximum
32
33                prob2 = text_cat(description)
34                print prob2.prob('exp')
35                return 0.7*prob2+0.3*prob1
36
37
38if __name__=='__main__':
39
40        try:
41                illust2vec_f = open("Illustration2Vector/illustration2vec_master/illust2vec.pickle", "rb")
42                illust2vec = pickle.load(illust2vec_f)
43                illust2vec_f.close()
44        except IOError:
45                illust2vec = i2v.make_i2v_with_chainer(
46            "Illustration2Vector/illustration2vec-master/illust2vec_tag_ver200.caffemodel", "Illustration2Vector/illustration2vec-master/tag_list.json")
47                save_model = open("Illustration2Vector/illustration2vec_master/illust2vec.pickle", "wb")
48                pickle.dump(illust2vec, save_model)
49                save_model.close()
50
51        icons = []
52        screenshots = []
53        description = ""
54
55        icons.append("./API to download database/images/Explicit search/icons_explicit/7883823.png")
56        screenshots.append("./API to download database/images/Explicit search/screenshot_explicit/18966461_3_hd.jpg")
57        description = "Are you looking for Porn Movies ? If yes, you are at right place. Enjoy porn movies. You can download porn movies also to enjoy later. Tag: Porn, Porno, Sex, Adult, Downloader, sex, xxx, xx"
58
59        print analyse_app(illust2vec, icons, screenshots, description)
Note: See TracBrowser for help on using the repository browser.