• 大小: 1.97MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-18
  • 语言: Python
  • 标签:

资源简介

高效准确的EAST文本检测器的一个TensorFlow实现

资源截图

代码片段和文件信息

‘‘‘
this file is modified from keras implemention of data process multi-threading
see https://github.com/fchollet/keras/blob/master/keras/utils/data_utils.py
‘‘‘
import time
import numpy as np
import threading
import multiprocessing
try:
    import queue
except ImportError:
    import Queue as queue


class GeneratorEnqueuer():
    “““Builds a queue out of a data generator.

    Used in ‘fit_generator‘ ‘evaluate_generator‘ ‘predict_generator‘.

    # Arguments
        generator: a generator function which endlessly yields data
        use_multiprocessing: use multiprocessing if True otherwise threading
        wait_time: time to sleep in-between calls to ‘put()‘
        random_seed: Initial seed for workers
            will be incremented by one for each workers.
    “““

    def __init__(self generator
                 use_multiprocessing=False
                 wait_time=0.05
                 random_seed=None):
        self.wait_time = wait_time
        self._generator = generator
        self._use_multiprocessing = use_multiprocessing
        self._threads = []
        self._stop_event = None
        self.queue = None
        self.random_seed = random_seed

    def start(self workers=1 max_queue_size=10):
        “““Kicks off threads which add data from the generator into the queue.

        # Arguments
            workers: number of worker threads
            max_queue_size: queue size
                (when full threads could block on ‘put()‘)
        “““

        def data_generator_task():
            while not self._stop_event.is_set():
                try:
                    if self._use_multiprocessing or self.queue.qsize() < max_queue_size:
                        generator_output = next(self._generator)
                        self.queue.put(generator_output)
                    else:
                        time.sleep(self.wait_time)
                except Exception:
                    self._stop_event.set()
                    raise

        try:
            if self._use_multiprocessing:
                self.queue = multiprocessing.Queue(maxsize=max_queue_size)
                self._stop_event = multiprocessing.Event()
            else:
                self.queue = queue.Queue()
                self._stop_event = threading.Event()

            for _ in range(workers):
                if self._use_multiprocessing:
                    # Reset random seed else all children processes
                    # share the same seed
                    np.random.seed(self.random_seed)
                    thread = multiprocessing.Process(target=data_generator_task)
                    thread.daemon = True
                    if self.random_seed is not None:
                        self.random_seed += 1
                else:
                    thread = threading.Thread(target=data_generator_task)
                self._threads.append(thread)
                thread.start()
        except:
            self.stop()
            raise

    d

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-08-27 03:10  EAST-master\
     文件        1219  2017-08-27 03:10  EAST-master\.gitignore
     文件       35141  2017-08-27 03:10  EAST-master\LICENSE
     文件           0  2017-08-27 03:10  EAST-master\__init__.py
     文件        4280  2017-08-27 03:10  EAST-master\data_util.py
     目录           0  2017-08-27 03:10  EAST-master\demo_images\
     文件      338376  2017-08-27 03:10  EAST-master\demo_images\img_10.jpg
     文件      117772  2017-08-27 03:10  EAST-master\demo_images\img_14.jpg
     文件      229940  2017-08-27 03:10  EAST-master\demo_images\img_2.jpg
     文件      213424  2017-08-27 03:10  EAST-master\demo_images\img_26.jpg
     文件      174745  2017-08-27 03:10  EAST-master\demo_images\img_75.jpg
     文件      728640  2017-08-27 03:10  EAST-master\demo_images\web-demo.png
     文件         171  2017-08-27 03:10  EAST-master\deploy.sh
     文件        7441  2017-08-27 03:10  EAST-master\eval.py
     文件       30634  2017-08-27 03:10  EAST-master\icdar.py
     目录           0  2017-08-27 03:10  EAST-master\lanms\
     文件          11  2017-08-27 03:10  EAST-master\lanms\.gitignore
     文件        4397  2017-08-27 03:10  EAST-master\lanms\.ycm_extra_conf.py
     文件         365  2017-08-27 03:10  EAST-master\lanms\Makefile
     文件         572  2017-08-27 03:10  EAST-master\lanms\__init__.py
     文件         245  2017-08-27 03:10  EAST-master\lanms\__main__.py
     文件        1596  2017-08-27 03:10  EAST-master\lanms\adaptor.cpp
     目录           0  2017-08-27 03:10  EAST-master\lanms\include\
     目录           0  2017-08-27 03:10  EAST-master\lanms\include\clipper\
     文件      141939  2017-08-27 03:10  EAST-master\lanms\include\clipper\clipper.cpp
     文件       15320  2017-08-27 03:10  EAST-master\lanms\include\clipper\clipper.hpp
     目录           0  2017-08-27 03:10  EAST-master\lanms\include\pybind11\
     文件       18075  2017-08-27 03:10  EAST-master\lanms\include\pybind11\attr.h
     文件        4299  2017-08-27 03:10  EAST-master\lanms\include\pybind11\buffer_info.h
     文件       87115  2017-08-27 03:10  EAST-master\lanms\include\pybind11\cast.h
     文件        6596  2017-08-27 03:10  EAST-master\lanms\include\pybind11\chrono.h
............此处省略37个文件信息

评论

共有 条评论