0

I'm currently using parallel python ,and in the parameters of job_server.submit i added the library in modules but the problem is that even that library has other librairies in it .so what should i do ? Here is the code i'm trying to run:

    from 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 this is part of code of demo.py

import _init_paths
from fast_rcnn.config import cfg
from fast_rcnn.test import im_detect
from fast_rcnn.nms_wrapper import nms
from utils.timer import Timer
from ocr.clstm import clstm_ocr
from ocr.clstm import clstm_ocr_calib
import matplotlib.pyplot as plt
import numpy as np
import scipy.io as sio
import caffe, os, sys, cv2
import argparse
import werkzeug
import datetime
import math
import pytesseract
from PIL import Image


def detect_cn(filename):
cfg.TEST.HAS_RPN = True  # Use RPN for 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 you 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 for CN image...'
return demo2(net, filename)

Do you think i should load all those librairies in modules of job server.submit? I want to use the pp bacause detect_cn takes 2 minutes to give results any ideas?

KAFFEL
  • 35
  • 1
  • 8

1 Answers1

0

Yes, you should import all these modules when wou submit your function into the execution queue.

f1 = job_server.submit(detect_cn, (filename,),modules=("math","numpy", ...))
Neil
  • 14,063
  • 3
  • 30
  • 51