Exemple #1
0
  def __init__(self, port):

    util_root = '/works/demon_11st/utils'
    sys.path.insert(0, util_root)
    from demon_utils import demon_utils
    app.demon_utils = demon_utils('/storage/enroll')

    vsm_root = '/works/demon_11st/vsm'
    sys.path.insert(0, vsm_root)
    from vsm import vsm
    #import pdb; pdb.set_trace()
    image_sentence_filename = '/storage/attribute/PBrain_all.csv.image_sentence.txt'
    app.vsm = vsm(image_sentence_filename)

    agent_detector_root = '/works/demon_11st/agent/detection'
    sys.path.insert(0, agent_detector_root)
    import _init_paths
    from conf import conf
    from agent_detector import agent_detector
    yaml_file = '/storage/product/detection/11st_All/cfg/faster_rcnn_end2end_test.yml'
    conf = conf(yaml_file, 0)
    app.agent_detector = agent_detector()

    #import pdb; pdb.set_trace()
    agent_attribute_root = '/works/demon_11st/agent/attribute' 
    sys.path.insert(0, agent_attribute_root)
    from agent_attribute import agent_attribute 
    attribute_demon_host_ip = host_ip
    attribute_demon_port= 8080
    app.agent_attribute = agent_attribute( \
      attribute_demon_host_ip, attribute_demon_port)

    app.result_dic = init_result_dic()

    web_server.__init__(self, app, port)
Exemple #2
0
 def trainClassifiers(self):
     """
     Function pre creates objects for all classifiers, so that prediction is fast.
     An instance dict of those models is created so that they can be indexed easily.
     arguments: none
     return: none
     """
     
     self.which = {0:vsm(),1:nb(),2:svm()}
     for i in self.which.keys():
         self.which[i].fit()

host_ip = '10.202.4.219'
feature_demon_port = 8080
port = 8081
html_filename = 'index_11st.html'
html_filename_vsm = 'index_vsm.html'
sentense_filename = \
  '/storage/coco/COCO_trainval_test_sentenses.ResCept_epoch35_embedding2048_hidden384_layer2.txt'
  #'/storage/coco/COCO_trainval_sentense.inception7_lstm2_embedding384.txt'
  #'/works/VSM/documents/COCO_sentense.txt'
url_prefix = 'http://%(host_ip)s:%(port)d/lua_wrapper_request_handler/?url=%%s' % \
  {'host_ip': host_ip, 'port': feature_demon_port}

exifutils = exifutil()
vsm = vsm(sentense_filename)


# global the flask app object
app = flask.Flask(__name__)


def gen(camera):
  while True:
    frame = camera.get_frame()
    yield (b'--frame\r\n'
           b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')


@app.route('/vsm_request_handler', methods=['GET'])
@crossdomain(origin='*')
from vsm import vsm

host_ip = '10.202.4.219'
feature_demon_port = 8080
port = 8081
html_filename = 'index_11st.html'
html_filename_vsm = 'index_vsm.html'
sentense_filename = \
  '/storage/coco/COCO_trainval_test_sentenses.ResCept_epoch35_embedding2048_hidden384_layer2.txt'
#'/storage/coco/COCO_trainval_sentense.inception7_lstm2_embedding384.txt'
#'/works/VSM/documents/COCO_sentense.txt'
url_prefix = 'http://%(host_ip)s:%(port)d/lua_wrapper_request_handler/?url=%%s' % \
  {'host_ip': host_ip, 'port': feature_demon_port}

exifutils = exifutil()
vsm = vsm(sentense_filename)

# global the flask app object
app = flask.Flask(__name__)


def gen(camera):
    while True:
        frame = camera.get_frame()
        yield (b'--frame\r\n'
               b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')


@app.route('/vsm_request_handler', methods=['GET'])
@crossdomain(origin='*')
def vsm_request_handler():
Exemple #5
0
            else:
                shutil.copyfile(
                    os.path.join(path, filename),
                    os.path.join('data/20news-test/' + folder, filename))
            i += 1


if __name__ == '__main__':
    # 将数据划分train set 与 test set
    # devide()
    # 输入train set
    train_X, train_Y = vsm.input_data(base_path='data/20news-train',
                                      out1='data/knn-out/train_X.csv',
                                      out2='data/knn-out/train_Y.csv')
    # 生成词典
    dictionary = vsm.f_dictionary(train_X, 'data/knn-out/dictionary.csv')
    # tf-idf 获取train_X 的 vector space
    vsm_train = vsm.vsm(train_X, dictionary)
    del train_X
    gc.collect()
    # 输入test set
    test_X, test_Y = vsm.input_data(base_path='data/20news-test',
                                    out1='data/knn-out/test_X.csv',
                                    out2='data/knn-out/test_Y.csv')
    # tf-idf 获取test_X 的 vector space
    vsm_test = vsm.vsm(test_X, dictionary)
    del test_X
    gc.collect()
    # knn分类
    knn(vsm_train, train_Y, vsm_test, test_Y)