python - how to call a module in a function in pp where that fuction has other functions in it? -


i'm using parallel python ,and in parameters of job_server.submit added library in modules problem library has other librairies in .so should ? here code i'm trying run:

    tools.demo import detect_cn     import pp      job_server = pp.server()     f1 = job_server.submit(detect_cn, (filename,),modules=('tools.demo',))     f2 = job_server.submit(detect_cn, (filename1,),modules=('tools.demo',))       cnis, preproc_time, roi_file_images=f1()     cnis1, preproc_time1, roi_file_images1=f2() 

and part of code of demo.py

import _init_paths fast_rcnn.config import cfg fast_rcnn.test import im_detect fast_rcnn.nms_wrapper import nms utils.timer import timer ocr.clstm import clstm_ocr ocr.clstm import clstm_ocr_calib import matplotlib.pyplot plt import numpy np import scipy.io sio import caffe, os, sys, cv2 import argparse import werkzeug import datetime import math import pytesseract pil import image   def detect_cn(filename): cfg.test.has_rpn = true  # use rpn proposals  args = parse_args()  prototxt = os.path.join(cfg.models_dir, nets[args.demo_net][0],                         'faster_rcnn_alt_opt', 'faster_rcnn_test.pt') caffemodel = os.path.join(cfg.data_dir, 'faster_rcnn_models',                           nets[args.demo_net][1])  if not os.path.isfile(caffemodel):     raise ioerror(('{:s} not found.\ndid run ./data/script/'                    'fetch_faster_rcnn_models.sh?').format(caffemodel))  if args.cpu_mode:     caffe.set_mode_cpu() else:     caffe.set_mode_gpu()     caffe.set_device(args.gpu_id)     cfg.gpu_id = args.gpu_id net = caffe.net(prototxt, caffemodel, caffe.test)  print '\n\nloaded network {:s}'.format(caffemodel)  print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' print 'demo cn image...' return demo2(net, filename) 

do think should load librairies in modules of job server.submit? want use pp bacause detect_cn takes 2 minutes give results ideas?

yes, should import these modules when wou submit function execution queue.

f1 = job_server.submit(detect_cn, (filename,),modules=("math","numpy", ...)) 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -