Changeset 16499


Ignore:
Timestamp:
Aug 8, 2016, 1:52:53 PM (3 years ago)
Author:
dferreira
Message:

Config file added

Location:
internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/aptoide_mature_app_detector/explicit_content_detector/API/Explicit_detector/Text_categorization/Text_categorization.py

    r16462 r16499  
    3434        words = []
    3535        word_features = []
     36       
    3637
    3738        try:
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/aptoide_mature_app_detector/explicit_content_detector/API/Explicit_detector/analyse_app.py

    r16462 r16499  
    66
    77from __future__ import division
     8import json
     9import os
    810import i2v
    911import pickle
     
    1517def get_model():
    1618        illust2vec = []
     19
     20        p = os.path.abspath(os.path.join("../", os.pardir))
     21
     22        with open(p+"/config.json") as json_data:
     23                config = json.load(json_data)
     24
    1725        try:
    18                 illust2vec_f = open("API/Explicit_detector/Illustration2Vector/illustration2vec_master/illust2vec.pickle", "rb")
     26                illust2vec_f = open(config['directories']['ill2vec_ser'], "rb")
    1927                illust2vec = pickle.load(illust2vec_f)
    2028                illust2vec_f.close()
    2129        except IOError:
    22                 illust2vec = i2v.make_i2v_with_chainer(
    23             "API/Explicit_detector/Illustration2Vector/illustration2vec-master/illust2vec_tag_ver200.caffemodel", "Illustration2Vector/illustration2vec-master/tag_list.json")
    24                 save_model = open("API/Explicit_detector/Illustration2Vector/illustration2vec_master/illust2vec.pickle", "wb")
     30                illust2vec = i2v.make_i2v_with_chainer(config['directories']['ill2vec_model']
     31            , config['directories']['ill2vec_tag_list'])
     32                save_model = open(config['directories']['ill2vec_ser'], "wb")
    2533                pickle.dump(illust2vec, save_model)
    2634                save_model.close()
     
    2937def analyse_app(illust2vec, icons, screenshots, description, category, age, size, title):
    3038
     39        p = os.path.abspath(os.path.join("../", os.pardir))
     40
     41        with open(p+"/config.json") as json_data:
     42                config = json.load(json_data)
     43
    3144        # Tries to load the model for text categorization
    3245        try:
    33                 f = open("./API/Explicit_detector/model_apps_info.pickle", "rb")
     46                f = open(config['directories']['text_cat_model'], "rb")
    3447                classifier = pickle.load(f)
    3548                f.close()
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/aptoide_mature_app_detector/explicit_content_detector/API/views.py

    r16487 r16499  
    99# http://127.0.0.1:8000/detect_mature/id=md5_of_app
    1010
     11import os
    1112from django.http import HttpResponse
    1213from django.shortcuts import redirect
     
    2930        illust2vec = Model._model
    3031        exp = False
     32
     33        p = os.path.abspath(os.path.join("../", os.pardir))
     34
     35        with open(p+"/config.json") as json_data:
     36                config = json.load(json_data)
     37
     38
    3139        print "Fetching data..."
    3240        title = page['meta']['title']
     
    4755        if 'sshots' in page['media']:
    4856                for s in page['media']['sshots']:
    49                         scr.append(s)
     57
     58                        temp = s['path'].split('http://',1)
     59
     60                        scr.append(config['directories']['url_images']+temp[1])
    5061
    5162        if 'sshots_hd' in page['media']:
    5263                for s in page['media']['sshots_hd']:
    53                         scr_hd.append(s['path'])
     64                        temp = s['path'].split('http://',1)
     65
     66                        scr_hd.append(config['directories']['url_images']+temp[1])
    5467
    5568        min_age = page['meta']['min_age']
    5669
    5770        icon = page['apk']['icon']
     71        temp = icon.split('http://',1)
     72
     73        icon = config['directories']['url_images']+temp[1]
    5874
    5975        icon_hd = []
    6076        if 'icon_hd' in page['apk']:
    6177                icon_hd = page['apk']['icon_hd']
     78                temp = icon_hd.split('http://',1)
     79
     80                icon_hd = config['directories']['url_images']+temp[1]
    6281
    6382        icons = []
Note: See TracChangeset for help on using the changeset viewer.