nwojke / deep_sort

Simple Online Realtime Tracking with a Deep Association Metric
GNU General Public License v3.0
5.39k stars 1.49k forks source link

_run_in_batches Issue With Multi Processing #191

Open fspider opened 5 years ago

fspider commented 5 years ago

I found this issue with log

Code is like this

def worker(FLAGS, pno, lock):
    model_filename = 'model_data/market1501.pb'
    encoder = gdet.create_box_encoder(model_filename, batch_size=1)
    while:
         darknet_detection part
         boxs, confidences, classids = generate_boxes_confidences_classids(results, FLAGS.confidence)
         if (boxs is not None):
             features = encoder(frame, boxs)
             ....

if __name__ == '__main__':
    jobs = []
    p = Process(target=worker, args=(FLAGS, 0, lock))
    jobs.append(p)
    p.start()

generate_detection.py

def __call__(self, data_x, batch_size=32):
    print("->190")
    out = np.zeros((len(data_x), self.feature_dim), np.float32)
    print("->191")
    _run_in_batches(
        lambda x: self.session.run(self.output_var, feed_dict=x),
        {self.input_var: data_x}, out, batch_size)
    print("->192")
    return out

ENVIRONMENT

Ubuntu 18.04, Cuda 10.0, Tensorflow 1.14

Log RESULT

->13
->16
->17
->18
->19
->190
->191

So i found the _run_in_batches function not works with multiprocessing

How can i run deep sort module with multiprocessing?

fspider commented 5 years ago

And when trace the log with _run_in_baches function i get this log result

def _run_in_batches(f, data_dict, out, batch_size):
    data_len = len(out)
    num_batches = int(data_len / batch_size)
    print("123")
    s, e = 0, 0
    print("124")
    for i in range(num_batches):
        print("1240")
        s, e = i * batch_size, (i + 1) * batch_size
        print("1241")
        batch_data_dict = {k: v[s:e] for k, v in data_dict.items()}
        print("1242")
        out[s:e] = f(batch_data_dict)
        print("1243")
    print("125")
    if e < len(out):
        print("1250")
        batch_data_dict = {k: v[e:] for k, v in data_dict.items()}
        print("1251")
        out[e:] = f(batch_data_dict)
        print("1252")

Log RESULT

123
124
1240
1241
1242

So it seems not work with following function out[s:e] = f(batch_data_dict)

Please Help me!

songzhifei commented 3 years ago

i have the same problem . how do you solve it?

gustavojoseleite commented 3 years ago

Same problem here! Any solution?