提交 66f2408d 编写于 作者: B Bai Yifan 提交者: qingqing01

Fix face_detection reader 'None' error (#1339)

* Fix  bug and  add  traceback.
上级 e2131fbc
...@@ -9,6 +9,7 @@ import time ...@@ -9,6 +9,7 @@ import time
import numpy as np import numpy as np
import threading import threading
import multiprocessing import multiprocessing
import traceback
try: try:
import queue import queue
except ImportError: except ImportError:
...@@ -71,6 +72,7 @@ class GeneratorEnqueuer(object): ...@@ -71,6 +72,7 @@ class GeneratorEnqueuer(object):
try: try:
task() task()
except Exception: except Exception:
traceback.print_exc()
self._stop_event.set() self._stop_event.set()
break break
else: else:
...@@ -78,6 +80,7 @@ class GeneratorEnqueuer(object): ...@@ -78,6 +80,7 @@ class GeneratorEnqueuer(object):
try: try:
task() task()
except Exception: except Exception:
traceback.print_exc()
self._stop_event.set() self._stop_event.set()
break break
......
...@@ -250,6 +250,10 @@ def train_generator(settings, file_list, batch_size, shuffle=True): ...@@ -250,6 +250,10 @@ def train_generator(settings, file_list, batch_size, shuffle=True):
ymin = float(temp_info_box[1]) ymin = float(temp_info_box[1])
w = float(temp_info_box[2]) w = float(temp_info_box[2])
h = float(temp_info_box[3]) h = float(temp_info_box[3])
# Filter out wrong labels
if w < 0 or h < 0:
continue
xmax = xmin + w xmax = xmin + w
ymax = ymin + h ymax = ymin + h
...@@ -285,8 +289,7 @@ def train(settings, ...@@ -285,8 +289,7 @@ def train(settings,
try: try:
enqueuer = GeneratorEnqueuer( enqueuer = GeneratorEnqueuer(
train_generator(settings, file_list, batch_size, shuffle), train_generator(settings, file_list, batch_size, shuffle),
use_multiprocessing=use_multiprocessing, use_multiprocessing=use_multiprocessing)
wait_time=0.5)
enqueuer.start(max_queue_size=max_queue, workers=num_workers) enqueuer.start(max_queue_size=max_queue, workers=num_workers)
generator_output = None generator_output = None
while True: while True:
...@@ -295,7 +298,7 @@ def train(settings, ...@@ -295,7 +298,7 @@ def train(settings,
generator_output = enqueuer.queue.get() generator_output = enqueuer.queue.get()
break break
else: else:
time.sleep(0.5) time.sleep(0.01)
yield generator_output yield generator_output
generator_output = None generator_output = None
finally: finally:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册