WO2023050673A1 - Image caching method and apparatus, and electronic device, storage medium and computer program product - Google Patents

Image caching method and apparatus, and electronic device, storage medium and computer program product Download PDF

Info

Publication number
WO2023050673A1
WO2023050673A1 PCT/CN2022/074698 CN2022074698W WO2023050673A1 WO 2023050673 A1 WO2023050673 A1 WO 2023050673A1 CN 2022074698 W CN2022074698 W CN 2022074698W WO 2023050673 A1 WO2023050673 A1 WO 2023050673A1
Authority
WO
WIPO (PCT)
Prior art keywords
images
training
training process
processes
groups
Prior art date
Application number
PCT/CN2022/074698
Other languages
French (fr)
Chinese (zh)
Inventor
王志宏
Original Assignee
上海商汤智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 上海商汤智能科技有限公司 filed Critical 上海商汤智能科技有限公司
Publication of WO2023050673A1 publication Critical patent/WO2023050673A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/60Memory management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • the present application relates to the technical field of computer vision, and in particular to an image caching method, device, electronic equipment, storage medium and computer program product.
  • the training process of the neural network is divided into two parts: data processing and training.
  • the data processing stage mainly includes the two steps of reading pictures from the hard disk and preprocessing the pictures.
  • multiple processes are started on a physical machine to use multiple graphics cards for training at the same time.
  • Embodiments of the present disclosure expect to provide an image caching method, device, electronic equipment, storage medium, and computer program product.
  • An embodiment of the present disclosure provides an image caching method, including:
  • each training process in multiple training processes to read a group of images to obtain multiple groups of images; wherein, the multiple training processes correspond to the multiple groups of images one-to-one;
  • each training process in the plurality of training processes respectively cache a group of images read in the plurality of groups of images into the shared memory for each training process in the plurality of training processes During the execution of the neural network training step, the plurality of sets of images are read from the shared memory.
  • each training process in multiple training processes to read a group of images to obtain multiple groups of images including:
  • each training process in the multiple training processes based on the image path list, according to the corresponding preset image reading strategy, read a group of images from the image data set to obtain the multiple groups of images .
  • the method before applying for the shared memory corresponding to the plurality of groups of images using the first training process in the plurality of training processes, the method further includes:
  • each training process in the plurality of training processes calculate the memory size required to support the caching of a group of images read in the plurality of groups of images, and obtain a plurality of memories corresponding to the plurality of groups of images one-to-one. size;
  • Using the first training process in the multiple training processes to apply for the shared memory corresponding to the multiple groups of images includes:
  • each training process in the plurality of training processes is used to calculate the memory size required to support the caching of the corresponding group of images in the plurality of groups of images, and to obtain the memory size corresponding to the plurality of groups of images.
  • the method also includes:
  • each training process in the multiple training processes uses each training process in the multiple training processes to sum up the multiple memory sizes to obtain the overall memory size.
  • each training process in the plurality of training processes is used to calculate the memory size required to support the caching of a group of images read in the plurality of groups of images, and to obtain the memory size corresponding to the plurality of groups of images
  • One-to-one correspondence with multiple memory sizes including:
  • each training process in the plurality of training processes to obtain shape information of a group of images read in the plurality of groups of images;
  • each training process in the plurality of training processes calculates the memory size required by a group of images that support cache reading, and obtain the described Multiple memory sizes.
  • the method further includes:
  • each training process in the plurality of training processes to summarize the shape information of the multiple groups of images to obtain an information summary result.
  • An embodiment of the present disclosure provides an image caching device, including:
  • the reading module is configured to use each training process in multiple training processes to read a group of images to obtain multiple groups of images; wherein, the multiple training processes correspond to the multiple groups of images one-to-one;
  • the processing module is configured to use the first training process in the plurality of training processes to apply for the shared memory corresponding to the plurality of groups of images, and share the applied for shared memory to the plurality of training processes and all each training session different from the first training session;
  • the caching module is configured to use each training process in the plurality of training processes to respectively cache a group of images read in the plurality of groups of images into the shared memory for the plurality of training processes Each training process reads the multiple sets of images from the shared memory during the execution of the neural network training step.
  • the reading module is specifically configured to use the second training process in the plurality of training processes to read the image path list that records the storage path of each image in the image data set, and store the image path
  • the list is broadcast to each training process different from the second training process in the plurality of training processes; using each training process in the plurality of training processes, based on the image path list, according to the corresponding preset image
  • the reading strategy is to read a group of images from the image data set to obtain the multiple groups of images.
  • the processing module is further configured to use each training process in the plurality of training processes to calculate the memory size required to support the caching of a group of images read in the plurality of groups of images, and obtain the same as Multiple memory sizes corresponding to the multiple groups of images one-to-one; using the first training process, summarizing the multiple memory sizes to obtain an overall memory size that supports storage of the multiple groups of images;
  • the processing module is specifically configured to use the first training process to apply for the shared memory according to the overall memory size.
  • the processing module is further configured to use each training process in the multiple training processes to summarize the multiple memory sizes to obtain the overall memory size.
  • the processing module is specifically configured to use each training process in the plurality of training processes to acquire the shape information of a group of images read in the plurality of groups of images;
  • Each training process in the training process according to the shape information of a group of images read in the plurality of groups of images, calculates the memory size required by a group of images that support cache reading, and obtains the multiple memory sizes.
  • the processing module is further configured to use each training process in the multiple training processes to summarize the shape information of the multiple groups of images to obtain an information summary result.
  • An embodiment of the present disclosure provides an electronic device, and the electronic device includes: a processor, a memory, and a communication bus; wherein,
  • the communication bus is configured to realize connection and communication between the processor and the memory
  • the processor is configured to execute one or more programs stored in the memory, so as to implement the above image caching method.
  • An embodiment of the present disclosure provides a computer-readable storage medium, the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to realize the above image caching method.
  • An embodiment of the present disclosure provides a computer program product, the computer program product includes a computer program or an instruction, and when the computer program or instruction is run on a computer, the computer is caused to execute the above image caching method.
  • Embodiments of the present disclosure provide an image caching method, device, electronic equipment, storage medium, and computer program product.
  • the method includes: using each training process in multiple training processes to read a group of images to obtain multiple groups of images; Wherein, a plurality of training processes are in one-to-one correspondence with multiple groups of images; using the first training process in the multiple training processes, apply for shared memory corresponding to multiple groups of images, and share the applied shared memory to multiple training processes and Each training process that is different from the first training process; using each training process in the multiple training processes, respectively cache a group of images read in the multiple groups of images to the shared memory for each of the multiple training processes Each training process reads sets of images from shared memory during the neural network training steps.
  • the technical solution provided by the embodiments of the present disclosure utilizes the training process to pre-cache the images to be applied during the neural network training phase into the shared memory, thereby increasing the image reading speed and improving the training efficiency of the neural network.
  • FIG. 1 is a schematic flowchart of an image caching method provided by an embodiment of the present disclosure
  • FIG. 2 is a schematic diagram of an exemplary training process cache image provided by an embodiment of the present disclosure
  • FIG. 3 is a schematic structural diagram of an image caching device provided by an embodiment of the present disclosure.
  • Fig. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure.
  • first ⁇ second ⁇ third involved in the embodiments of the present disclosure is only to distinguish similar objects, and does not represent a specific ordering of objects. Understandably, “first ⁇ second ⁇ third "Where permitted, the preset order or sequence may be interchanged so that the embodiments of the disclosure described herein can be practiced in an order other than that illustrated or described herein.
  • An embodiment of the present disclosure provides an image caching method, which may be executed by an image caching device.
  • the image caching method may be executed by a terminal device or a server or other electronic devices, wherein the terminal device may be a user equipment (User Equipment, UE), mobile devices, user terminals, cellular phones, cordless phones, personal digital assistants (Personal Digital Assistant, PDA), handheld devices, computing devices, vehicle-mounted devices, wearable devices, etc.
  • the image caching method may be implemented by a processor invoking computer-readable instructions stored in a memory.
  • FIG. 1 is a schematic flowchart of an image caching method provided by an embodiment of the present disclosure. As shown in Figure 1, in the embodiment of the present disclosure, the image caching method mainly includes the following steps:
  • the image caching device uses multiple training processes to read multiple sets of images.
  • multiple sets of images are actually stored on the hard disk, and the image cache device can read a set of images by using each training process in multiple training processes, that is, multiple The training process is in one-to-one correspondence with multiple sets of images.
  • the specific number of training processes and the images read by each training process can be set according to actual needs and application scenarios, which are not limited in this embodiment of the present disclosure.
  • a neural network training step may be performed for training the neural network.
  • a group of images read by each training process may include one or more frames of images, and the specific number of images included in each group of images may be set according to actual needs.
  • the embodiments of the present disclosure are not limited.
  • the image processing device uses each of the multiple training processes to read a set of images to obtain multiple sets of images, including: using the second training process among the multiple training processes, reading the image path list that records the storage path of each image in the image dataset, and broadcasting the image path list to each of the plurality of training processes that is different from the second training process; utilizing each of the plurality of training processes , based on the image path list, according to the corresponding preset image reading strategy, read a group of images from the image data set to obtain multiple groups of images.
  • the multiple training processes include the first training process, wherein the first training process is used to realize the application and sharing of the shared memory, which will be detailed in the subsequent steps, and the second
  • the second training process can be the same training process as the first training process, of course, it can also be any training process different from the first training process among multiple training processes.
  • the specific second training process can be set according to actual needs and application scenarios, and is not limited in this embodiment of the present disclosure.
  • the storage path of each image in the image data set is recorded in the image path list, and the image cache device uses the second training process to read the image path list and broadcast it to multiple training processes Each training process that is different from the second training process, thereby realizing that each training process in multiple training processes knows the storage path of each image in the image data set, so that the image cache device can use the storage path of each image in the multiple training processes Each training process reads a set of images based on the image path list.
  • each of the multiple training processes is set with a corresponding preset image reading strategy, which indicates that the training thread needs to read a set of images from the image data set. group of images, that is, each training thread actually reads part of the images in the image dataset separately.
  • the multiple training processes are three training processes, specifically including: training process 1, training process 2, and training process 3, wherein the preset image reading strategy corresponding to training process 1 is to read the previous One third of the images, that is, the set of images read by training process 1 is the first third of the images recorded in the image path list in the image data set, and the preset image reading strategy corresponding to training process 2 is Read the middle third of the images recorded in the image path list, and the preset image reading strategy corresponding to training process 3 is to read the last third of the images recorded in the image path list, that is, use three training processes , which can realize the reading of all images in the image dataset.
  • the specific preset image reading strategy corresponding to each training process can be set according to actual needs and application scenarios, and is not limited in this embodiment of the present disclosure.
  • multiple sets of images may cover the entire image data set, and of course, may also cover only some specific images in the image data set, which is not limited in the embodiments of the present disclosure.
  • the image caching device when multiple sets of images are read by the image caching device using multiple training processes, use the first training process in the multiple training processes to apply for the shared memory corresponding to the multiple sets of images, and Sharing the applied for shared memory to each training process different from the first training process among the multiple training processes.
  • the first training process may be any training process among multiple training processes, or may be a specific training process among multiple preset training processes, which may be related to
  • the above-mentioned second training process is the same training process, and may also be a different training process from the above-mentioned second training process, which is not limited in this embodiment of the present disclosure.
  • the image caching device after the image caching device applies for the shared memory through the first training process, it can share the shared memory with other training processes. Specifically, the image caching device can use the first training process to send the descriptor pointing to the shared memory to other training processes, and the other training processes can learn the specific shared memory according to the descriptor.
  • the image caching device may perform the following steps before applying for the shared memory corresponding to multiple groups of images using the first training process among the multiple training processes: using each of the multiple training processes to train process, calculate the memory size required to support caching a group of images read in multiple groups of images, and obtain multiple memory sizes corresponding to multiple groups of images; use the first training process to summarize multiple memory sizes, and obtain The overall memory size that supports storing multiple sets of images; correspondingly, the image cache device uses the first training process in multiple training processes to apply for shared memory corresponding to multiple sets of images, including: using the first training process, according to the overall memory size Apply for shared memory.
  • each training process when each training process reads a set of images, it can calculate the memory size required for caching the set of images, in fact, it is to calculate the set of images The image data size of the image.
  • communication and interaction can be performed between multiple training processes, and each training process different from the first training process can use the calculated set of images that support cache reading Notify the memory size to the first training process, the first training process can summarize the multiple memory sizes corresponding to multiple sets of images, so as to obtain the overall memory size that supports storing multiple sets of images, and then apply for a share that matches the overall memory size Memory, that is, the shared memory corresponding to multiple sets of images.
  • the overall memory size is actually the image data size of multiple sets of images.
  • the image caching device uses each training process in multiple training processes to calculate the memory size required to support caching a group of images read in multiple groups of images, and obtain the Like one-to-one correspondence of multiple memory sizes, including: using each training process in multiple training processes to obtain the shape information of a set of images read in multiple sets of images; using each training process in multiple training processes , according to the shape information of a group of images read in multiple groups of images, calculate the memory size required by a group of images that support cache reading, and obtain multiple memory sizes.
  • the image caching device can use each training process in multiple training processes to acquire the shape information of a group of images read, wherein, for a frame of image, its The shape information can include information such as the data type of the image, and each training process can calculate the memory size required by a group of images that support cache reading according to the shape information of a corresponding group of images.
  • the image caching device uses each training process in multiple training processes to calculate the memory size required to support caching a group of images read in multiple groups of images, and obtain the After one-to-one correspondence of multiple memory sizes, the following steps can also be performed: use each training process in multiple training processes to aggregate multiple memory sizes to obtain the overall memory size.
  • each training process when the image caching device uses each training process to calculate the memory size required by a group of images that support cache reading, it can also use each training process to perform Aggregation of multiple memory sizes, so that each training process can learn the size of multiple sets of images.
  • the following steps may also be performed: respectively Using each training process in the multiple training processes, the shape information of multiple groups of images is summarized to obtain an information summary result.
  • the image caching device in the case that the image caching device obtains the shape information of a group of read images by using each training process, it can also use each training process to perform multiple sets of images respectively. Like the summary of shape information, so that each training process can learn the shape information of multiple sets of images, so that each training process can be based on the learned shape information when reading images from the shared memory. The selection of a specific image is then read.
  • each training process in the multiple training processes respectively cache a group of images read in multiple groups of images to the shared memory, so that each training process in the multiple training processes executes the neural network training step During the period, multiple sets of images are read from the shared memory.
  • the image caching device uses the first training process to share the shared memory to other training processes in the multiple training processes, that is, the multiple training processes all know the shared memory, so that each of the multiple training processes can use
  • Each training process caches a group of images read from multiple groups of images to the shared memory.
  • the image caching device uses each training process in the multiple training processes to respectively cache a group of images read from the multiple groups of images into the shared memory, which is actually Realized that multiple groups of images are all cached in shared memory.
  • the image can be read from the shared memory.
  • the cache in the shared memory can be read Any image in the multiple groups of images is used for neural network training, thereby improving the image reading speed, and correspondingly, also improving the neural network training speed.
  • the above-mentioned image caching method is preferably applicable to neural network training, and the amount of single-frame image data used for training is relatively large, but the total image data of the image is relatively small , that is, the application scenario with a small number of images.
  • FIG. 2 is a schematic diagram of an exemplary training process cache image provided by an embodiment of the present disclosure.
  • training process 1 reads the image path list, and then broadcasts the path list to training process 2 and training process 3.
  • Each training process determines a set of images that it needs to read according to the image path list, and reads a corresponding set of pictures from the hard disk.
  • Each training process calculates the memory size required to cache these pictures in this process based on the read pictures, and then summarizes them, so that all training processes know the size of the entire image data set.
  • Training process 1 applies for the corresponding shared memory according to the aggregated overall memory size, and shares this shared memory with other processes.
  • each process caches the image it read before into the corresponding location of the shared memory, and each subsequent process can read the image in the shared memory during the training process.
  • An embodiment of the present disclosure provides an image caching method, including: using each training process in multiple training processes to read a set of images to obtain multiple sets of images; wherein, multiple training processes and multiple sets of images are one by one Corresponding; using the first training process in the multiple training processes, applying for shared memory corresponding to multiple groups of images, and sharing the applied shared memory to each training process different from the first training process in the multiple training processes; using multiple training processes Each training process in each training process caches a group of images read in multiple groups of images to the shared memory, so that each training process in multiple training processes can read from Read multiple sets of images in shared memory.
  • the image caching method provided by the embodiments of the present disclosure utilizes the training process to pre-cache the images to be applied during the neural network training phase into the shared memory, thereby increasing the image reading speed and improving the neural network training efficiency.
  • FIG. 3 is a schematic structural diagram of an image caching device provided by an embodiment of the present disclosure. As shown in Figure 3, the image cache device includes:
  • the reading module 301 is configured to use each training process in multiple training processes to read a group of images to obtain multiple groups of images; wherein, the multiple training processes correspond to the multiple groups of images one by one;
  • the processing module 302 is configured to use the first training process in the multiple training processes to apply for the shared memory corresponding to the multiple groups of images, and share the applied shared memory to the multiple training processes and each training session different from the first training session;
  • the caching module 303 is configured to use each training process in the plurality of training processes to respectively cache a group of images read in the plurality of groups of images into the shared memory for the plurality of training Each training process in the process reads the multiple groups of images from the shared memory during the execution of the neural network training step.
  • the reading module 301 is specifically configured to use the second training process in the plurality of training processes to read the image path list that records the storage path of each image in the image data set, and
  • the image path list is broadcast to each training process different from the second training process in the plurality of training processes; using each training process in the plurality of training processes, based on the image path list, according to the corresponding
  • the preset image reading strategy reads a group of images from the image data set to obtain the multiple groups of images.
  • the processing module 302 is further configured to use each training process in the plurality of training processes to calculate the memory required to support caching a set of images read in the multiple sets of images size, to obtain a plurality of memory sizes corresponding to the plurality of groups of images; using the first training process, summarizing the plurality of memory sizes, and obtaining an overall memory size that supports storage of the plurality of groups of images;
  • the processing module 302 is specifically configured to use the first training process to apply for the shared memory according to the overall memory size.
  • the processing module 302 is further configured to use each training process in the multiple training processes to summarize the multiple memory sizes to obtain the overall memory size.
  • the processing module 302 is specifically configured to use each training process in the multiple training processes to acquire the shape information of a set of images read in the multiple sets of images;
  • Each training process in the plurality of training processes according to the shape information of a group of images read in the plurality of groups of images, calculates the memory size required by a group of images that support cache reading, and obtains the plurality of memory size.
  • the processing module 302 is further configured to respectively use each training process in the multiple training processes to summarize the shape information of the multiple groups of images to obtain an information summary result.
  • FIG. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure.
  • the electronic device includes: a processor 401, a memory 402, and a communication bus 403; wherein,
  • the communication bus 403 is configured to realize connection and communication between the processor 401 and the memory 402;
  • the processor 401 is configured to execute one or more programs stored in the memory 402 to implement the image caching method described above.
  • An embodiment of the present disclosure provides a computer-readable storage medium, the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to realize the above image caching method.
  • the computer-readable storage medium can be a volatile memory (volatile memory), such as a random access memory (Random-Access Memory, RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (Read-Only Memory).
  • ROM Read Only Memory
  • flash memory flash memory
  • HDD Hard Disk Drive
  • SSD Solid-State Drive
  • An embodiment of the present disclosure provides a computer program product, the computer program product includes a computer program or an instruction, and when the computer program or instruction is run on a computer, the computer is made to execute the above-mentioned image caching method.
  • the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Accordingly, the present disclosure may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) having computer-usable program code embodied therein.
  • a computer-usable storage media including but not limited to disk storage, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable signal processing device to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
  • the device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
  • Embodiments of the present disclosure provide an image caching method, device, electronic equipment, storage medium, and computer program product, wherein the method includes: using each training process in multiple training processes to read a set of images to obtain multiple sets of images Image; among them, multiple training processes correspond to multiple groups of images one by one; use the first training process in multiple training processes to apply for shared memory corresponding to multiple groups of images, and share the applied shared memory to multiple training processes In each training process different from the first training process; each training process in multiple training processes is used to cache a group of images read in multiple groups of images to shared memory for multiple training processes Each training process in , reads multiple sets of images from shared memory during the neural network training steps.
  • the technical solution provided by the embodiments of the present disclosure utilizes the training process to pre-cache the images to be applied during the neural network training phase into the shared memory, thereby increasing the image reading speed and improving the training efficiency of the neural network.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Biomedical Technology (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Image Analysis (AREA)

Abstract

Provided in the present disclosure are an image caching method and apparatus, and an electronic device, a storage medium and a computer program product. The method comprises: using each of a plurality of training processes to read a group of images, so as to obtain a plurality of groups of images, wherein the plurality of training processes correspond to the plurality of groups of images on a one-to-one basis; using a first training process in the plurality of training processes to apply for a shared memory corresponding to the plurality of groups of images, and sharing the shared memory, obtained by means of the application, to each of the plurality of training processes that is different from the first training process; and using each of the plurality of training processes to respectively cache, to the shared memory, the group of images read from the plurality of groups of images, such that each of the plurality of training processes reads the plurality of groups of images from the shared memory during the process of executing a neural network training step.

Description

一种图像缓存方法、装置、电子设备、存储介质及计算机程序产品Image caching method, device, electronic equipment, storage medium and computer program product
相关申请的交叉引用Cross References to Related Applications
本申请基于申请号为202111145887.X、申请日为2021年09月28日,申请名称为“一种图像缓存方法、装置、电子设备及可读存储介质”的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此以引入方式结合在本申请中。This application is based on the Chinese patent application with the application number 202111145887.X, the application date is September 28, 2021, and the application name is "An Image Caching Method, Device, Electronic Equipment, and Readable Storage Medium", and requires the Chinese The priority of the patent application, the entire content of the Chinese patent application is hereby incorporated in this application by reference.
技术领域technical field
本申请涉及计算机视觉技术领域,尤其涉及一种图像缓存方法、装置、电子设备、存储介质及计算机程序产品。The present application relates to the technical field of computer vision, and in particular to an image caching method, device, electronic equipment, storage medium and computer program product.
背景技术Background technique
神经网络的训练过程分为数据处理和训练两个部分,其中,数据处理阶段主要包含从硬盘中读取图片和对图片进行预处理两个步骤的操作。通常地,为了提高训练速度,会在一台物理机上,启动多个进程来同时利用多张显卡进行训练。The training process of the neural network is divided into two parts: data processing and training. Among them, the data processing stage mainly includes the two steps of reading pictures from the hard disk and preprocessing the pictures. Usually, in order to improve the training speed, multiple processes are started on a physical machine to use multiple graphics cards for training at the same time.
目前,当单个图片的数据比较大的时候,数据处理阶段内,读图片的时间会非常长,那么可能出现训练进程利用前一个图像已经进行了神经网络的训练,而下一个图像还在读取,无法很好地将数据处理和训练并行运行,图像读取耗费时间过长,从而导致神经网络的训练效率较低。At present, when the data of a single image is relatively large, it takes a very long time to read the image during the data processing stage, so it may happen that the training process uses the previous image to train the neural network, while the next image is still being read , data processing and training cannot be well run in parallel, and image reading takes too long, resulting in low training efficiency of the neural network.
发明内容Contents of the invention
本公开实施例期望提供一种图像缓存方法、装置、电子设备、存储介质及计算机程序产品。Embodiments of the present disclosure expect to provide an image caching method, device, electronic equipment, storage medium, and computer program product.
本公开实施例的技术方案是这样实现的:The technical scheme of the embodiment of the present disclosure is realized in this way:
本公开实施例提供了一种图像缓存方法,包括:An embodiment of the present disclosure provides an image caching method, including:
利用多个训练进程中每个训练进程读取一组图像,得到多组图像;其中,所述多个训练进程与所述多组图像一一对应;Using each training process in multiple training processes to read a group of images to obtain multiple groups of images; wherein, the multiple training processes correspond to the multiple groups of images one-to-one;
利用所述多个训练进程中第一训练进程,申请所述多组图像对应的共享内存,并将申请到的所述共享内存共享至所述多个训练进程中与所述第一训练进程不同的每个训练进程;Using the first training process among the plurality of training processes, apply for the shared memory corresponding to the plurality of groups of images, and share the applied shared memory to the plurality of training processes with the first training process different for each training process;
利用所述多个训练进程中每个训练进程,分别将所述多组图像中读取的一组图像,缓存至所述共享内存,以供所述多个训练进程中每个训练进程在执行神经网络训练步骤的期间,从所述共享内存中读取所述多组图像。Using each training process in the plurality of training processes, respectively cache a group of images read in the plurality of groups of images into the shared memory for each training process in the plurality of training processes During the execution of the neural network training step, the plurality of sets of images are read from the shared memory.
在上述方法中,所述利用多个训练进程中每个训练进程读取一组图像,得到多组图像,包括:In the above method, the use of each training process in multiple training processes to read a group of images to obtain multiple groups of images, including:
利用所述多个训练进程中第二训练进程,读取记录图像数据集中每个图像的存储路径的图像路径列表,并将所述图像路径列表广播至所述多个训练进程中与所述第二训练进程不同的每个训练进程;Using the second training process in the plurality of training processes, read the image path list recording the storage path of each image in the image data set, and broadcast the image path list to the plurality of training processes and the first training process Two different training processes for each training process;
利用所述多个训练进程中每个训练进程,基于所述图像路径列表,按照对应的预设图像读取策略,从所述图像数据集中读取一组图像,得到所述多组图像。Using each training process in the multiple training processes, based on the image path list, according to the corresponding preset image reading strategy, read a group of images from the image data set to obtain the multiple groups of images .
在上述方法中,所述利用所述多个训练进程中第一训练进程,申请所述多组图像对应的共享内存之前,所述方法还包括:In the above method, before applying for the shared memory corresponding to the plurality of groups of images using the first training process in the plurality of training processes, the method further includes:
利用所述多个训练进程中每个训练进程,计算支持缓存所述多组图像中读取的一组图像需求的内存大小,得到与所述多组图像一一对应的多个内存大小;Using each training process in the plurality of training processes, calculate the memory size required to support the caching of a group of images read in the plurality of groups of images, and obtain a plurality of memories corresponding to the plurality of groups of images one-to-one. size;
利用所述第一训练进程,汇总所述多个内存大小,得到支持存储所述多组图像的整体内存大小;Using the first training process, summarizing the multiple memory sizes to obtain an overall memory size that supports storage of the multiple groups of images;
所述利用所述多个训练进程中第一训练进程,申请所述多组图像对应的共享内存,包括:Using the first training process in the multiple training processes to apply for the shared memory corresponding to the multiple groups of images includes:
利用所述第一训练进程,根据所述整体内存大小申请所述共享内存。Applying for the shared memory according to the overall memory size by using the first training process.
在上述方法中,所述利用所述多个训练进程中每个训练进程,计算支持缓存所述多组图像中对应一组图像需求的内存大小,得到与所述多组图像一一对应的多个内存大小之后,所述方法还包括:In the above method, the use of each training process in the plurality of training processes is used to calculate the memory size required to support the caching of the corresponding group of images in the plurality of groups of images, and to obtain the memory size corresponding to the plurality of groups of images. After the corresponding multiple memory sizes, the method also includes:
分别利用所述多个训练进程中每个训练进程,汇总所述多个内存大小,得到所述整体内存大小。Using each training process in the multiple training processes to sum up the multiple memory sizes to obtain the overall memory size.
在上述方法中,所述利用所述多个训练进程中每个训练进程,计算支持缓存所述多组图像中读取的一组图像需求的内存大小,得到与所述多组图像一一对应的多个内存大小,包括:In the above method, the use of each training process in the plurality of training processes is used to calculate the memory size required to support the caching of a group of images read in the plurality of groups of images, and to obtain the memory size corresponding to the plurality of groups of images One-to-one correspondence with multiple memory sizes, including:
利用所述多个训练进程中每个训练进程,获取所述多组图像中读取的一组图像的形状信息;Using each training process in the plurality of training processes to obtain shape information of a group of images read in the plurality of groups of images;
利用所述多个训练进程中每个训练进程,根据所述多组图像中读取的一组图像的形状信息,计算支持缓存读取的一组图像需求的内存大小,得到所述多个内存大小。Using each training process in the plurality of training processes, according to the shape information of a group of images read in the plurality of groups of images, calculate the memory size required by a group of images that support cache reading, and obtain the described Multiple memory sizes.
在上述方法中,所述利用所述多个训练进程中每个训练进程,获取所述多组图像中读取的一组图像的形状信息之后,所述方法还包括:In the above method, after acquiring the shape information of a group of images read in the plurality of groups of images by using each of the plurality of training processes, the method further includes:
分别利用所述多个训练进程中每个训练进程,汇总所述多组图像的形状信息,得到信息汇总结果。Using each training process in the plurality of training processes to summarize the shape information of the multiple groups of images to obtain an information summary result.
本公开实施例提供了一种图像缓存装置,包括:An embodiment of the present disclosure provides an image caching device, including:
读取模块,配置为利用多个训练进程中每个训练进程读取一组图像,得到多组图像;其中,所述多个训练进程与所述多组图像一一对应;The reading module is configured to use each training process in multiple training processes to read a group of images to obtain multiple groups of images; wherein, the multiple training processes correspond to the multiple groups of images one-to-one;
处理模块,配置为利用所述多个训练进程中第一训练进程,申请所述多组图像对应的共享内存,并将申请到的所述共享内存共享至所述多个训练进程中与所述第一训练进程不同的每个训练进程;The processing module is configured to use the first training process in the plurality of training processes to apply for the shared memory corresponding to the plurality of groups of images, and share the applied for shared memory to the plurality of training processes and all each training session different from the first training session;
缓存模块,配置为利用所述多个训练进程中每个训练进程,分别将所述多组图像中读取的一组图像,缓存至所述共享内存,以供所述多个训练进程中每个训练进程在执行神经网络训练步骤的期间,从所述共享内存中读取所述多组图像。The caching module is configured to use each training process in the plurality of training processes to respectively cache a group of images read in the plurality of groups of images into the shared memory for the plurality of training processes Each training process reads the multiple sets of images from the shared memory during the execution of the neural network training step.
在上述装置中,所述读取模块,具体配置为利用所述多个训练进程中第二训练进程,读取记录图像数据集中每个图像的存储路径的图像路径列表,并将所述图像路径列表广播至所述多个训练进程中与所述第二训练进程不同的每个训练进程;利用所述多个训练进程中每个训练进程,基于所述图像路径列表,按照对应的预设图像读取策略,从所述图像数据集中读取一组图像,得到所述多组图像。In the above device, the reading module is specifically configured to use the second training process in the plurality of training processes to read the image path list that records the storage path of each image in the image data set, and store the image path The list is broadcast to each training process different from the second training process in the plurality of training processes; using each training process in the plurality of training processes, based on the image path list, according to the corresponding preset image The reading strategy is to read a group of images from the image data set to obtain the multiple groups of images.
在上述装置中,所述处理模块,还配置为利用所述多个训练进程中每个训练进程,计算支持缓存所述多组图像中读取的一组图像需求的内存大小,得到与所述多组图像一一对应的多个内存大小;利用所述第一训练进程,汇总所述多个内存大小,得到支持存储所述多组图像的整体内存大小;In the above device, the processing module is further configured to use each training process in the plurality of training processes to calculate the memory size required to support the caching of a group of images read in the plurality of groups of images, and obtain the same as Multiple memory sizes corresponding to the multiple groups of images one-to-one; using the first training process, summarizing the multiple memory sizes to obtain an overall memory size that supports storage of the multiple groups of images;
所述处理模块,具体配置为利用所述第一训练进程,根据所述整体内存大小申请所 述共享内存。The processing module is specifically configured to use the first training process to apply for the shared memory according to the overall memory size.
在上述装置中,所述处理模块,还配置为分别利用所述多个训练进程中每个训练进程,汇总所述多个内存大小,得到所述整体内存大小。In the above device, the processing module is further configured to use each training process in the multiple training processes to summarize the multiple memory sizes to obtain the overall memory size.
在上述装置中,所述处理模块,具体配置为利用所述多个训练进程中每个训练进程,获取所述多组图像中读取的一组图像的形状信息;利用所述多个训练进程中每个训练进程,根据所述多组图像中读取的一组图像的形状信息,计算支持缓存读取的一组图像需求的内存大小,得到所述多个内存大小。In the above device, the processing module is specifically configured to use each training process in the plurality of training processes to acquire the shape information of a group of images read in the plurality of groups of images; Each training process in the training process, according to the shape information of a group of images read in the plurality of groups of images, calculates the memory size required by a group of images that support cache reading, and obtains the multiple memory sizes.
在上述装置中,所述处理模块,还配置为分别利用所述多个训练进程中每个训练进程,汇总所述多组图像的形状信息,得到信息汇总结果。In the above device, the processing module is further configured to use each training process in the multiple training processes to summarize the shape information of the multiple groups of images to obtain an information summary result.
本公开实施例提供了一种电子设备,所述电子设备包括:处理器、存储器和通信总线;其中,An embodiment of the present disclosure provides an electronic device, and the electronic device includes: a processor, a memory, and a communication bus; wherein,
所述通信总线,配置为实现所述处理器和所述存储器之间的连接通信;The communication bus is configured to realize connection and communication between the processor and the memory;
所述处理器,配置为执行所述存储器中存储的一个或者多个程序,以实现上述图像缓存方法。The processor is configured to execute one or more programs stored in the memory, so as to implement the above image caching method.
本公开实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有一个或者多个程序,所述一个或者多个程序可以被一个或者多个处理器执行,以实现上述图像缓存方法。An embodiment of the present disclosure provides a computer-readable storage medium, the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to realize the above image caching method.
本公开实施例提供了一种计算机程序产品,所述计算机程序产品包括计算机程序或指令,在所述计算机程序或指令在计算机上运行的情况下,使所述计算机执行上述图像缓存方法。An embodiment of the present disclosure provides a computer program product, the computer program product includes a computer program or an instruction, and when the computer program or instruction is run on a computer, the computer is caused to execute the above image caching method.
本公开实施例提供了一种图像缓存方法、装置、电子设备、存储介质及计算机程序产品,方法包括:利用多个训练进程中每个训练进程读取一组图像,得到多组图像;其中,多个训练进程与多组图像一一对应;利用多个训练进程中第一训练进程,申请多组图像对应的共享内存,并将申请到的共享内存共享至多个训练进程中与第一训练进程不同的每个训练进程;利用多个训练进程中每个训练进程,分别将多组图像中读取的一组图像,缓存至共享内存,以供多个训练进程中每个训练进程在执行神经网络训练步骤的期间,从共享内存中读取多组图像。本公开实施例提供的技术方案,利用训练进程,将神经网络训练阶段需要应用的图像预先缓存到共享内存中,从而提高图像读取速度,提高神经网络训练效率。Embodiments of the present disclosure provide an image caching method, device, electronic equipment, storage medium, and computer program product. The method includes: using each training process in multiple training processes to read a group of images to obtain multiple groups of images; Wherein, a plurality of training processes are in one-to-one correspondence with multiple groups of images; using the first training process in the multiple training processes, apply for shared memory corresponding to multiple groups of images, and share the applied shared memory to multiple training processes and Each training process that is different from the first training process; using each training process in the multiple training processes, respectively cache a group of images read in the multiple groups of images to the shared memory for each of the multiple training processes Each training process reads sets of images from shared memory during the neural network training steps. The technical solution provided by the embodiments of the present disclosure utilizes the training process to pre-cache the images to be applied during the neural network training phase into the shared memory, thereby increasing the image reading speed and improving the training efficiency of the neural network.
附图说明Description of drawings
为了更清楚地说明本公开实施例或背景技术中的技术方案,下面将对本公开实施例或背景技术中所需要使用的附图进行说明。In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the background art, the following will describe the drawings that need to be used in the embodiments of the present disclosure or the background art.
此处的附图被并入说明书中并构成本说明书的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。The accompanying drawings here are incorporated into the description and constitute a part of the present description. These drawings show embodiments consistent with the present disclosure, and are used together with the description to explain the technical solution of the present disclosure.
图1为本公开实施例提供的一种图像缓存方法的流程示意图;FIG. 1 is a schematic flowchart of an image caching method provided by an embodiment of the present disclosure;
图2为本公开实施例提供的一种示例性的训练进程缓存图像的示意图;FIG. 2 is a schematic diagram of an exemplary training process cache image provided by an embodiment of the present disclosure;
图3为本公开实施例提供的一种图像缓存装置的结构示意图;FIG. 3 is a schematic structural diagram of an image caching device provided by an embodiment of the present disclosure;
图4为本公开实施例提供的一种电子设备的结构示意图。Fig. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例 是本公开一部分实施例,而不是全部的实施例。以下实施例用于说明本公开,但不用来限制本公开的范围。基于本公开中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments It is a part of the embodiments of the present disclosure, but not all of them. The following examples are used to illustrate the present disclosure, but not to limit the scope of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present disclosure.
在以下的描述中,涉及到“一些实施例”,其描述了所有可能实施例的子集,但是可以理解,“一些实施例”可以是所有可能实施例的相同子集或不同子集,并且可以在不冲突的情况下相互结合。In the following description, references to "some embodiments" describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or a different subset of all possible embodiments, and Can be combined with each other without conflict.
需要指出,本公开实施例所涉及的术语“第一\第二\第三”仅仅是是区别类似的对象,不代表针对对象的特定排序,可以理解地,“第一\第二\第三”在允许的情况下可以互换预设的顺序或先后次序,以使这里描述的本公开实施例能够以除了在这里图示或描述的以外的顺序实施。It should be pointed out that the term "first\second\third" involved in the embodiments of the present disclosure is only to distinguish similar objects, and does not represent a specific ordering of objects. Understandably, "first\second\third "Where permitted, the preset order or sequence may be interchanged so that the embodiments of the disclosure described herein can be practiced in an order other than that illustrated or described herein.
本公开实施例提供了一种图像缓存方法,其执行主体可以是图像缓存装置,例如,图像缓存方法可以由终端设备或服务器或其它电子设备执行,其中,终端设备可以为用户设备(User Equipment,UE)、移动设备、用户终端、蜂窝电话、无绳电话、个人数字助理(Personal Digital Assistant,PDA)、手持设备、计算设备、车载设备、可穿戴设备等。在一些可能的实现方式中,图像缓存方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。An embodiment of the present disclosure provides an image caching method, which may be executed by an image caching device. For example, the image caching method may be executed by a terminal device or a server or other electronic devices, wherein the terminal device may be a user equipment (User Equipment, UE), mobile devices, user terminals, cellular phones, cordless phones, personal digital assistants (Personal Digital Assistant, PDA), handheld devices, computing devices, vehicle-mounted devices, wearable devices, etc. In some possible implementation manners, the image caching method may be implemented by a processor invoking computer-readable instructions stored in a memory.
本公开实施例提供了一种图像缓存方法。图1为本公开实施例提供的一种图像缓存方法的流程示意图。如图1所示,在本公开的实施例中,图像缓存方法主要包括以下步骤:The embodiment of the present disclosure provides an image caching method. FIG. 1 is a schematic flowchart of an image caching method provided by an embodiment of the present disclosure. As shown in Figure 1, in the embodiment of the present disclosure, the image caching method mainly includes the following steps:
S101、利用多个训练进程中每个训练进程读取一组图像,得到多组图像;其中,多个训练进程与多组图像一一对应。S101. Using each of the multiple training processes to read a set of images to obtain multiple sets of images; wherein, the multiple training processes are in one-to-one correspondence with the multiple sets of images.
在本公开的实施例中,图像缓存装置利用多个训练进程读取多组图像。In an embodiment of the present disclosure, the image caching device uses multiple training processes to read multiple sets of images.
需要说明的是,在本公开的实施例中,多组图像实际上是存储在硬盘上的,图像缓存装置利用多个训练进程中每个训练进程可以读取一组图像,即多个训练进程与多组图像一一对应。具体的训练进程的数量,以及每个训练进程读取的图像可以根据实际需求和应用场景设定,本公开实施例不作限定。It should be noted that, in the embodiment of the present disclosure, multiple sets of images are actually stored on the hard disk, and the image cache device can read a set of images by using each training process in multiple training processes, that is, multiple The training process is in one-to-one correspondence with multiple sets of images. The specific number of training processes and the images read by each training process can be set according to actual needs and application scenarios, which are not limited in this embodiment of the present disclosure.
需要说明的是,在本公开的实施例中,对于多个训练进程中每个训练进程,可以执行神经网络训练步骤,用于训练神经网络。It should be noted that, in the embodiments of the present disclosure, for each training process in the multiple training processes, a neural network training step may be performed for training the neural network.
需要说明的是,在本公开的实施例中,每个训练进程读取的一组图像中,可以包括一帧或者多帧图像,具体的每组图像包含的图像数量可以根据实际需求设定,本公开实施例不作限定。It should be noted that, in the embodiments of the present disclosure, a group of images read by each training process may include one or more frames of images, and the specific number of images included in each group of images may be set according to actual needs. Certainly, the embodiments of the present disclosure are not limited.
具体的,在本公开的实施例中,图像处理装置利用多个训练进程中每个训练进程读取一组图像,得到多组图像,包括:利用多个训练进程中第二训练进程,读取记录图像数据集中每个图像的存储路径的图像路径列表,并将图像路径列表广播至多个训练进程中与第二训练进程不同的每个训练进程;利用多个训练进程中每个训练进程,基于图像路径列表,按照对应的预设图像读取策略,从图像数据集中读取一组图像,得到多组图像。Specifically, in an embodiment of the present disclosure, the image processing device uses each of the multiple training processes to read a set of images to obtain multiple sets of images, including: using the second training process among the multiple training processes, reading the image path list that records the storage path of each image in the image dataset, and broadcasting the image path list to each of the plurality of training processes that is different from the second training process; utilizing each of the plurality of training processes , based on the image path list, according to the corresponding preset image reading strategy, read a group of images from the image data set to obtain multiple groups of images.
需要说明的是,在本公开的实施例中,多个训练进程中包括第一训练进程,其中,第一训练进程用于实现共享内存的申请和共享,具体在后续步骤中详述,而第二训练进程,可以与第一训练进程为同一个训练进程,当然,也可以为多个训练进程中,与第一训练进程为不同的任意一个训练进程。具体的第二训练进程可以根据实际需求和应用场景设定,本公开实施例不作限定。It should be noted that, in the embodiments of the present disclosure, the multiple training processes include the first training process, wherein the first training process is used to realize the application and sharing of the shared memory, which will be detailed in the subsequent steps, and the second The second training process can be the same training process as the first training process, of course, it can also be any training process different from the first training process among multiple training processes. The specific second training process can be set according to actual needs and application scenarios, and is not limited in this embodiment of the present disclosure.
可以理解的是,在本公开的实施例中,图像路径列表中记录了图像数据集中每个图像的存储路径,图像缓存装置利用第二训练进程读取到图像路径列表,并广播至多个训 练进程中与第二训练进程不同的每个训练进程,从而实现了多个训练进程中每个训练进程获知图像数据集中每个图像的存储路径,这样,图像缓存装置即可利用多个训练进程中的每个训练进程,基于图像路径列表,进行一组图像的读取。It can be understood that, in the embodiment of the present disclosure, the storage path of each image in the image data set is recorded in the image path list, and the image cache device uses the second training process to read the image path list and broadcast it to multiple training processes Each training process that is different from the second training process, thereby realizing that each training process in multiple training processes knows the storage path of each image in the image data set, so that the image cache device can use the storage path of each image in the multiple training processes Each training process reads a set of images based on the image path list.
需要说明的是,在本公开的实施例中,多个训练进程中每个训练进程,都设定有对应的预设图像读取策略,指示了该训练线程需要从图像数据集中读取的一组图像,也就是说,实际上每个训练线程分别读取图像数据集中部分图像。例如,多个训练进程为三个训练进程,具体包括:训练进程1、训练进程2和训练进程3,其中,训练进程1对应的预设图像读取策略为读取图像路径列表中记录的前三分之一的图像,即训练进程1对应读取的一组图像为图像数据集中在图像路径列表中记录的前三分之一的图像,训练进程2对应的预设图像读取策略为读取图像路径列表中记录的中间三分之一的图像,训练进程3对应的预设图像读取策略为读取图像路径列表中记录的后三分之一的图像,即利用三个训练进程,可以实现图像数据集全部图像的读取。具体的每个训练进程对应的预设图像读取策略可以根据实际需求和应用场景设定,本公开实施例不作限定。It should be noted that, in the embodiments of the present disclosure, each of the multiple training processes is set with a corresponding preset image reading strategy, which indicates that the training thread needs to read a set of images from the image data set. group of images, that is, each training thread actually reads part of the images in the image dataset separately. For example, the multiple training processes are three training processes, specifically including: training process 1, training process 2, and training process 3, wherein the preset image reading strategy corresponding to training process 1 is to read the previous One third of the images, that is, the set of images read by training process 1 is the first third of the images recorded in the image path list in the image data set, and the preset image reading strategy corresponding to training process 2 is Read the middle third of the images recorded in the image path list, and the preset image reading strategy corresponding to training process 3 is to read the last third of the images recorded in the image path list, that is, use three training processes , which can realize the reading of all images in the image dataset. The specific preset image reading strategy corresponding to each training process can be set according to actual needs and application scenarios, and is not limited in this embodiment of the present disclosure.
需要说明的是,在本公开的实施例中,多组图像可以覆盖整个图像数据集,当然,也可以仅覆盖图像数据集部分特定的图像,本公开实施例不作限定。It should be noted that, in the embodiments of the present disclosure, multiple sets of images may cover the entire image data set, and of course, may also cover only some specific images in the image data set, which is not limited in the embodiments of the present disclosure.
S102、利用多个训练进程中第一训练进程,申请多组图像对应的共享内存,并将申请到的共享内存共享至所述多个训练进程中与第一训练进程不同的每个训练进程。S102. Using the first training process among the multiple training processes, apply for shared memory corresponding to multiple groups of images, and share the applied shared memory to each training process different from the first training process among the multiple training processes .
在本公开的实施例中,图像缓存装置在利用多个训练进程读取到多组图像的情况下,利用多个训练进程中第一训练进程,申请多组图像对应的共享内存,并将申请到的共享内存共享至所述多个训练进程中与第一训练进程不同的每个训练进程。In an embodiment of the present disclosure, when multiple sets of images are read by the image caching device using multiple training processes, use the first training process in the multiple training processes to apply for the shared memory corresponding to the multiple sets of images, and Sharing the applied for shared memory to each training process different from the first training process among the multiple training processes.
需要说明的是,在本公开的实施例中,第一训练进程可以是多个训练进程中任意一个训练进程,也可以是预先设定的多个训练进程中特定的一个训练进程,其可以与上述第二训练进程为同一训练进程,也可以与上述第二训练进程为不同的训练进程,本公开实施例不作限定。It should be noted that, in the embodiment of the present disclosure, the first training process may be any training process among multiple training processes, or may be a specific training process among multiple preset training processes, which may be related to The above-mentioned second training process is the same training process, and may also be a different training process from the above-mentioned second training process, which is not limited in this embodiment of the present disclosure.
需要说明的是,在本公开的实施例中,图像缓存装置在利用第一训练进程申请到共享内存之后,即可将共享内存共享至其他训练进程。具体的,图像缓存装置可以利用第一训练进程,将指向共享内存的描述符发送给其他训练进程,其他训练进程根据该描述符,即可获知具体的共享内存。It should be noted that, in the embodiment of the present disclosure, after the image caching device applies for the shared memory through the first training process, it can share the shared memory with other training processes. Specifically, the image caching device can use the first training process to send the descriptor pointing to the shared memory to other training processes, and the other training processes can learn the specific shared memory according to the descriptor.
具体的,在本公开的实施例中,图像缓存装置利用多个训练进程中第一训练进程,申请多组图像对应的共享内存之前,可以执行以下步骤:利用多个训练进程中每个训练进程,计算支持缓存多组图像中读取的一组图像需求的内存大小,得到与多组图像一一对应的多个内存大小;利用第一训练进程,汇总多个内存大小,得到支持存储多组图像的整体内存大小;相应地,图像缓存装置利用多个训练进程中第一训练进程,申请多组图像对应的共享内存,包括:利用第一训练进程,根据整体内存大小申请共享内存。Specifically, in the embodiment of the present disclosure, the image caching device may perform the following steps before applying for the shared memory corresponding to multiple groups of images using the first training process among the multiple training processes: using each of the multiple training processes to train process, calculate the memory size required to support caching a group of images read in multiple groups of images, and obtain multiple memory sizes corresponding to multiple groups of images; use the first training process to summarize multiple memory sizes, and obtain The overall memory size that supports storing multiple sets of images; correspondingly, the image cache device uses the first training process in multiple training processes to apply for shared memory corresponding to multiple sets of images, including: using the first training process, according to the overall memory size Apply for shared memory.
可以理解的是,在本公开的实施例中,每个训练进程在读取到一组图像的情况下,可以计算缓存该组图像所需要的内存大小,实际上也就是计算该组图像的图像数据量大小。It can be understood that, in the embodiments of the present disclosure, when each training process reads a set of images, it can calculate the memory size required for caching the set of images, in fact, it is to calculate the set of images The image data size of the image.
需要说明的是,在本公开的实施例中,多个训练进程之间可以进行通信交互,与第一训练进程不同的每个训练进程,可以将计算出的支持缓存读取的一组图像的内存大小通知给第一训练进程,第一训练进程即可汇总多组图像对应的多个内存大小,从而得到支持存储多组图像的整体内存大小,再申请与整体内存大小匹配的共享内存,也就是多组图像对应的共享内存。整体内存大小,实际上也就是多组图像的图像数据量大小。It should be noted that, in the embodiment of the present disclosure, communication and interaction can be performed between multiple training processes, and each training process different from the first training process can use the calculated set of images that support cache reading Notify the memory size to the first training process, the first training process can summarize the multiple memory sizes corresponding to multiple sets of images, so as to obtain the overall memory size that supports storing multiple sets of images, and then apply for a share that matches the overall memory size Memory, that is, the shared memory corresponding to multiple sets of images. The overall memory size is actually the image data size of multiple sets of images.
具体的,在本公开的实施例中,图像缓存装置利用多个训练进程中每个训练进程,计算支持缓存多组图像中读取的一组图像需求的内存大小,得到与多组图像一一对应的 多个内存大小,包括:利用多个训练进程中每个训练进程,获取多组图像中读取的一组图像的形状信息;利用多个训练进程中每个训练进程,根据多组图像中读取的一组图像的形状信息,计算支持缓存读取的一组图像需求的内存大小,得到多个内存大小。Specifically, in an embodiment of the present disclosure, the image caching device uses each training process in multiple training processes to calculate the memory size required to support caching a group of images read in multiple groups of images, and obtain the Like one-to-one correspondence of multiple memory sizes, including: using each training process in multiple training processes to obtain the shape information of a set of images read in multiple sets of images; using each training process in multiple training processes , according to the shape information of a group of images read in multiple groups of images, calculate the memory size required by a group of images that support cache reading, and obtain multiple memory sizes.
需要说明的是,在本公开的实施例中,图像缓存装置可以利用多个训练进程中每个训练进程,获取读取的一组图像的形状信息,其中,对于一帧图像而言,其形状信息可以包括该图像的数据类型等信息,每个训练进程根据对应一组图像的形状信息,可以计算出支持缓存读取的一组图像需求的内存大小。It should be noted that, in the embodiment of the present disclosure, the image caching device can use each training process in multiple training processes to acquire the shape information of a group of images read, wherein, for a frame of image, its The shape information can include information such as the data type of the image, and each training process can calculate the memory size required by a group of images that support cache reading according to the shape information of a corresponding group of images.
具体的,在本公开的实施例中,图像缓存装置利用多个训练进程中每个训练进程,计算支持缓存多组图像中读取的一组图像需求的内存大小,得到与多组图像一一对应的多个内存大小之后,还可以执行以下步骤:分别利用多个训练进程中每个训练进程,汇总多个内存大小,得到整体内存大小。Specifically, in an embodiment of the present disclosure, the image caching device uses each training process in multiple training processes to calculate the memory size required to support caching a group of images read in multiple groups of images, and obtain the After one-to-one correspondence of multiple memory sizes, the following steps can also be performed: use each training process in multiple training processes to aggregate multiple memory sizes to obtain the overall memory size.
需要说明的是,在本公开的实施例中,图像缓存装置在利用每个训练进程计算出支持缓存读取的一组图像需求的内存大小的情况下,还可以分别利用每个训练进程进行多个内存大小的汇总,这样,每个训练进程都可以获知到多组图像的大小。It should be noted that, in the embodiment of the present disclosure, when the image caching device uses each training process to calculate the memory size required by a group of images that support cache reading, it can also use each training process to perform Aggregation of multiple memory sizes, so that each training process can learn the size of multiple sets of images.
具体的,在本公开的实施例中,图像缓存装置利用多个训练进程中每个训练进程,获取多组图像中读取的一组图像的形状信息之后,还可以执行以下步骤:分别利用多个训练进程中每个训练进程,汇总多组图像的形状信息,得到信息汇总结果。Specifically, in an embodiment of the present disclosure, after the image caching device acquires the shape information of a set of images read from multiple sets of images by using each of the multiple training processes, the following steps may also be performed: respectively Using each training process in the multiple training processes, the shape information of multiple groups of images is summarized to obtain an information summary result.
需要说明的是,在本公开的实施例中,图像缓存装置在利用每个训练进程获取到读取的一组图像的形状信息的情况下,还可以分别利用每个训练进程进行多组图像的形状信息的汇总,这样,每个训练进程都可以获知到多组图像的形状信息,这样,每个训练进程在后续从共享内存中进行图像读取时,可以基于获知的形状信息进行特定图像的选择再进行读取。It should be noted that, in the embodiment of the present disclosure, in the case that the image caching device obtains the shape information of a group of read images by using each training process, it can also use each training process to perform multiple sets of images respectively. Like the summary of shape information, so that each training process can learn the shape information of multiple sets of images, so that each training process can be based on the learned shape information when reading images from the shared memory. The selection of a specific image is then read.
S103、利用多个训练进程中每个训练进程,分别将多组图像中读取的一组图像,缓存至共享内存,以供多个训练进程中每个训练进程在执行神经网络训练步骤的期间,从共享内存中读取多组图像。S103. Using each training process in the multiple training processes, respectively cache a group of images read in multiple groups of images to the shared memory, so that each training process in the multiple training processes executes the neural network training step During the period, multiple sets of images are read from the shared memory.
在本公开的实施例中,图像缓存装置在利用第一训练进程将共享内存共享至多个训练进程中其他训练进程之后,即多个训练进程均获知共享内存,从而可以利用多个训练进程中每个训练进程,分别将多组图像中读取的一组图像,缓存至共享内存。In the embodiment of the present disclosure, after the image caching device uses the first training process to share the shared memory to other training processes in the multiple training processes, that is, the multiple training processes all know the shared memory, so that each of the multiple training processes can use Each training process caches a group of images read from multiple groups of images to the shared memory.
可以理解的是,在本公开的实施例中,图像缓存装置利用多个训练进程中每个训练进程,分别将多组图像中读取的一组图像,缓存至共享内存,实际上就是实现了将多组图像全部缓存到共享内存中。对于每个训练进程而言,其获知缓存多组图像的共享内存,因此,在后续执行神经网络训练步骤的期间,可以从共享内存中进行图像的读取,具体可以读取共享内存中缓存的多组图像中任意的图像,用于进行神经网络训练,从而提高了图像读取速度,相应地,也就提高了神经网络训练速度。It can be understood that, in the embodiment of the present disclosure, the image caching device uses each training process in the multiple training processes to respectively cache a group of images read from the multiple groups of images into the shared memory, which is actually Realized that multiple groups of images are all cached in shared memory. For each training process, it knows the shared memory that caches multiple sets of images. Therefore, during the subsequent execution of the neural network training step, the image can be read from the shared memory. Specifically, the cache in the shared memory can be read Any image in the multiple groups of images is used for neural network training, thereby improving the image reading speed, and correspondingly, also improving the neural network training speed.
需要说明的是,在本公开的实施例中,上述图像缓存方法,较佳的,适用于神经网络训练中,用于训练的单帧图像数据量较大,但是,图像的总图像数据较少,即图像数量较少的应用场景。It should be noted that, in the embodiment of the present disclosure, the above-mentioned image caching method is preferably applicable to neural network training, and the amount of single-frame image data used for training is relatively large, but the total image data of the image is relatively small , that is, the application scenario with a small number of images.
图2为本公开实施例提供的一种示例性的训练进程缓存图像的示意图。如图2所示,训练进程1读取图像路径列表,然后将这个路径列表广播给训练进程2和训练进程3。每个训练进程根据图像路径列表,确定出自己需要读取的一组图像,并且从硬盘中读取对应的一组图片。每个训练进程根据读到的图片,计算出缓存本进程的这些图片所需要的内存大小,然后汇总,这样所有训练进程都知道了整个图像数据集的大小。训练进程1根据汇总出来的整体内存大小,申请对应的共享内存,并将这块共享内存共享给其他的进程。最后,每个进程将自己之前读到的图片,缓存到这块共享内存的对应位置, 后续每个进程在训练的过程中,都可以读这块共享内存的图像。FIG. 2 is a schematic diagram of an exemplary training process cache image provided by an embodiment of the present disclosure. As shown in Figure 2, training process 1 reads the image path list, and then broadcasts the path list to training process 2 and training process 3. Each training process determines a set of images that it needs to read according to the image path list, and reads a corresponding set of pictures from the hard disk. Each training process calculates the memory size required to cache these pictures in this process based on the read pictures, and then summarizes them, so that all training processes know the size of the entire image data set. Training process 1 applies for the corresponding shared memory according to the aggregated overall memory size, and shares this shared memory with other processes. Finally, each process caches the image it read before into the corresponding location of the shared memory, and each subsequent process can read the image in the shared memory during the training process.
本公开实施例提供了一种图像缓存方法,包括:利用多个训练进程中每个训练进程读取一组图像,得到多组图像;其中,多个训练进程与多组图像一一对应;利用多个训练进程中第一训练进程,申请多组图像对应的共享内存,并将申请到的共享内存共享至多个训练进程中与第一训练进程不同的每个训练进程;利用多个训练进程中每个训练进程,分别将多组图像中读取的一组图像,缓存至共享内存,以供多个训练进程中每个训练进程在执行神经网络训练步骤的期间,从共享内存中读取多组图像。本公开实施例提供的图像缓存方法,利用训练进程,将神经网络训练阶段需要应用的图像预先缓存到共享内存中,从而提高图像读取速度,提高神经网络训练效率。An embodiment of the present disclosure provides an image caching method, including: using each training process in multiple training processes to read a set of images to obtain multiple sets of images; wherein, multiple training processes and multiple sets of images are one by one Corresponding; using the first training process in the multiple training processes, applying for shared memory corresponding to multiple groups of images, and sharing the applied shared memory to each training process different from the first training process in the multiple training processes; using multiple training processes Each training process in each training process caches a group of images read in multiple groups of images to the shared memory, so that each training process in multiple training processes can read from Read multiple sets of images in shared memory. The image caching method provided by the embodiments of the present disclosure utilizes the training process to pre-cache the images to be applied during the neural network training phase into the shared memory, thereby increasing the image reading speed and improving the neural network training efficiency.
本公开实施例提供了一种图像缓存装置。图3为本公开实施例提供的一种图像缓存装置的结构示意图。如图3所示,图像缓存装置包括:An embodiment of the present disclosure provides an image caching device. FIG. 3 is a schematic structural diagram of an image caching device provided by an embodiment of the present disclosure. As shown in Figure 3, the image cache device includes:
读取模块301,配置为利用多个训练进程中每个训练进程读取一组图像,得到多组图像;其中,所述多个训练进程与所述多组图像一一对应;The reading module 301 is configured to use each training process in multiple training processes to read a group of images to obtain multiple groups of images; wherein, the multiple training processes correspond to the multiple groups of images one by one;
处理模块302,配置为利用所述多个训练进程中第一训练进程,申请所述多组图像对应的共享内存,并将申请到的所述共享内存共享至所述多个训练进程中与所述第一训练进程不同的每个训练进程;The processing module 302 is configured to use the first training process in the multiple training processes to apply for the shared memory corresponding to the multiple groups of images, and share the applied shared memory to the multiple training processes and each training session different from the first training session;
缓存模块303,配置为利用所述多个训练进程中每个训练进程,分别将所述多组图像中读取的一组图像,缓存至所述共享内存,以供所述多个训练进程中每个训练进程在执行神经网络训练步骤的期间,从所述共享内存中读取所述多组图像。The caching module 303 is configured to use each training process in the plurality of training processes to respectively cache a group of images read in the plurality of groups of images into the shared memory for the plurality of training Each training process in the process reads the multiple groups of images from the shared memory during the execution of the neural network training step.
在本公开一实施例中,所述读取模块301,具体配置为利用所述多个训练进程中第二训练进程,读取记录图像数据集中每个图像的存储路径的图像路径列表,并将所述图像路径列表广播至所述多个训练进程中与所述第二训练进程不同的每个训练进程;利用所述多个训练进程中每个训练进程,基于所述图像路径列表,按照对应的预设图像读取策略,从所述图像数据集中读取一组图像,得到所述多组图像。In an embodiment of the present disclosure, the reading module 301 is specifically configured to use the second training process in the plurality of training processes to read the image path list that records the storage path of each image in the image data set, and The image path list is broadcast to each training process different from the second training process in the plurality of training processes; using each training process in the plurality of training processes, based on the image path list, according to the corresponding The preset image reading strategy reads a group of images from the image data set to obtain the multiple groups of images.
在本公开一实施例中,所述处理模块302,还配置为利用所述多个训练进程中每个训练进程,计算支持缓存所述多组图像中读取的一组图像需求的内存大小,得到与所述多组图像一一对应的多个内存大小;利用所述第一训练进程,汇总所述多个内存大小,得到支持存储所述多组图像的整体内存大小;In an embodiment of the present disclosure, the processing module 302 is further configured to use each training process in the plurality of training processes to calculate the memory required to support caching a set of images read in the multiple sets of images size, to obtain a plurality of memory sizes corresponding to the plurality of groups of images; using the first training process, summarizing the plurality of memory sizes, and obtaining an overall memory size that supports storage of the plurality of groups of images;
所述处理模块302,具体配置为利用所述第一训练进程,根据所述整体内存大小申请所述共享内存。The processing module 302 is specifically configured to use the first training process to apply for the shared memory according to the overall memory size.
在本公开一实施例中,所述处理模块302,还配置为分别利用所述多个训练进程中每个训练进程,汇总所述多个内存大小,得到所述整体内存大小。In an embodiment of the present disclosure, the processing module 302 is further configured to use each training process in the multiple training processes to summarize the multiple memory sizes to obtain the overall memory size.
在本公开一实施例中,所述处理模块302,具体配置为利用所述多个训练进程中每个训练进程,获取所述多组图像中读取的一组图像的形状信息;利用所述多个训练进程中每个训练进程,根据所述多组图像中读取的一组图像的形状信息,计算支持缓存读取的一组图像需求的内存大小,得到所述多个内存大小。In an embodiment of the present disclosure, the processing module 302 is specifically configured to use each training process in the multiple training processes to acquire the shape information of a set of images read in the multiple sets of images; Each training process in the plurality of training processes, according to the shape information of a group of images read in the plurality of groups of images, calculates the memory size required by a group of images that support cache reading, and obtains the plurality of memory size.
在本公开一实施例中,所述处理模块302,还配置为分别利用所述多个训练进程中每个训练进程,汇总所述多组图像的形状信息,得到信息汇总结果。In an embodiment of the present disclosure, the processing module 302 is further configured to respectively use each training process in the multiple training processes to summarize the shape information of the multiple groups of images to obtain an information summary result.
本公开实施例提供了一种电子设备。图4为本公开实施例提供的一种电子设备的结构示意图。如图4所示,在本公开的实施例中,电子设备包括:处理器401、存储器402和通信总线403;其中,An embodiment of the present disclosure provides an electronic device. Fig. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. As shown in FIG. 4, in an embodiment of the present disclosure, the electronic device includes: a processor 401, a memory 402, and a communication bus 403; wherein,
所述通信总线403,配置为实现所述处理器401和所述存储器402之间的连接通信;The communication bus 403 is configured to realize connection and communication between the processor 401 and the memory 402;
所述处理器401,配置为执行所述存储器402中存储的一个或者多个程序,以上述图像缓存方法。The processor 401 is configured to execute one or more programs stored in the memory 402 to implement the image caching method described above.
本公开实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有一个或者多个程序,所述一个或者多个程序可以被一个或者多个处理器执行,以实现上述图像缓存方法。计算机可读存储介质可以是是易失性存储器(volatile memory),例如随机存取存储器(Random-Access Memory,RAM);或者非易失性存储器(non-volatile memory),例如只读存储器(Read-Only Memory,ROM),快闪存储器(flash memory),硬盘(Hard Disk Drive,HDD)或固态硬盘(Solid-State Drive,SSD);也可以是包括上述存储器之一或任意组合的各自设备,如移动电话、计算机、平板设备、个人数字助理等。An embodiment of the present disclosure provides a computer-readable storage medium, the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to realize the above image caching method. The computer-readable storage medium can be a volatile memory (volatile memory), such as a random access memory (Random-Access Memory, RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (Read-Only Memory). -Only Memory, ROM), flash memory (flash memory), hard disk (Hard Disk Drive, HDD) or solid-state drive (Solid-State Drive, SSD); it can also be a respective device including one or any combination of the above memories, Such as mobile phones, computers, tablet devices, personal digital assistants, etc.
本公开实施例提供了一种计算机程序产品,所述计算机程序产品包括计算机程序或指令,在所述计算机程序或指令在计算机上运行的情况下,使所述计算机执行是上述图像缓存方法。An embodiment of the present disclosure provides a computer program product, the computer program product includes a computer program or an instruction, and when the computer program or instruction is run on a computer, the computer is made to execute the above-mentioned image caching method.
本领域内的技术人员应明白,本公开的实施例可提供为方法、系统、或计算机程序产品。因此,本公开可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本公开可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Accordingly, the present disclosure may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) having computer-usable program code embodied therein.
本公开是参照根据本公开实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程信号处理设备的处理器以产生一个机器,使得通过计算机或其他可编程信号处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present disclosure is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable signal processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable signal processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程信号处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable signal processing device to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程信号处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded into a computer or other programmable signal processing device, so that a series of operational steps are performed on the computer or other programmable device to produce computer-implemented processing, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
以上所述,仅为本公开的较佳实施例而已,并非用于限定本公开的保护范围。The above descriptions are only preferred embodiments of the present disclosure, and are not intended to limit the protection scope of the present disclosure.
工业实用性Industrial Applicability
本公开实施例提供了一种图像缓存方法、装置、电子设备、存储介质及计算机程序产品,其中,方法包括:利用多个训练进程中每个训练进程读取一组图像,得到多组图像;其中,多个训练进程与多组图像一一对应;利用多个训练进程中第一训练进程,申请多组图像对应的共享内存,并将申请到的共享内存共享至多个训练进程中与第一训练进程不同的每个训练进程;利用多个训练进程中每个训练进程,分别将多组图像中读取的一组图像,缓存至共享内存,以供多个训练进程中每个训练进程在执行神经网络训练步骤的期间,从共享内存中读取多组图像。本公开实施例提供的技术方案,利用训练进程,将神经网络训练阶段需要应用的图像预先缓存到共享内存中,从而提高图像读取速度,提高神经网络训练效率。Embodiments of the present disclosure provide an image caching method, device, electronic equipment, storage medium, and computer program product, wherein the method includes: using each training process in multiple training processes to read a set of images to obtain multiple sets of images Image; among them, multiple training processes correspond to multiple groups of images one by one; use the first training process in multiple training processes to apply for shared memory corresponding to multiple groups of images, and share the applied shared memory to multiple training processes In each training process different from the first training process; each training process in multiple training processes is used to cache a group of images read in multiple groups of images to shared memory for multiple training processes Each training process in , reads multiple sets of images from shared memory during the neural network training steps. The technical solution provided by the embodiments of the present disclosure utilizes the training process to pre-cache the images to be applied during the neural network training phase into the shared memory, thereby increasing the image reading speed and improving the training efficiency of the neural network.

Claims (15)

  1. 一种图像缓存方法,包括:An image caching method, comprising:
    利用多个训练进程中每个训练进程读取一组图像,得到多组图像;其中,所述多个训练进程与所述多组图像一一对应;Using each training process in multiple training processes to read a group of images to obtain multiple groups of images; wherein, the multiple training processes correspond to the multiple groups of images one-to-one;
    利用所述多个训练进程中第一训练进程,申请所述多组图像对应的共享内存,并将申请到的所述共享内存共享至所述多个训练进程中与所述第一训练进程不同的每个训练进程;Using the first training process among the plurality of training processes, apply for the shared memory corresponding to the plurality of groups of images, and share the applied shared memory to the plurality of training processes with the first training process different for each training process;
    利用所述多个训练进程中每个训练进程,分别将所述多组图像中读取的一组图像,缓存至所述共享内存,以供所述多个训练进程中每个训练进程在执行神经网络训练步骤的期间,从所述共享内存中读取所述多组图像。Using each training process in the plurality of training processes, respectively cache a group of images read in the plurality of groups of images into the shared memory for each training process in the plurality of training processes During the execution of the neural network training step, the plurality of sets of images are read from the shared memory.
  2. 根据权利要求1所述的方法,其中,所述利用多个训练进程中每个训练进程读取一组图像,得到多组图像,包括:The method according to claim 1, wherein said using each training process in multiple training processes to read a group of images to obtain multiple groups of images comprises:
    利用所述多个训练进程中第二训练进程,读取记录图像数据集中每个图像的存储路径的图像路径列表,并将所述图像路径列表广播至所述多个训练进程中与所述第二训练进程不同的每个训练进程;Using the second training process in the plurality of training processes, read the image path list recording the storage path of each image in the image data set, and broadcast the image path list to the plurality of training processes and the first training process Two different training processes for each training process;
    利用所述多个训练进程中每个训练进程,基于所述图像路径列表,按照对应的预设图像读取策略,从所述图像数据集中读取一组图像,得到所述多组图像。Using each training process in the multiple training processes, based on the image path list, according to the corresponding preset image reading strategy, read a group of images from the image data set to obtain the multiple groups of images .
  3. 根据权利要求1所述的方法,其中,所述利用所述多个训练进程中第一训练进程,申请所述多组图像对应的共享内存之前,所述方法还包括:The method according to claim 1, wherein, before applying for the shared memory corresponding to the plurality of groups of images using the first training process in the plurality of training processes, the method further comprises:
    利用所述多个训练进程中每个训练进程,计算支持缓存所述多组图像中读取的一组图像需求的内存大小,得到与所述多组图像一一对应的多个内存大小;Using each training process in the plurality of training processes, calculate the memory size required to support the caching of a group of images read in the plurality of groups of images, and obtain a plurality of memories corresponding to the plurality of groups of images one-to-one. size;
    利用所述第一训练进程,汇总所述多个内存大小,得到支持存储所述多组图像的整体内存大小;Using the first training process, summarizing the multiple memory sizes to obtain an overall memory size that supports storage of the multiple groups of images;
    所述利用所述多个训练进程中第一训练进程,申请所述多组图像对应的共享内存,包括:Using the first training process in the multiple training processes to apply for the shared memory corresponding to the multiple groups of images includes:
    利用所述第一训练进程,根据所述整体内存大小申请所述共享内存。Applying for the shared memory according to the overall memory size by using the first training process.
  4. 根据权利要求3所述的方法,其中,所述利用所述多个训练进程中每个训练进程,计算支持缓存所述多组图像中对应一组图像需求的内存大小,得到与所述多组图像一一对应的多个内存大小之后,所述方法还包括:The method according to claim 3, wherein, using each training process in the plurality of training processes, calculating the memory size required to support caching a corresponding group of images in the plurality of groups of images, and obtaining the same size as the After multiple memory sizes corresponding to multiple groups of images one-to-one, the method also includes:
    分别利用所述多个训练进程中每个训练进程,汇总所述多个内存大小,得到所述整体内存大小。Using each training process in the multiple training processes to sum up the multiple memory sizes to obtain the overall memory size.
  5. 根据权利要求3所述的方法,其中,所述利用所述多个训练进程中每个训练进程,计算支持缓存所述多组图像中读取的一组图像需求的内存大小,得到与所述多组图像一一对应的多个内存大小,包括:The method according to claim 3, wherein, using each training process in the plurality of training processes, calculating the memory size required to support caching a group of images read in the plurality of groups of images, and obtaining the same as The multiple memory sizes corresponding to the multiple groups of images one-to-one include:
    利用所述多个训练进程中每个训练进程,获取所述多组图像中读取的一组图像的形状信息;Using each training process in the plurality of training processes to obtain shape information of a group of images read in the plurality of groups of images;
    利用所述多个训练进程中每个训练进程,根据所述多组图像中读取的一组图像的形状信息,计算支持缓存读取的一组图像需求的内存大小,得到所述多个内存大小。Using each training process in the plurality of training processes, according to the shape information of a group of images read in the plurality of groups of images, calculate the memory size required by a group of images that support cache reading, and obtain the described Multiple memory sizes.
  6. 根据权利要求5所述的方法,其中,所述利用所述多个训练进程中每个训练进程,获取所述多组图像中读取的一组图像的形状信息之后,所述方法还包括:The method according to claim 5, wherein, after obtaining the shape information of a group of images read in the plurality of groups of images by using each training process in the plurality of training processes, the method further include:
    分别利用所述多个训练进程中每个训练进程,汇总所述多组图像的形状信息,得到信息汇总结果。Using each training process in the multiple training processes to summarize the shape information of the multiple groups of images to obtain an information summary result.
  7. 一种图像缓存装置,包括:An image caching device, comprising:
    读取模块,配置为利用多个训练进程中每个训练进程读取一组图像,得到多组图像;其中,所述多个训练进程与所述多组图像一一对应;The reading module is configured to use each training process in multiple training processes to read a group of images to obtain multiple groups of images; wherein, the multiple training processes correspond to the multiple groups of images one-to-one;
    处理模块,配置为利用所述多个训练进程中第一训练进程,申请所述多组图像对应的共享内存,并将申请到的所述共享内存共享至所述多个训练进程中与所述第一训练进程不同的每个训练进程;The processing module is configured to use the first training process in the plurality of training processes to apply for the shared memory corresponding to the plurality of groups of images, and share the applied for shared memory to the plurality of training processes and all each training session different from the first training session;
    缓存模块,配置为利用所述多个训练进程中每个训练进程,分别将所述多组图像中读取的一组图像,缓存至所述共享内存,以供所述多个训练进程中每个训练进程在执行神经网络训练步骤的期间,从所述共享内存中读取所述多组图像。The caching module is configured to use each training process in the plurality of training processes to respectively cache a group of images read in the plurality of groups of images into the shared memory for the plurality of training processes Each training process reads the multiple sets of images from the shared memory during the execution of the neural network training step.
  8. 根据权利要求7所述的装置,其中,The apparatus according to claim 7, wherein,
    所述读取模块,具体配置为利用所述多个训练进程中第二训练进程,读取记录图像数据集中每个图像的存储路径的图像路径列表,并将所述图像路径列表广播至所述多个训练进程中与所述第二训练进程不同的每个训练进程;利用所述多个训练进程中每个训练进程,基于所述图像路径列表,按照对应的预设图像读取策略,从所述图像数据集中读取一组图像,得到所述多组图像。The reading module is specifically configured to use the second training process in the plurality of training processes to read the image path list that records the storage path of each image in the image data set, and broadcast the image path list to the Each training process different from the second training process in the multiple training processes; using each training process in the multiple training processes, based on the image path list, according to the corresponding preset image reading strategy, from A group of images is read from the image data set to obtain the multiple groups of images.
  9. 根据权利要求7所述的装置,其中,The apparatus according to claim 7, wherein,
    所述处理模块,还配置为利用所述多个训练进程中每个训练进程,计算支持缓存所述多组图像中读取的一组图像需求的内存大小,得到与所述多组图像一一对应的多个内存大小;利用所述第一训练进程,汇总所述多个内存大小,得到支持存储所述多组图像的整体内存大小;The processing module is further configured to use each training process in the plurality of training processes to calculate the memory size required to support the caching of a group of images read in the plurality of groups of images, and obtain the memory size corresponding to the plurality of groups of images Multiple memory sizes corresponding to each other; using the first training process, summing up the multiple memory sizes to obtain an overall memory size that supports storing the multiple groups of images;
    所述处理模块,具体配置为利用所述第一训练进程,根据所述整体内存大小申请所述共享内存。The processing module is specifically configured to use the first training process to apply for the shared memory according to the overall memory size.
  10. 根据权利要求9所述的装置,其中,The apparatus according to claim 9, wherein,
    所述处理模块,还配置为分别利用所述多个训练进程中每个训练进程,汇总所述多个内存大小,得到所述整体内存大小。The processing module is further configured to use each training process in the multiple training processes to summarize the multiple memory sizes to obtain the overall memory size.
  11. 根据权利要求9所述的装置,其中,The apparatus according to claim 9, wherein,
    所述处理模块,具体配置为利用所述多个训练进程中每个训练进程,获取所述多组图像中读取的一组图像的形状信息;利用所述多个训练进程中每个训练进程,根据所述多组图像中读取的一组图像的形状信息,计算支持缓存读取的一组图像需求的内存大小,得到所述多个内存大小。The processing module is specifically configured to use each training process in the plurality of training processes to acquire the shape information of a group of images read in the plurality of groups of images; use each of the plurality of training processes to The training process, according to the shape information of a group of images read in the plurality of groups of images, calculates the memory size required by a group of images that support cache reading, and obtains the multiple memory sizes.
  12. 根据权利要求11所述的装置,其中,The apparatus of claim 11, wherein,
    所述处理模块,还配置为分别利用所述多个训练进程中每个训练进程,汇总所述多组图像的形状信息,得到信息汇总结果。The processing module is further configured to use each training process in the multiple training processes to summarize the shape information of the multiple groups of images to obtain an information summary result.
  13. 一种电子设备,所述电子设备包括:处理器、存储器和通信总线;其中,A kind of electronic equipment, described electronic equipment comprises: processor, memory and communication bus; Wherein,
    所述通信总线,配置为实现所述处理器和所述存储器之间的连接通信;The communication bus is configured to realize connection and communication between the processor and the memory;
    所述处理器,配置为执行所述存储器中存储的一个或者多个程序,以实现权利要求1-6任一项所述的图像缓存方法。The processor is configured to execute one or more programs stored in the memory, so as to realize the image caching method according to any one of claims 1-6.
  14. 一种计算机可读存储介质,所述计算机可读存储介质存储有一个或者多个程序,所述一个或者多个程序可以被一个或者多个处理器执行,以实现权利要求1-6任一项所述的图像缓存方法。A computer-readable storage medium, the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors, so as to realize any one of claims 1-6 The image caching method described.
  15. 一种计算机程序产品,所述计算机程序产品包括计算机程序或指令,在所述计算机程序或指令在计算机上运行的情况下,使所述计算机执行权利要求1-6任一项所述的图像缓存方法。A computer program product, the computer program product comprising a computer program or instruction, when the computer program or instruction is run on a computer, the computer is made to execute the image cache described in any one of claims 1-6 method.
PCT/CN2022/074698 2021-09-28 2022-01-28 Image caching method and apparatus, and electronic device, storage medium and computer program product WO2023050673A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111145887.XA CN113870093A (en) 2021-09-28 2021-09-28 Image caching method and device, electronic equipment and storage medium
CN202111145887.X 2021-09-28

Publications (1)

Publication Number Publication Date
WO2023050673A1 true WO2023050673A1 (en) 2023-04-06

Family

ID=78992114

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/074698 WO2023050673A1 (en) 2021-09-28 2022-01-28 Image caching method and apparatus, and electronic device, storage medium and computer program product

Country Status (2)

Country Link
CN (1) CN113870093A (en)
WO (1) WO2023050673A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113870093A (en) * 2021-09-28 2021-12-31 上海商汤科技开发有限公司 Image caching method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108009008A (en) * 2016-10-28 2018-05-08 北京市商汤科技开发有限公司 Data processing method and system, electronic equipment
CN111367687A (en) * 2020-02-28 2020-07-03 罗普特科技集团股份有限公司 Inter-process data communication method and device
WO2021134229A1 (en) * 2019-12-30 2021-07-08 深圳市欢太科技有限公司 Text identification method, device, storage medium, and electronic apparatus
US20210241169A1 (en) * 2020-02-05 2021-08-05 International Business Machines Corporation Performance based switching of a model training process
CN113870093A (en) * 2021-09-28 2021-12-31 上海商汤科技开发有限公司 Image caching method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108009008A (en) * 2016-10-28 2018-05-08 北京市商汤科技开发有限公司 Data processing method and system, electronic equipment
WO2021134229A1 (en) * 2019-12-30 2021-07-08 深圳市欢太科技有限公司 Text identification method, device, storage medium, and electronic apparatus
US20210241169A1 (en) * 2020-02-05 2021-08-05 International Business Machines Corporation Performance based switching of a model training process
CN111367687A (en) * 2020-02-28 2020-07-03 罗普特科技集团股份有限公司 Inter-process data communication method and device
CN113870093A (en) * 2021-09-28 2021-12-31 上海商汤科技开发有限公司 Image caching method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN113870093A (en) 2021-12-31

Similar Documents

Publication Publication Date Title
CN110958218B (en) Data transmission method based on multi-network communication and related equipment
CN104572278B (en) The method, device and equipment of light application calling local side ability
EP3467679B1 (en) Data processing method and device
US10165058B2 (en) Dynamic local function binding apparatus and method
US11290256B2 (en) Blockchain-based advertisement monitoring method and apparatus, and electronic device
CN106878370A (en) The update method and equipment of a kind of local cache
CN105893409A (en) File downloading method and apparatus
WO2023050673A1 (en) Image caching method and apparatus, and electronic device, storage medium and computer program product
JP2018528634A (en) Method and device for previewing moving image and method and device for displaying expression package
CN106657182B (en) Cloud file processing method and device
TW202004592A (en) Method and apparatus for correcting transaction causal sequence, and electronic device
US20220335977A1 (en) Method and apparatus for editing object, electronic device and storage medium
US11494237B2 (en) Managing workloads of a deep neural network processor
WO2016202306A1 (en) Video processing method and device
US10021162B2 (en) Cloud streaming service system, and method and apparatus for providing cloud streaming service
CN113918356A (en) Method and device for quickly synchronizing data based on CUDA (compute unified device architecture), computer equipment and storage medium
CN111383038A (en) Advertisement display method and device of mobile terminal, mobile terminal and storage medium
WO2018119712A1 (en) Video display method, device, electronic apparatus, and computer program product
CN111274176B (en) Information processing method, electronic equipment, system and storage medium
CN114363654B (en) Video push method, device, terminal equipment and storage medium
US11379653B2 (en) Rendering method for on-demand loading of PDF file on network
CN108268254B (en) Flash file function library calling method and device, electronic equipment and medium
CN110428453B (en) Data processing method, data processing device, data processing equipment and storage medium
US9794580B2 (en) Cache management device, and motion picture system and method using the same
US20140072244A1 (en) Image processing and recording system and method thereof

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22874076

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE