• 大小: 105.7MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2022-05-07
  • 语言: Python
  • 标签: 文本检测  

资源简介

一个快速的文本检测程序,python语言编写,代码简单实用

资源截图

代码片段和文件信息

‘‘‘
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-10-27 14:22  EAST\
     目录           0  2017-10-27 14:22  EAST\.git\
     目录           0  2017-10-29 20:16  EAST\.git\branches\
     目录           0  2017-10-29 20:16  EAST\.git\hooks\
     目录           0  2017-10-29 20:16  EAST\.git\info\
     目录           0  2017-10-27 14:22  EAST\.git\logs\
     目录           0  2017-10-27 14:22  EAST\.git\logs\refs\
     目录           0  2017-10-29 20:16  EAST\.git\logs\refs\heads\
     目录           0  2017-10-27 14:22  EAST\.git\logs\refs\remotes\
     目录           0  2017-10-29 20:16  EAST\.git\logs\refs\remotes\origin\
     目录           0  2017-10-27 14:22  EAST\.git\objects\
     目录           0  2017-10-29 20:16  EAST\.git\objects\info\
     目录           0  2017-10-29 20:16  EAST\.git\objects\pack\
     目录           0  2017-10-27 14:22  EAST\.git\refs\
     目录           0  2017-10-29 20:16  EAST\.git\refs\heads\
     目录           0  2017-10-27 14:22  EAST\.git\refs\remotes\
     目录           0  2017-10-29 20:16  EAST\.git\refs\remotes\origin\
     目录           0  2017-10-29 20:16  EAST\.git\refs\tags\
     文件        1219  2017-10-27 14:22  EAST\.gitignore
     文件       35141  2017-10-27 14:22  EAST\LICENSE
     文件           0  2017-10-27 14:22  EAST\__init__.py
     目录           0  2017-10-29 20:16  EAST\__pycache__\
     目录           0  2017-10-29 20:16  EAST\copy\
     目录           0  2017-10-27 14:31  EAST\data\
     文件         277  2017-10-27 14:31  EAST\data\checkpoint
     目录           0  2017-10-29 20:16  EAST\data\east_icdar2015_resnet_v1_50_rbox\
     目录           0  2017-10-29 20:16  EAST\data\image_char\
     目录           0  2017-10-29 20:16  EAST\data\model\
     目录           0  2017-10-27 14:21  EAST\data\ocr\
     目录           0  2017-10-29 20:16  EAST\data\ocr\icdar2015\
     目录           0  2017-10-29 20:16  EAST\data\output\
............此处省略373个文件信息

评论

共有 条评论