KR20230027630A - Data augmentation and learning method for ai-based vision inspection of solid medications and inspection system thereof - Google Patents

Data augmentation and learning method for ai-based vision inspection of solid medications and inspection system thereof Download PDF

Info

Publication number
KR20230027630A
KR20230027630A KR1020210109632A KR20210109632A KR20230027630A KR 20230027630 A KR20230027630 A KR 20230027630A KR 1020210109632 A KR1020210109632 A KR 1020210109632A KR 20210109632 A KR20210109632 A KR 20210109632A KR 20230027630 A KR20230027630 A KR 20230027630A
Authority
KR
South Korea
Prior art keywords
learning
image data
inspection
pill
data
Prior art date
Application number
KR1020210109632A
Other languages
Korean (ko)
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 한국전자통신연구원
Priority to KR1020210109632A priority Critical patent/KR20230027630A/en
Publication of KR20230027630A publication Critical patent/KR20230027630A/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0639Performance analysis of employees; Performance analysis of enterprise or organisation operations
    • G06Q10/06395Quality analysis or management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/40Scenes; Scene-specific elements in video content
    • G06V20/41Higher-level, semantic clustering, classification or understanding of video scenes, e.g. detection, labelling or Markovian modelling of sport events or news items
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16HHEALTHCARE INFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR THE HANDLING OR PROCESSING OF MEDICAL OR HEALTHCARE DATA
    • G16H40/00ICT specially adapted for the management or administration of healthcare resources or facilities; ICT specially adapted for the management or operation of medical equipment or devices
    • G16H40/40ICT specially adapted for the management or administration of healthcare resources or facilities; ICT specially adapted for the management or operation of medical equipment or devices for the management of medical equipment or devices, e.g. scheduling maintenance or upgrades
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16HHEALTHCARE INFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR THE HANDLING OR PROCESSING OF MEDICAL OR HEALTHCARE DATA
    • G16H70/00ICT specially adapted for the handling or processing of medical references
    • G16H70/40ICT specially adapted for the handling or processing of medical references relating to drugs, e.g. their side effects or intended usage
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2210/00Indexing scheme for image generation or computer graphics
    • G06T2210/41Medical

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Human Resources & Organizations (AREA)
  • Health & Medical Sciences (AREA)
  • General Business, Economics & Management (AREA)
  • Epidemiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Strategic Management (AREA)
  • Educational Administration (AREA)
  • Biomedical Technology (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Theoretical Computer Science (AREA)
  • Medical Informatics (AREA)
  • Primary Health Care (AREA)
  • Public Health (AREA)
  • General Physics & Mathematics (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Physics & Mathematics (AREA)
  • Operations Research (AREA)
  • Tourism & Hospitality (AREA)
  • Game Theory and Decision Science (AREA)
  • Software Systems (AREA)
  • Marketing (AREA)
  • Multimedia (AREA)
  • Quality & Reliability (AREA)
  • Computational Linguistics (AREA)
  • Chemical & Material Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Medicinal Chemistry (AREA)
  • Pharmacology & Pharmacy (AREA)
  • Toxicology (AREA)
  • Image Analysis (AREA)

Abstract

The present invention relates to a data expansion and a learning method for AI-based pharmaceutical vision inspection and an inspection system applying the same. The inspection system for AI-based pharmaceutical vision inspection according to the present invention comprises: a data management unit which stores image data for each pill and image data for training a pharmaceutical inspection model, and generates the image data for learning by combining the image data for each pill; a learning unit which extracts the video data for training from the data management unit, and generates an inspection model by learning an initial inspection model; an inspection unit which executes the inspection model to detect and recognize each pill in the image of the actual prepared and packaged medicine, and then determines whether or not it is a misprepared drug; and a control unit which controls operations of the data management unit, the learning unit, and the inspection unit when a prescription is received. Accordingly, the present invention can shorten the time required for inspection.

Description

AI 기반 의약품 비전 검수를 위한 데이터 확장 및 학습 방법과 이를 적용한 검수 시스템{DATA AUGMENTATION AND LEARNING METHOD FOR AI-BASED VISION INSPECTION OF SOLID MEDICATIONS AND INSPECTION SYSTEM THEREOF}Data expansion and learning method for AI-based pharmaceutical vision inspection and inspection system applying it

본 발명은 AI 기반 의약품 비전 검수를 위한 데이터 확장 및 학습 방법과 이를 적용한 검수 시스템에 관한 것으로, 더욱 상세하게는 AI 기반의 의약품 비전 검수를 위하여 단일 알약 영상을 조합하여 학습용 영상 데이터를 확장하는 방법, 학습용 영상 데이터를 확보하는 과정에서 자동으로 알약의 정보를 레이블링하는 방법 및 이러한 학습용 영상 데이터를 이용하여 학습을 통해 검수 모델을 생성하는 방법, 그리고 상기 검수 모델을 적용하여 조제 포장된 의약품과 처방의 일치 여부를 판단하는 검수 시스템에 관한 것이다. The present invention relates to a data expansion and learning method for AI-based pharmaceutical vision inspection and an inspection system applying the same, and more particularly, to a method of expanding learning image data by combining single pill images for AI-based pharmaceutical vision inspection, A method of automatically labeling information on pills in the process of obtaining image data for learning, a method of generating an inspection model through learning using this image data for learning, and a method of matching the prescription and packaged medicines by applying the inspection model It is about an inspection system that determines whether or not.

정제(tablet) 등 고형 의약품의 조제와 관련된 기업, 약국 및 병원 등에서는 조제 업무 자동화를 위한 전자동 정제 분배 및 포장 시스템을 사용하고 있다. 관련 의료진들은 이를 이용하여 처방에 따라 약품을 자동으로 분류하고 포장한 뒤 환자에게 전달하게 된다. 이 때, 만일의 경우 발생할 수 있는 오조제를 방지하기 위해 환자에게 전달하기 전 관련 의료진들에 의한 약품 검수가 반드시 수행되어야 한다. 다만, 환자가 많거나 조제에 사용되는 취급 약품이 많은 대형병원 또는 약품의 장기 복용이 필요한 만성질환자를 대상으로 한 조제의 경우, 의료진들에 의한 전량 직접 검수가 불가능한 상황이며 이에 따른 시간 및 인력의 낭비 역시 크다는 문제점이 있다.Companies, pharmacies, hospitals, etc., related to the dispensing of solid medicines such as tablets, use fully automatic tablet dispensing and packaging systems for automating dispensing tasks. Related medical staff will use it to automatically classify and pack medicines according to prescriptions and deliver them to patients. At this time, in order to prevent misuse that may occur in case of emergency, drug inspection by related medical staff must be performed before delivery to the patient. However, in the case of dispensing for patients with chronic diseases who need to take long-term medications or in large hospitals with many patients or handling medications used in dispensing, it is impossible to directly inspect the entire amount by medical staff, and it takes time and manpower accordingly. Waste is also a problem.

약품 오조제로 인한 의료 사고는 환자의 생명과 직결될 수 있는 문제로 상당히 민감한 사안이다. 그러나 관련 기업, 약국 및 병원 등에선 수동으로 진행되는 직접 검수에 있어서 현재까지 많은 어려움을 겪고 있는 실정이다. A medical accident caused by misuse of medicines is a very sensitive issue as it can directly affect the lives of patients. However, related companies, pharmacies, hospitals, etc. are experiencing many difficulties until now in the direct inspection performed manually.

이와 관련하여 최근 포장이 완료된 약품에 대한 검수 장치 및 방법에 대한 연구 개발이 진행되고 있다. 또한, 포장 영상을 촬영한 뒤, 이를 바탕으로 한 비전 기반의 자동 검수 시스템이 현재 상용화되어 조제 자동화 시스템과 함께 판매되고 있다. 그러나 기존 영상처리 기술들만을 활용하여 포장 내 알약들을 검출하고 인식하는데는 분명한 한계가 있다. 기존 영상처리 기술들을 활용하는 경우, 알약의 영역을 분할하고 영상 내 알약들로부터 특징을 추출한 뒤 이를 매칭하여 인식하는 방법(규칙 기반 (Rule-based))으로 알약을 검출 및 인식해야 한다. 그런데, 알약의 경우 비슷한 크기, 모양, 색상을 지닌 경우가 대부분이며 실제 특징 추출이 어려운 알약들(투명 연질 캡슐 등) 또한 존재할 수 있어 이를 분류하고 검출하는데 어려움이 있다. 또한 본 기술이 적용될 환경을 고려했을 때, 포장 내에는 여러 정의 알약이 다양한 형태로 위치할 수 있어 기존의 영상처리 기술만을 사용하여 영상 내 알약의 특징들을 추출하고 매칭하는데 어려움이 있다.In this regard, research and development on an inspection device and method for recently packaged drugs are being conducted. In addition, after filming the packaging video, a vision-based automatic inspection system based on it is currently commercialized and sold together with a dispensing automation system. However, there are clear limitations in detecting and recognizing pills in packages using only existing image processing technologies. In the case of using existing image processing technologies, it is necessary to detect and recognize the pills by segmenting the area of the pill, extracting features from the pills in the image, and then matching and recognizing the pills (rule-based). However, most pills have a similar size, shape, and color, and pills (transparent soft capsules, etc.) for which actual feature extraction is difficult may also exist, making it difficult to classify and detect them. In addition, considering the environment to which the present technology will be applied, it is difficult to extract and match the features of the pills in the image using only the existing image processing technology because many pills can be located in various shapes in the packaging.

최근 많은 양의 데이터로부터 직접 특징을 추출하고 이를 학습해 영상 내 객체들을 검출 및 인식하는 인공지능 기술 기반의 딥러닝 모델들이 주목받고 있다. 이러한 딥러닝 기반 기술을 통하여 위 언급한 기존의 영상 처리 기술을 활용한 약품 검수 방법의 한계를 극복할 수 있을 것으로 판단된다.Recently, deep learning models based on artificial intelligence technology that extract features directly from a large amount of data and learn them to detect and recognize objects in images are attracting attention. Through this deep learning-based technology, it is believed that the limitations of the drug inspection method using the above-mentioned existing image processing technology can be overcome.

다만, 현재 딥러닝 기반 기술의 사용을 위해서는 학습을 위한 아주 많은 양의 데이터의 획득(영상 촬영)과 획득한 데이터 내의 알약들에 대한 정보(이름 및 위치 등)들의 라벨을 붙여주는 레이블링 작업이 필요한데, 이와 관련하여 딥러닝 기반 기술의 현장 적용 시 다음과 같은 문제점이 예상된다.However, in order to use the current deep learning-based technology, it is necessary to acquire a very large amount of data for learning (photographing an image) and label information (name and location, etc.) of the pills in the acquired data. , In this regard, the following problems are expected when deep learning-based technology is applied to the field.

조제 관련 기업, 약국 및 병원에서 취급하는 수많은 종의 알약들을 실제 조제 환경처럼 처방된 알약들의 조합으로 모두 표현할 수 없을 뿐 아니라, 학습 데이터 획득만을 위하여 수많은 알약들을 포장하는 것 또한 불가능하다. 설령 포장이 가능하다 해도 포장 내 각각의 알약들을 임의의 다양한 형태로 위치하게 하여 촬영하는 것 역시 불가능하다. 또한, 수많은 영상에 대하여 각 영상 내 객체(알약)들의 정보를 수작업으로 레이블링 하는 것은 시간과 작업 부하를 과도하게 요구한다는 문제점이 있다.Numerous types of pills handled by dispensing companies, pharmacies, and hospitals cannot be expressed as a combination of prescribed pills like a real dispensing environment, and it is also impossible to package numerous pills only for learning data acquisition. Even if packaging is possible, it is also impossible to photograph each tablet in a variety of arbitrary shapes. In addition, there is a problem in that manually labeling information of objects (pills) in each image for a large number of images requires excessive time and workload.

본 발명은 약품 조제 자동화 시스템을 통해 포장된 약품의 비전 검수에 딥러닝 기반의 영상 내 객체 검출 및 인식 기술을 적용하는데 있어서, 많은 양의 데이터를 획득해야 하는 문제(촬영 및 레이블링 등) 및 실제 조제 환경 적용을 위해 고려해야 할 문제(조합 및 포장, 포장 내 약품 위치 등)들로 인한 기술 적용의 어려움을 극복하기 위하여 새로운 데이터 확보(확장) 및 학습 방법과 이를 적용한 검수 시스템을 제공하는데 목적이 있다.In the present invention, in applying a deep learning-based object detection and recognition technology in an image to the vision inspection of packaged drugs through an automated drug preparation system, the problem of acquiring a large amount of data (photography and labeling, etc.) and the actual preparation The purpose is to provide a new data acquisition (expansion) and learning method and an inspection system that applies it to overcome difficulties in technology application due to problems to be considered for environmental application (combination and packaging, drug location in packaging, etc.).

본 발명은 실제 조제 환경 적용을 위한, i) 단일 알약 영상의 조합으로 학습 영상 및 레이블링 된 데이터를 확보하는 방법, ii) 처방이 주어진 후 처방에 따라 i) 방법을 사용하여 학습 데이터 생성 및 이를 이용한 학습과 검수 방법을 제안하고자 한다.The present invention, for application to a real pharmacy environment, i) a method for obtaining a learning image and labeled data by combining a single pill image, ii) generating learning data using the i) method according to a prescription after a prescription is given, and using the same I would like to suggest a learning and inspection method.

본 발명에서 제공하고자 하는 데이터 확보(확장) 및 학습 방법은 한 영상 내 여러 알의 알약이 다양한 형태로 함께 존재할 때 이를 대상으로 알약 검출 및 인식을 수행하기 위한 것이다.The data acquisition (expansion) and learning method to be provided in the present invention is for detecting and recognizing pills targeting multiple pills in one image in various forms.

우선 상기 방법을 적용할 약품 비전 검수 장비 내 촬영 환경(배경, 조명 등)은 항상 동일하므로 도 1a와 같이 처방에 포함된 알약이 6개일 때, 포장 후는 도 1b와 같이 약품 6알이 다양한 형태로 위치하게 된다.First of all, since the shooting environment (background, lighting, etc.) in the drug vision inspection equipment to which the above method is applied is always the same, when there are 6 pills included in the prescription as shown in FIG. will be located as

도 1a는 포장 전의 약품 영상의 예이며, 도 1b는 포장 후의 약품 영상의 예인데, 투명 포장인 경우를 가정하여 포장을 제외한 것이다. 1A is an example of an image of a drug before packaging, and FIG. 1B is an example of an image of a drug after packaging.

이 때 조제 자동화 시스템 적용을 위한 실제 조제 환경 및 상황을 고려해보면, 도 1a와 같이 포장 전 한 알의 알약을 각각 촬영하고 데이터베이스화 하여 이를 대상으로 학습을 진행한 뒤, 도 1b와 같이 한 영상에 여러 개의 알약이 다양한 형태로 위치한 포장 후 영상을 대상으로 영상 내 알약의 위치를 검출하고 약의 종류를 인식하는 방식으로 검수를 수행하여야 한다. 일반적으로 딥러닝 기술을 활용하여 객체 검출 및 인식을 하기 위해서는 대량의 학습 데이터(영상)가 필요하며, 학습에는 최종 판별할 영상(도 1b)과 가장 유사한 형태의 영상이 많이 사용될수록 검수 모델의 성능이 좋아지게 된다. 그러나 실제 조제 환경에서는 도 1a와 같이 하나의 알약 정도를 확보하여 촬영할 수 있을 뿐 여러 개의 알약을 한 번에 임의의 다양한 형태로 위치시켜 촬영하는 것은 불가능하다. 또한 이 때 각 알약에 대한 위치 및 이름 정보를 직접 레이블링하는 것 역시 불가능하다.At this time, considering the actual dispensing environment and situation for application of the automated dispensing system, each pill is photographed before packaging as shown in FIG. Inspection should be performed by detecting the location of the pills in the image and recognizing the type of the drug, targeting the image after packaging in which several pills are located in various forms. In general, a large amount of training data (images) is required to detect and recognize objects using deep learning technology, and the performance of the inspection model increases as the images most similar to the final image (Fig. 1b) are used for learning. this gets better However, in an actual dispensing environment, as shown in FIG. 1A, only one pill can be secured and photographed, but it is impossible to position and photograph several pills in various shapes at once. Also, at this time, it is also impossible to directly label location and name information for each pill.

딥러닝 분야에서 이런 경우, 학습 데이터를 충분히 확보하기 위하여 다양한 방법으로 데이터를 확장(Data Augmentation)하여 학습에 사용하는데, 영상 데이터에 대한 확장 방법으로는 대표적으로 영상의 환경(해상도, 조명 등) 변경 또는 객체(색상, 크기, 회전, 위치 등) 변화 등을 들 수 있다. 조제 자동화 시스템을 사용한 포장 약품 영상의 경우 영상의 촬영 환경이 고정되어 있으므로 데이터 확장 시 알약의 회전 및 위치 변화만 고려하여 데이터를 확장하고 학습하면 된다.In this case, in the field of deep learning, data augmentation is used for learning in various ways to secure sufficient training data. As an extension method for image data, a representative example is to change the image environment (resolution, lighting, etc.) Or object (color, size, rotation, position, etc.) change. In the case of packaged drug images using a dispensing automation system, since the shooting environment of the image is fixed, it is only necessary to expand the data and learn by considering only the rotation and position change of the pill when expanding the data.

따라서 도 2a, 도 2b와 같이 배경이 동일한 영상 내 알약의 위치(도 2a) 및 각도(도 2b)를 임의로 바꿔가며 영상을 다양하게 원하는 만큼 확장할 수 있다. 이 때 변화의 범위는 알약 위치의 경우 배경 영상 내 임의의 픽셀 위치(알약이 배경을 벗어나는 모서리 영역 제외), 각도는 0~360°(도) 사이로 볼 수 있으며 두 조건의 조합에 따라 대량의 데이터를 만들어 낼 수 있다. 또한 이와 더불어 알약의 픽셀 위치를 알 수 있으므로 대량의 영상데이터에 포함된 각각의 알약에 대해 그 이름과 위치에 대한 자동 레이블링(labeling)도 가능하다. Therefore, as shown in FIGS. 2A and 2B , the position ( FIG. 2a ) and the angle ( FIG. 2b ) of the pill in the image having the same background can be arbitrarily changed and the image can be expanded in various ways as desired. At this time, the range of change is any pixel position in the background image in the case of the pill position (except for the corner area where the pill is out of the background), and the angle can be viewed between 0 and 360° (degrees), and a large amount of data can be seen depending on the combination of the two conditions. can create In addition, since the pixel location of the pill can be known, automatic labeling of the name and location of each pill included in the large amount of image data is also possible.

다만 도 2a, 도 2b를 참조한 설명과 같은 방법에 따라 단일 알약만을 대상으로 영상을 확장하여 학습한 모델을 검수에 적용한 경우 오인식의 소지가 있다. 도 3a, 도 3b는 실제 알약의 포장 영상 내 여러 알의 알약이 동시에 다양한 형태로 존재하는 경우, 알약 검출 및 인식 결과를 나타낸 것이다. 도 3a와 같이 알약이 서로 거리를 두고 떨어져 있으면 각 알약을 제대로 검출하고 인식하지만, 도 3b와 같이 알약들이 서로 가깝게 위치하거나 접한 경우, 각각의 알약을 인식하지 못하고 하나의 알약으로 오인식하는 것을 볼 수 있다. However, if the model learned by expanding the image targeting only a single pill is applied to the inspection according to the same method as described with reference to FIGS. 2A and 2B, there is a possibility of misrecognition. 3A and 3B show pill detection and recognition results when several pills exist in various shapes at the same time in an actual pill packaging image. As shown in FIG. 3A, when the pills are spaced apart from each other, each pill is properly detected and recognized, but when the pills are located close to each other or come into contact with each other as shown in FIG. 3B, each pill is not recognized and misrecognized as one pill. there is.

이는 위 설명한 것과 같이 실제 시험에 사용되는 영상과 유사한 형태의 영상이 학습에도 많이 사용되어야 하지만 단일 알약만을 대상으로 영상을 확장하여 학습하는 경우 영상 내 알약들이 접하면서 생기는 다양한 형태들을 제대로 학습하지 못해 발생하는 현상으로 판단되며, 이를 위한 새로운 학습 데이터 확장 및 학습 방법이 필요하다.This is because, as described above, an image similar to the image used in the actual test should be used for learning, but when the image is expanded and learned for only a single pill, various forms generated by the pills in the image are not properly learned. It is judged to be a phenomenon, and a new learning data expansion and learning method is needed for this.

물론 검수 포장 내 알약이 하나만 존재하는 경우 본 방법으로도 충분한 성능을 보일 수 있지만, 대부분 실생활 중 처방에 따라 약국에서 받는 포장 및 포장 검수가 필요한 상황의 경우 한 포장 내 여러 알의 알약이 동시에 들어가 있는 형태일 것이므로, 하나의 알약만을 대상으로 한 데이터 확장 및 학습 방법에는 한계가 있으며, 본 방법을 포함한 새로운 알약 데이터 확장 및 학습 방법이 필요하다. Of course, if there is only one pill in the inspection package, this method can show sufficient performance, but in most real life situations where packaging and packaging inspection from pharmacies are required according to prescription, multiple pills in one package are included at the same time. Since it will be in the form of a pill, there is a limit to the data expansion and learning method targeting only one pill, and a new pill data expansion and learning method including this method is needed.

상기 목적을 달성하기 위한 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수 시스템은 알약 각각의 영상데이터 및 의약품 검수 모델 학습용 영상데이터를 저장하고, 상기 알약 각각의 영상데이터를 조합하여 상기 학습용 영상데이터를 생성하는 데이터관리부; 상기 데이터관리부에서 상기 학습용 영상데이터를 추출하고, 초기 검수 모델을 학습시켜 검수 모델을 생성하는 학습부; 상기 검수 모델을 실행시켜 실제 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식한 후, 오조제 여부를 판단하는 검수부; 및 처방이 접수되면 상기 데이터관리부, 상기 학습부 및 상기 검수부의 동작을 제어하는 제어부;를 포함한다.In order to achieve the above object, the AI-based medicine vision inspection system according to an embodiment of the present invention stores image data of each pill and image data for learning a medicine inspection model, and combines the image data of each pill to form the image data for learning. Data management unit for generating; a learning unit that extracts the video data for learning from the data management unit and generates an inspection model by learning an initial inspection model; an inspection unit that executes the inspection model to detect and recognize each pill in the actual prepared and packaged medicine image, and then determines whether or not there is an erroneous preparation; and a controller for controlling operations of the data management unit, the learning unit, and the inspection unit when a prescription is received.

상기 데이터관리부는 검수 대상이 될 수 있는 각 알약의 영상데이터를 저장하는 의약품 영상 DB; 상기 검수 모델 학습용 영상데이터를 저장하는 학습용 데이터 DB; 및 상기 알약 각각의 영상데이터를 조합하여 상기 학습용 영상데이터를 생성하여 상기 학습용 데이터 DB에 전달하는 학습용 데이터 생성부;를 포함할 수 있다.The data management unit includes a drug image DB storing image data of each pill that can be inspected; a learning data DB for storing image data for learning the verification model; and a learning data generation unit that generates the image data for learning by combining the image data of each of the pills and transfers the result to the learning data DB.

상기 데이터관리부는 검수 대상이 될 수 있는 각 알약이 가질 수 있는 면 중 적어도 한 면의 영상데이터를 저장할 수 있다.The data management unit may store image data of at least one side among the sides of each pill that may be inspected.

상기 데이터관리부는 상기 처방에 포함되는 각 알약에 대한 영상데이터를 추출하고, 추출한 상기 영상데이터별로 임의의 각도로 회전하여 배경영상의 임의의 위치에 배치하는 방식으로 상기 영상데이터와 상기 배경영상을 조합하여 학습용 영상데이터를 생성할 수 있다.The data management unit extracts image data for each pill included in the prescription, rotates each of the extracted image data at an arbitrary angle, and combines the image data and the background image in a manner of arranging them at an arbitrary position of the background image. Thus, image data for learning can be generated.

상기 데이터관리부는 학습용 영상데이터 생성 시 상기 처방에 포함되는 각 알약의 이름과 위치를 자동 레이블링할 수 있다.The data management unit may automatically label the name and location of each pill included in the prescription when generating image data for learning.

상기 데이터관리부는 설정파일이나 사용자 정책 중 적어도 하나에 따라 처방별 학습용 영상데이터의 생성 개수를 제한할 수 있다.The data management unit may limit the number of generated image data for learning for each prescription according to at least one of a setting file and a user policy.

상기 학습부는 상기 검수 모델을 해당하는 처방에 매칭시켜 함께 내부저장소에 저장할 수 있다.The learning unit may match the verification model to a corresponding prescription and store the same in an internal storage.

상기 제어부는 특정한 처방에 대하여 상기 학습부에 동일한 처방에 대해 이미 검수 모델이 존재하는 경우, 학습용 영상데이터 생성이나 초기 검수 모델의 학습 과정을 거치지 않고, 상기 검수부로 하여금 상기 검수 모델의 실행을 통해 상기 특정한 처방에 따라 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식함으로써 오조제 여부를 판단하도록 할 수 있다.When an inspection model for the same prescription already exists in the learning unit for a specific prescription, the control unit causes the inspection unit to execute the inspection model without going through a process of generating image data for learning or learning an initial inspection model. By detecting and recognizing each pill in the image of medicines packaged according to a specific prescription, it is possible to determine whether or not an erroneous preparation has been made.

상기 검수부는 상기 인식된 알약의 품목별로 개수를 산출하여 상기 처방과 일치하는지 여부를 확인함으로써 오조제 여부를 판단할 수 있다.The inspection unit may determine whether or not an erroneous medication has been taken by calculating the number of the recognized pills for each item and confirming whether the number matches the prescription.

상기 검수부는 상기 의약품 영상 내에서 각각의 알약에 대한 검출 및 인식 중 적어도 하나가 불가능하여 오조제 여부를 판단할 수 없는 경우 육안 검수가 필요하다는 내용을 출력할 수 있다.The inspection unit may output a message that a visual inspection is required when it is impossible to determine whether or not an erroneous medication has been taken because at least one of detection and recognition of each pill is impossible in the medicine image.

또한, 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수를 위한 데이터 확장 방법은 처방에 포함되는 각 알약에 대한 영상데이터를 의약품 영상 DB로부터 추출하는 단계; 상기 각 알약에 대한 영상데이터를 조합하여 학습용 영상데이터를 생성하는 단계; 및 상기 생성한 학습용 영상데이터를 학습용 데이터 DB에 저장하는 단계;를 포함한다.In addition, a data expansion method for AI-based pharmaceutical vision inspection according to an embodiment of the present invention includes the steps of extracting image data for each pill included in a prescription from a medicine image DB; generating image data for learning by combining the image data for each of the pills; and storing the generated image data for learning in a data DB for learning.

상기 각 알약에 대한 영상데이터는 상기 처방에 포함되는 각 알약이 가질 수 있는 면 중 적어도 한 면을 촬영한 영상데이터일 수 있다.The image data for each of the pills may be image data obtained by photographing at least one of the sides of each pill included in the prescription.

상기 각 알약에 대한 영상데이터의 조합은 상기 각 알약에 대한 영상데이터를 임의의 각도로 회전하여 배경영상의 임의의 위치에 배치하는 방식으로 조합한 것일 수 있다.The combination of image data for each pill may be combined by rotating the image data for each pill at an arbitrary angle and arranging the image data at an arbitrary position in the background image.

이 때, 본 발명은 상기 학습용 영상데이터 생성 단계 이후에 학습용 영상데이터에 포함된 각 알약의 이름과 위치를 상기 학습용 영상데이터에 자동으로 레이블링하는 단계;를 더 포함할 수 있다.At this time, the present invention may further include the step of automatically labeling the name and location of each pill included in the image data for learning to the image data for learning after the generating of the image data for learning.

또한, 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수를 위한 학습 방법은 처방에 포함되는 각 알약의 일면의 영상데이터가 하나의 배경영상에 조합된 형태로서, 각 알약의 이름과 위치가 레이블링되어 있는 학습용 영상데이터를 학습용 데이터 DB로부터 추출하는 단계; 상기 추출한 학습용 영상데이터로 초기 검수 모델을 학습시켜 검수 모델을 생성하는 단계; 및 상기 검수 모델을 저장하는 단계;를 포함한다.In addition, the AI-based learning method for pharmaceutical vision inspection according to an embodiment of the present invention is a form in which image data of one side of each pill included in a prescription is combined with a single background image, and the name and location of each pill are labeled. Extracting the image data for learning that has been done from the data DB for learning; Creating an inspection model by learning an initial inspection model with the extracted training image data; and storing the inspection model.

상기 검수 모델을 저장하는 단계는 상기 검수 모델을 해당하는 처방에 매칭시켜 함께 저장하는 것일 수 있다.The step of storing the inspection model may include matching the inspection model with a corresponding prescription and storing the inspection model together.

또한, 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수 방법은 처방에 대한 검수 모델이 존재하는지 판단하는 단계; 상기 처방에 대한 검수 모델이 존재하는 경우, 상기 검수 모델을 실행하여 실제 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식하는 단계; 상기 인식 결과를 바탕으로 의약품 품목별 개수를 산출하는 단계; 및 상기 산출된 의약품 품목별 개수와 처방을 비교하여 오조제 여부를 판단하는 단계를 포함한다.In addition, the AI-based drug vision inspection method according to an embodiment of the present invention includes the steps of determining whether an inspection model for a prescription exists; detecting and recognizing each pill in an image of an actual prepared and packaged medicine by executing the inspection model if there is an inspection model for the prescription; Calculating the number of medicines for each item based on the recognition result; and comparing the calculated number of medicines for each item with the prescription to determine whether or not there is a mistake.

이 때, 본 발명은 상기 판단 결과 처방에 대한 검수 모델이 존재하지 않는 경우, 상기 처방에 포함되는 각 알약에 대한 영상데이터를 의약품 영상 DB로부터 추출하는 단계; 상기 각 알약에 대한 영상데이터를 조합하여 학습용 영상데이터를 생성하는 단계; 및 상기 생성한 학습용 영상데이터로 초기 검수 모델을 학습시켜 검수 모델을 생성하는 단계; 를 더 포함할 수 있다.At this time, the present invention includes the steps of extracting image data for each pill included in the prescription from a drug image DB when the verification model for the prescription does not exist as a result of the determination; generating image data for learning by combining the image data for each of the pills; and generating an inspection model by learning an initial inspection model with the generated image data for learning. may further include.

본 발명의 일 실시예에 따르면, 처방에 포함된 알약의 영상만을 조합하여 학습에 이용함으로써, 약국이 보유하고 있는 모든 알약에 대한 영상을 조합하여 학습에 이용하는 경우에 비해 모델 학습 시간을 단축하면서도 목표로 하는 검출 및 인식 성능을 확보할 수 있다.According to an embodiment of the present invention, by combining only the images of pills included in the prescription and using them for learning, the model learning time is reduced compared to the case where images of all pills owned by the pharmacy are combined and used for learning. It is possible to secure the detection and recognition performance of

또한 본 발명의 일 실시예에 따르면, 특정 처방에 대해 학습된 모델을 동일한 처방에 대해 재사용할 수 있어서 검수에 필요한 시간을 단축할 수 있다.In addition, according to an embodiment of the present invention, a model learned for a specific prescription can be reused for the same prescription, so the time required for inspection can be reduced.

또한 본 발명의 일 실시예에 따르면 학습데이터 확장 시 배경 영상에 알약 영상을 합성할 때 특정 픽셀의 위치를 알약의 위치로 사용하므로 알약의 이름과 함께 알약의 위치에 대한 자동 레이블링이 가능하여, 학습데이터를 준비하는 시간과 작업 부하를 줄일 수 있다.In addition, according to an embodiment of the present invention, when a pill image is synthesized with a background image when expanding learning data, the location of a specific pixel is used as the location of the pill, so that the location of the pill can be automatically labeled along with the name of the pill. Reduce data preparation time and workload.

또한 본 발명의 일 실시예에 따르면, 처방에 포함된 알약의 영상을 면(面), 각도, 위치를 달리하여 조합한 영상을 학습에 이용한다. 이 방법을 통해 조제 환경의 특수성이 반영된 변수에 집중하여 다양한 경우의 수를 반영하여 데이터를 확장할 수 있으므로, 딥러닝에 충분한 양의 학습데이터를 확보할 수 있다. 그리고 상기 조합 영상을 학습에 이용한 결과, 영상 내 알약들 간의 다양한 위치 관계 및 알약의 형태(예를 들어, 전면/후면/측면)가 반영된, 실제 시험 영상과 유사한 형태의 학습데이터를 구성하여 모델을 학습할 수 있으므로, 단일 알약의 영상만을 사용하여 학습한 경우에 비해 검출 및 인식 성능이 뛰어나며, 특히 시험 영상에서 알약들이 서로 접해 있을 때 우수한 검출 및 인식 성능을 나타낸다.In addition, according to one embodiment of the present invention, images obtained by combining images of pills included in prescriptions in different planes, angles, and positions are used for learning. Through this method, it is possible to expand the data by focusing on variables reflecting the specificity of the pharmacy environment and reflecting the number of various cases, so that a sufficient amount of learning data can be secured for deep learning. And as a result of using the combined image for learning, various positional relationships between pills in the image and the shape of the pill (eg, front/rear/side) are reflected, and training data in a form similar to the actual test image is configured to build the model. Since learning is possible, the detection and recognition performance is excellent compared to the case of learning using only the image of a single pill, and especially when the pills are in contact with each other in the test image, the detection and recognition performance is excellent.

도 1a는 포장 전 약품 영상의 예.
도 1b는 포장 후 약품 영상의 예.
도 2a는 단일 알약 영상의 위치 변화를 통한 영상데이터 확장의 예.
도 2b는 단일 알약 영상의 각도 및 위치 변화를 통한 영상데이터 확장의 예.
도 3a는 단일 알약 영상을 확장한 영상으로 학습 후, 알약들이 떨어져 분포하는 영상에 대한 알약 검출 및 인식 결과.
도 3b는 단일 알약 영상을 확장한 영상으로 학습 후, 알약들이 가깝게 분포하는 영상에 대한 알약 검출 및 인식 결과.
도 4a는 준비 영상 중에서 6종의 약품에서 각 단일 약품에 대한 영상의 예.
도 4b는 준비 영상 중에서 배경 영상의 예.
도 5는 알약 2종의 앞면 영상을 이용한 영상 확장의 예.
도 6는 알약 6종의 앞면 영상을 이용한 영상 확장의 예.
도 7a은 단일 알약 영상을 확장한 영상으로 학습한 후의 시험 결과의 예.
도 7b는 복수 개의 알약 영상의 조합을 통해 확장한 영상으로 학습한 후의 시험 결과의 예.
도 8은 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수 시스템의 구성을 나타낸 블록도.
도 9는 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수 시스템의 데이터관리부의 구성을 나타낸 블록도.
도 10은 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수의 전체 과정을 나타낸 흐름도.
도 11은 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수를 위한 데이터 확장 방법을 설명하기 위한 흐름도.
도 12는 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수를 위한 학습 방법을 설명하기 위한 흐름도.
도 13은 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수 방법을 설명하기 위한 흐름도.
Figure 1a is an example of a drug image before packaging.
Figure 1b is an example of a drug image after packaging.
Figure 2a is an example of image data expansion through a change in the position of a single pill image.
Figure 2b is an example of image data expansion through angle and position change of a single pill image.
3A is a pill detection and recognition result for an image in which pills are separated and distributed after learning with an image obtained by expanding a single pill image.
3B is a result of detecting and recognizing pills for an image in which pills are closely distributed after training with an image obtained by expanding a single pill image.
Figure 4a is an example of an image for each single drug in six types of drugs among preparation images.
4B is an example of a background image among preparation images.
5 is an example of image expansion using front images of two types of pills.
6 is an example of image expansion using front images of six types of pills.
Fig. 7a is an example of a test result after learning a single pill image as an expanded image.
7B is an example of a test result after learning with an image expanded through a combination of a plurality of pill images.
8 is a block diagram showing the configuration of an AI-based medicine vision inspection system according to an embodiment of the present invention.
9 is a block diagram showing the configuration of a data management unit of an AI-based drug vision inspection system according to an embodiment of the present invention.
10 is a flowchart illustrating the entire process of AI-based vision inspection of medicines according to an embodiment of the present invention.
11 is a flowchart illustrating a data expansion method for AI-based pharmaceutical vision inspection according to an embodiment of the present invention.
12 is a flowchart for explaining a learning method for AI-based drug vision inspection according to an embodiment of the present invention.
13 is a flowchart illustrating an AI-based pharmaceutical vision inspection method according to an embodiment of the present invention.

본 발명의 이점 및 특징, 그리고 그것들을 달성하는 방법은 첨부되는 도면과 함께 상세하게 후술되어 있는 실시예들을 참조하면 명확해질 것이다. 그러나 본 발명은 이하에서 개시되는 실시예들에 한정되는 것이 아니라 서로 다른 다양한 형태로 구현될 것이며, 단지 본 실시예들은 본 발명의 개시가 완전하도록 하며, 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 발명의 범주를 완전하게 알려주기 위해 제공되는 것이며, 본 발명은 청구항의 범주에 의해 정의될 뿐이다. 한편, 본 명세서에서 사용된 용어는 실시예들을 설명하기 위한 것이며 본 발명을 제한하고자 하는 것은 아니다. 본 명세서에서, 단수형은 문구에서 특별히 언급하지 않는 한 복수형도 포함한다. 명세서에서 사용되는 "포함한다(comprises)" 및/또는 "포함하는(comprising)"은 언급된 구성소자, 단계, 동작 및/또는 소자는 하나 이상의 다른 구성소자, 단계, 동작 및/또는 소자의 존재 또는 추가를 배제하지 않는다.Advantages and features of the present invention, and methods of achieving them, will become clear with reference to the detailed description of the following embodiments taken in conjunction with the accompanying drawings. However, the present invention is not limited to the embodiments disclosed below, but will be implemented in various different forms, only these embodiments make the disclosure of the present invention complete, and common knowledge in the art to which the present invention belongs. It is provided to fully inform the holder of the scope of the invention, and the present invention is only defined by the scope of the claims. Meanwhile, terms used in this specification are for describing the embodiments and are not intended to limit the present invention. In this specification, singular forms also include plural forms unless specifically stated otherwise in a phrase. As used herein, "comprises" and/or "comprising" means that a stated component, step, operation, and/or element is the presence of one or more other components, steps, operations, and/or elements. or do not rule out additions.

본 발명을 설명함에 있어서, 관련된 공지 기술에 대한 구체적인 설명이 본 발명의 요지를 불필요하게 흐릴 수 있다고 판단되는 경우 그 상세한 설명을 생략한다. In describing the present invention, if it is determined that a detailed description of related known technologies may unnecessarily obscure the subject matter of the present invention, the detailed description will be omitted.

이하, 본 발명의 실시예를 첨부한 도면들을 참조하여 상세히 설명한다. 본 발명을 설명함에 있어 전체적인 이해를 용이하게 하기 위하여 도면 번호에 상관없이 동일한 수단에 대해서는 동일한 참조 번호를 사용하기로 한다.Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings. In order to facilitate overall understanding in describing the present invention, the same reference numerals will be used for the same means regardless of the drawing numbers.

본 발명에서 제공하는 데이터 확장 및 학습 방법은 한 영상 내 여러 알의 알약이 다양한 형태로 함께 존재할 때 이를 대상으로 알약 검출 및 인식을 수행하기 위한 것이다. The data expansion and learning method provided by the present invention is for detecting and recognizing pills targeting multiple pills in one image when they exist together in various shapes.

도 4a와 도 4b는 본 발명의 데이터 확장 방법과 관련하여 준비하여야 할 영상의 예시이다. 도 4a는 준비 영상 중에서 6종의 약품에서 각 단일 약품에 대한 영상의 예이고, 도 4b는 준비 영상 중에서 배경 영상의 예이다. 4A and 4B are examples of images to be prepared in relation to the data extension method of the present invention. 4A is an example of an image for each single drug among 6 types of drugs in the preparation image, and FIG. 4B is an example of a background image in the preparation image.

도 4a와 같이 검수 대상에 해당하는 알약 각각에 대하여 앞/뒤(정제류 약품 두 면의 형상이 다르거나 인쇄(imprint)가 다른 경우, 캡슐류 약품 내 인쇄의 유/무 면 등 경우), 측면(정제류 원형, 정방형 등 약품이 측면으로 서 있을 수 있는 경우 등) 등 알약이 검수 영상 내 존재할 수 있는 형태의 모든 면을 한 장씩 촬영하고, 알약들이 위치하게 될 배경 영상(도 4b)을 촬영하여 준비한다.As shown in Figure 4a, front / back (if the shape of the two sides of the tablet drug is different or the imprint is different, in the case of the presence / absence of printing in the capsule drug, etc.), side (e.g., tablets, round, square, etc. where medicines can stand sideways), etc., take a picture of all the shapes in which pills can exist in the inspection image, and take a background image where the pills will be located (FIG. 4b) prepare by

도 5는 상기 단일 약품에 대한 영상과 배경 영상의 합성을 통해 학습 영상을 확장하는 예이다. 알약 2종의 앞면 영상을 이용한 영상 확장의 예가 나타나 있다. 5 is an example of expanding a training image through synthesis of an image for the single drug and a background image. An example of image expansion using front images of two types of pills is shown.

도 5와 같이 각 알약에 대하여 임의 면에 해당하는 영상을 선택하여 임의의 각도로 회전한 뒤 배경 영상 내 임의의 픽셀 위치에 합성하여 원하는 장 수만큼의 영상을 만들어 학습 영상을 확장 생성하면 된다.As shown in FIG. 5, for each pill, an image corresponding to an arbitrary surface is selected, rotated at an arbitrary angle, and then synthesized at an arbitrary pixel position in the background image to create as many images as desired to create an extended learning image.

도 4의 예시와 같이 6종의 알약을 대상으로 처방에 각 알약을 1알씩을 포함하는 경우, 영상 확장을 위한 모든 경우는 아래 [수학식 1]과 같이 표현할 수 있다.As shown in the example of FIG. 4 , when the prescription includes 1 pill for each of 6 types of pills, all cases for image expansion can be expressed as in [Equation 1] below.

Figure pat00001
Figure pat00001

[수학식 1]에서 A 내지 F는 6종의 알약에 대해 각 알약이 가질 수 있는 면의 집합을 의미한다. 각 알약에 대한 면을 a 내지 f로 표시하였다. 각 면의 아래 첨자로 표시된 f는 앞, b는 뒤, s는 옆을 의미한다.In [Equation 1], A to F mean a set of faces that each pill can have for six types of pills. Sides for each pill are indicated as a to f. The subscripts on each side indicate f for the front, b for the back, and s for the side.

6종의 알약이 가질 수 있는 면(본 예시에서는 앞/뒤/측면)의 영상의 집합을 A에서 F로 표현했을 때, 각 알약에 대한 면의 영상의 집합에서 하나씩을 선택하는 조합의 곱으로 경우의 수를 표현하고, 여기에 각도의 변화를 1°로 설정했을 때 각도에 관한 경우의 수인 360을 곱하고, 영상의 픽셀 개수(가로 X 세로)를 곱하여 모든 경우를 표현할 수 있다. 단지 이렇게만 가정해도 대량의 영상 데이터를 생성할 수 있다. 또한, 본 방법의 경우 데이터 확장 시 배경 영상에 알약을 합성하기 위해 픽셀의 위치를 알약의 위치로 사용하므로 알약의 이름과 함께 무수히 많이 생성한 영상 내 알약에 대한 자동 레이블링이 가능하다. 최종적으로 이런 방법으로 확장하여 만든 영상들을 학습에 사용했을 때 최종 약품 검수에 있어 앞서 설명한 단일 알약의 영상을 이용하여 학습한 경우보다 현저히 좋은 성능을 기대할 수 있다.When the set of images of the faces (front/back/side in this example) that 6 types of pills can have is expressed from A to F, it is a product of combinations that select one from the set of images of the faces for each pill. The number of cases is expressed, and when the angle change is set to 1°, all cases can be expressed by multiplying this by 360, the number of cases related to the angle, and multiplying by the number of pixels (width X height) of the image. Just assuming this, a large amount of image data can be generated. In addition, in the case of this method, since the position of the pixel is used as the position of the pill to synthesize the pill in the background image during data expansion, it is possible to automatically label the pill in the image generated innumerably along with the pill name. Finally, when the images created by expanding in this way are used for learning, significantly better performance can be expected in the final drug inspection than in the case of learning using the image of a single pill described above.

도 6은 도 4에 도시된 6종의 알약의 앞면 영상만을 이용하여 영상을 확장한 예이다. 알약 간 인접한 경우도 있으며, 일정한 거리를 두고 떨어져 있는 경우도 있어서 알약 간 다양한 위치 관계를 학습용 데이터에 포함시킬 수 있다. FIG. 6 is an example of expanding an image using only front images of the six types of pills shown in FIG. 4 . In some cases, pills are adjacent to each other, and in some cases they are spaced apart from each other, so various positional relationships between pills can be included in learning data.

도 7a와 도 7b는 단일 알약의 영상을 확장한 영상으로 학습한 경우의 시험 결과와 복수 개의 알약 영상의 조합을 통해 확장한 영상으로 학습한 경우의 시험 결과를 비교한 것이다. 7A and 7B compare the test results obtained when learning with the expanded image of a single pill and the test result when learned with the expanded image through a combination of a plurality of pill images.

도 7a은 단일 알약의 영상만을 확장한 영상 데이터로 모델이 학습한 후의 시험 결과이며, 도 7b는 복수 개 알약 영상의 조합을 이용하여 영상 데이터를 확장하여 모델이 이를 학습한 후의 시험 결과인데, 도 7b와 같이 본 발명에서 제안한 방법을 사용하였을 때 시험 영상에서 알약들이 서로 접해 있을 때 더 좋은 검출 및 인식 성능을 보이는 것을 확인할 수 있다.7a is a test result after the model learns with image data in which only the image of a single pill is expanded, and FIG. 7b is a test result after the model learns by expanding image data using a combination of multiple pill images. As shown in 7b, when using the method proposed in the present invention, it can be confirmed that better detection and recognition performance is shown when the pills are in contact with each other in the test image.

위와 같이 딥러닝 기반 조제 포장 검수 시 학습용 데이터 생성을 위한 자동 데이터 확장 및 레이블링 방법을 제안했다면, 다음으로 이를 실제 조제 환경에 적용하기 위한 새로운 학습 방법이 필요하다. 검수 대상이 될 수 있는 모든 약품의 영상에서 복수 개의 영상을 추출한 뒤 이를 조합하여 학습용 영상 데이터를 확장하여 초기 검수 모델을 학습시키는 방법은 대량의 데이터를 생성하여 학습에 이용할 수는 있으나, 실제 조제 환경에 적합한 방법이라 보기 어렵다. 예를 들어 한 약국에서 취급하는 약품이 총 100종이라고만 가정했을 때, 처방에 따라 포장 내 포함할 수 있는 약품 수는 한 알부터 많게는 10알 이상일 수 있는데(nCk = 100Ck, k = 1 ~ 100), 처방에 포함되는 약품이 서로 다른 품목의 총 5개의 알약이라고 가정하더라도 그 경우의 수는 위 [수학식 1]과 같이 각 알약의 면을 선택하는 수식에 100개 중 다섯 개를 선택하는 100C5에 대한 조제 패턴의 경우를 더 곱해주어야 하며, 실제 조제 패턴에는 일부 약품이 중복으로 포함될 수도 있어 환자에 따라 매번 다른 처방에 대비하여 모든 약품 정보를 고려하여 학습용 데이터를 생성하고 검수 모델을 만들어 두는 것은 효율성이 낮아 현실적인 방법이라고 하기 어렵다. 또한 약국에서 취급하는 알약이 시기에 따라 추가되거나 변경되는 경우가 있어, 이에 따라 학습을 매번 새로 수행하는 것 또한 매우 번거로운 문제가 있다. 상기 문제들을 고려했을 때, 각 약국에서 취급하는 알약이 매우 다양하며, 처방에 따라 포장되는 알약 조합의 경우의 수도 너무 많은 환경에서, 모든 상황을 고려하여 학습용 영상 데이터를 확장하고 검수 모델을 만드는 것은 바람직하지 않다. If the automatic data expansion and labeling method for generating data for learning during deep learning-based packaging inspection is proposed as above, then a new learning method is needed to apply it to the actual pharmacy environment. The method of extracting multiple images from images of all drugs that can be inspected and then combining them to expand the learning image data to learn the initial inspection model can generate a large amount of data and use it for learning, but it is difficult to use in the actual preparation environment. It is difficult to see it as an appropriate method for For example, assuming that there are only 100 types of drugs in one pharmacy, the number of drugs that can be included in a package according to prescription can range from one to 10 or more ( n C k = 100 C k , k = 1 to 100), even if it is assumed that the drugs included in the prescription are a total of 5 pills of different items, the number of cases is 5 out of 100 in the formula for selecting the side of each pill as shown in [Equation 1] above The case of the dispensing pattern for the selected 100 C 5 needs to be multiplied more, and the actual dispensing pattern may include some drugs redundantly, so create and check data for learning by considering all drug information in preparation for different prescriptions for each patient It is difficult to say that making a model is a realistic method due to its low efficiency. In addition, there are cases in which pills handled by pharmacies are added or changed depending on the time, and accordingly, it is very cumbersome to perform new learning every time. Considering the above problems, in an environment where pills handled by each pharmacy are very diverse and the number of combinations of pills packaged according to prescription is too large, it is Not desirable.

일반적으로 딥러닝 기반의 영상 내 객체 검출 및 인식에 있어 많은 양의 데이터를 복잡한 네트워크를 통하여 긴 시간 학습하는 것은 다양한 객체(사람, 동물, 자동차 등)를 대상으로 다양한 환경에서 이를 인식하기 위함이다. 그런데, 조제 자동화 시스템을 사용한 포장 약품 영상의 경우 촬영 환경이 항상 동일하고 영상 내 검출되는 객체의 대부분이 알약이라는 특수성이 있다. 따라서 이러한 특수성을 고려하여, 검수 대상이 되는 모든 알약에 대한 모든 조합의 경우의 수에 따른 학습용 데이터를 준비하고 이를 이용하여 초기 검수 모델을 학습시키기 보다는, 처방을 전달받은 직후, 처방에 따라 초기 검수 모델을 학습시키는 것이 유리할 것으로 판단된다. 즉, 처방에 나타난 조제 패턴을 반영한 학습용 영상 데이터를 생성한 후 이를 이용하여 초기 검수 모델을 학습시켜 검수 모델을 생성하고, 이 검수 모델을 검수에 사용하는 것이다. 이 방법은 모든 알약에 대한 영상 데이터를 조합하여 모델을 학습시키는 경우에 비해 학습용 데이터의 양을 줄여 학습용 영상데이터(학습용 데이터)의 생성 시간과 초기 검수 모델의 학습 시간을 단축시킴과 동시에 조제 검수에 최적화되고 간소화된 검수 모델을 만들 수 있다. 한편, 다른 이물질이나 오조제로 인하여 처방하지 않은 알약이 약품 포장에 추가되어, 검수 결과 학습한 알약 중 하나로 인식되더라도, 상기 간소화된 모델로도 충분히 검수가 가능하다. 검수 시 오조제 판단의 첫번째 조건은 처방과 비교한 알약 개수의 일치 여부이기 때문이다. In general, in deep learning-based object detection and recognition in images, learning a large amount of data for a long time through a complex network is to recognize various objects (humans, animals, cars, etc.) in various environments. However, in the case of an image of a packaged drug using an automated dispensing system, the photographing environment is always the same and most of the objects detected in the image are pills. Therefore, considering this specificity, rather than preparing learning data according to the number of cases of all combinations of all pills to be inspected and using this to learn the initial inspection model, the initial inspection according to the prescription immediately after receiving the prescription It is considered advantageous to train the model. That is, after generating image data for learning that reflects the dispensing pattern appearing in the prescription, an initial inspection model is learned using this image data to generate an inspection model, and this inspection model is used for inspection. Compared to the case of learning the model by combining image data for all pills, this method reduces the amount of training data, shortens the time to create training image data (learning data) and the learning time of the initial inspection model, Optimized and streamlined inspection models can be created. On the other hand, even if an unprescribed pill is added to the medicine package due to other foreign substances or erroneous preparation and is recognized as one of the learned pills as a result of the inspection, the simplified model can be sufficiently inspected. This is because the first condition for determining false medicine during inspection is whether the number of pills compared with the prescription matches.

예를 들어 위 도 4 및 [수학식 1]에 나와 있는 A 내지 F의 알약 중 A, B, D, E에 대해 처방이 주어졌다고 가정하자. 처방으로 A가 2개, B가 1개, D가 1개, E가 3개(총 7개의 알약)가 주어졌을 때, 각 알약이 가질 수 있는 면은 A가 3가지, B가 3가지, D가 1가지, E가 2가지이므로, 알약 영상을 선택할 수 있는 경우의 수는 [수학식 2]와 같다. 약국에서 취급하는 전 종의 알약 중 임의의 4종의 알약에 대해 7개의 영상을 선택할 경우, 선택할 수 있는 경우의 수의 계산, 데이터 확장 및 학습에 있어서 복잡하고 어려운 상황이 발생하는데, 본 발명에서 제안한 방법을 따를 경우 이와 같은 상황을 고려하지 않아도 된다는 장점이 있다. For example, assume that prescriptions are given for A, B, D, and E among pills A to F shown in FIG. 4 and [Equation 1]. Given 2 A's, 1 B's, 1 D's, and 3 E's (a total of 7 pills), each pill can have 3 A's, 3 B's, Since there is one type of D and two types of E, the number of cases in which a pill image can be selected is as shown in [Equation 2]. In the case of selecting 7 images for any 4 types of pills among all types of pills handled by pharmacies, a complicated and difficult situation arises in calculating the number of cases that can be selected, expanding data, and learning. The proposed method has the advantage of not having to consider such a situation.

Figure pat00002
Figure pat00002

본 발명은 [수학식 2]와 같이 처방에 포함된 약품 범위 내에서 각 알약의 면을 조합할 수 있는 모든 경우의 수를 반영하여 데이터를 확장하고 모델을 학습할 수 있다. 또한, 본 발명이 적용되는 상황은 앞서 설명한 것과 같이 영상 내 환경 변화가 없고 정해진 객체의 형태 및 이동만 있는 상황이므로, 설정 파일이나 사용자 정책에 따라 학습이 가능한 최소 장수를 설정하여 학습용 영상데이터를 확장하고 모델을 학습할 수도 있다. 본 발명에서 제안한 데이터 확장 방법으로 학습이 가능한 최소 장수만을 확장하고, 최적화된 간소화 네트워크(예를 들면 신경망)를 사용해 최단 시간 학습하는 방법으로 검수 모델을 만들면, 단일한 처방에 대해 최적화된 검수가 가능하다. 더불어 이 경우 처방에 따라 데이터 확장과 모델 학습이 진행되므로, 약국 내에서 취급하는 약 종이 추가되거나 제외되는 상황에도 영향을 받지 않을 수 있게 된다. As shown in [Equation 2], the present invention can expand data and learn a model by reflecting the number of all cases in which the sides of each pill can be combined within the range of drugs included in the prescription. In addition, since the situation to which the present invention is applied is a situation in which there is no change in the environment in the image and only the shape and movement of a predetermined object as described above, the video data for learning is expanded by setting the minimum number of chapters that can be learned according to the setting file or user policy. and train the model. Optimized inspection for a single prescription is possible by extending only the minimum number of longevity that can be learned with the data expansion method proposed in the present invention and creating an inspection model by using an optimized simplification network (e.g., a neural network) to learn in the shortest time. do. In addition, in this case, since data expansion and model learning proceed according to the prescription, it can be unaffected by situations in which drug species handled in the pharmacy are added or excluded.

오조제는 약품 누락, 초과, 변경, 이물질 등의 경우가 있다. 오조제 여부 판단을 위한 약품 검수는 한 포장을 대상으로 인식된 약 종 및 각 종의 개수가 처방과 일치하는지 여부를 기준으로 진행된다. 본 발명에서 제안한 방법에 따를 때, 오조제 중에서 약품 누락이나 초과의 경우는 각 종의 개수가 처방과 불일치할 것이므로 오조제로 판단할 수 있다. 또한, 오조제 중에서 변경이나 이물질이 포함되는 경우, 학습하지 못한 객체를 학습한 알약과 유사한 것으로 검출/인식하더라도 최종적으로는 약종(품목)별 개수가 처방과 다르므로 이를 오조제로 판단할 수 있다. 결국 변경이나 이물질 포함의 경우도 본 발명의 최종 검수 성능에 영향을 미치지 않는다. Omissions may include medication omission, excess, alteration, foreign matter, and the like. The drug inspection to determine whether or not there is an error is conducted based on whether the type of drug recognized for one package and the number of each type match the prescription. According to the method proposed in the present invention, in the case of omission or excess of medicines, it can be determined as a false medicine because the number of each type will not match the prescription. In addition, if a change or a foreign substance is included in the false medicine, even if the unlearned object is detected/recognized as similar to the learned pill, it can be determined as the false medicine because the number of each drug type (item) is different from the prescription. After all, the change or the inclusion of foreign substances does not affect the final inspection performance of the present invention.

본 발명이 적용될 수 있는 경우에 대해 살펴본다. 병원 진료 후 며칠 분의 약만 처방받아 근처 약국에서 바로 약을 받아가는 상황에서는 경우에 따라 처방 후 약을 포장하고 받기 전까지 처방에 대한 데이터를 생성하여 학습하는 시간이 부족할 수 있다. 소량의 조제 포장에서는 약사의 직접 육안 검수가 우선된다. Let's take a look at the case where the present invention can be applied. In a situation where only a few days' worth of medicine is prescribed after treatment at the hospital and the medicine is taken directly from a nearby pharmacy, in some cases, there may be insufficient time to create and learn prescription data before packing and receiving the medicine after prescription. Direct visual inspection by a pharmacist takes precedence in the packaging of small quantities of dispensing.

본 발명에서 제안한 방법은 위와 달리 조제 자동화 시스템 적용에 적합한 방법으로, 환자가 많은 대형 병원, 노인요양시설 또는 약의 장기 복용이 필요한 만성 질환자를 대상으로 한 번의 진료에 약품 복용 기간이 길어 많은 양의 조제 및 검수가 필요한 경우 활용 가치가 높은 방법이다. 왜냐하면 처방 및 포장 후 약품이 환자에게 전달되기까지의 시간 간격이 소량 포장의 경우보다 길어서 충분한 학습시간을 확보할 수 있을 뿐만 아니라, 각 환자에 대한 처방이 거의 일정하므로 각 처방에 대하여 한 번 학습한 모델을 환자와 매칭해 두면 다음 처방 시 약이 바뀌지 않으면 다시 모델을 학습하지 않아도 된다는 장점이 있기 때문이다. Unlike the above, the method proposed in the present invention is suitable for the application of an automated dispensing system, and is suitable for large hospitals with many patients, nursing facilities for the elderly, or patients with chronic diseases who need long-term use of drugs. It is a method with high utilization value when preparation and inspection are required. Because the time interval from prescription and packaging until the drug is delivered to the patient is longer than in the case of small quantity packaging, not only can sufficient learning time be secured, but also since the prescription for each patient is almost constant, it is possible to learn about each prescription once. This is because matching the model with the patient has the advantage of not having to learn the model again unless the drug is changed for the next prescription.

다만 본 발명은 약사나 관련 의료진의 조제 후 약품 검수를 지원하기 위한 것으로 검수 후 결과에 대하여 비전 기반의 판단이 불가능한 경우 (알약이 완전히 포개져 영상 내 확인이 불가능한 경우 등) 최종적인 직접 육안 검수가 동반되어야 한다. However, the present invention is intended to support drug inspection after dispensing by pharmacists or related medical staff, and when vision-based judgment on the results after inspection is impossible (when the pills are completely overlapped and cannot be confirmed in the image, etc.), the final direct visual inspection should be accompanied

이하, 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자가 본 발명의 기술적 사상을 용이하게 실시할 수 있도록 본 발명의 실시 예를 도면을 참조하여 설명할 것이다. Hereinafter, embodiments of the present invention will be described with reference to the drawings so that those skilled in the art can easily practice the technical spirit of the present invention.

도 8은 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수 시스템(비전 검수 시스템으로 약칭, 10)의 구성을 나타낸 블록도이다. 도 8에 도시된 바와 같이, 본 발명의 일 실시예에 따른 비전 검수 시스템(10)은 데이터관리부(100), 학습부(200), 검수부(300) 및 제어부(400)를 포함한다. 8 is a block diagram showing the configuration of an AI-based pharmaceutical vision inspection system (abbreviated as a vision inspection system, 10) according to an embodiment of the present invention. As shown in FIG. 8 , the vision inspection system 10 according to an embodiment of the present invention includes a data management unit 100, a learning unit 200, an inspection unit 300, and a control unit 400.

데이터관리부(100)는 검수 대상이 될 수 있는 알약 각각의 영상데이터 및 조제 포장된 의약품의 검수에 사용되는 모델(검수 모델)의 학습용 영상데이터(학습용 데이터)를 저장하고, 알약 각각의 영상데이터를 조합하여 학습용 영상데이터를 생성한다. 알약 각각의 영상데이터란 검수 대상이 될 수 있는 각 알약이 가질 수 있는 면 중 적어도 한 면의 영상데이터를 말한다. 예를 들어 알약이 구 형상을 가진다면 그 알약이 가질 수 있는 면은 1개의 면이 되며, 그 1개의 면에 대한 영상데이터를 저장한다. 다른 예를 들어 알약이 정제이고 앞면과 뒷면의 음각이나 인쇄가 다르며, 측면으로도 서 있을 수 있는 경우 해당 알약이 가질 수 있는 면은 앞면/뒷면/측면의 3개의 면이 되며, 그 3개의 면에 대한 영상데이터를 저장한다. The data management unit 100 stores image data for each pill that can be inspected and image data for learning (learning data) of a model (inspection model) used for inspecting prepared and packaged medicines, and image data for each pill Combined to generate image data for learning. The image data of each pill refers to image data of at least one side among the sides of each pill that can be inspected. For example, if a pill has a spherical shape, the surface that the pill can have is one surface, and image data for the one surface is stored. For another example, if the pill is a tablet, the intaglio or printing on the front and back is different, and it can stand on its side, the sides that the pill can have are the three sides of the front/back/side, and those three sides It stores the image data for

학습부(200)는 데이터관리부(100)에서 학습용 영상데이터를 추출하여 초기 검수 모델을 학습시킨 후 검수 모델을 생성하여 저장한다. 이 때 학습부(200)는 검수 모델을 해당하는 처방(약종별 개수)에 매칭시켜 함께 내부저장소에 저장한다. 또한 학습부(200)는 내부저장소에 해당 처방을 받은 환자의 ID나 이름을 함께 저장할 수 있다. 검수 모델을 저장한 이후에 동일한 처방이 접수되는 경우, 기존 검수 모델을 재사용하기 위함이다. 기존 검수 모델을 다시 사용하는 경우 학습용 데이터 생성 시간과 초기 검수 모델의 학습 시간이 필요하지 않게 되므로 다른 새로운 처방에 대한 학습용 데이터 생성 및 학습 시간을 추가로 확보하거나 검수에 신속히 착수할 수 있다. The learning unit 200 extracts the image data for learning from the data management unit 100, trains an initial inspection model, and then creates and stores the inspection model. At this time, the learning unit 200 matches the inspection model to the corresponding prescription (the number of each drug type) and stores them together in the internal storage. In addition, the learning unit 200 may also store the ID or name of the patient who has received the corresponding prescription in the internal storage. This is to reuse the existing inspection model when the same prescription is received after saving the inspection model. If the existing review model is used again, the time for creating data for learning and the time for learning the initial review model is not required, so it is possible to secure additional time for creating data for learning and learning for other new prescriptions, or to start review quickly.

검수부(300)는 검수 모델을 실행시켜 실제 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식한 후, 오조제 여부를 판단한다. 검수부(300)는 인식된 알약의 품목별로 개수를 산출하여 처방과 일치하는지 여부를 확인함으로써 오조제 여부를 판단한다. 선택적으로, 검수부(300)는 의약품 영상 내에서 각각의 알약에 대한 검출이 되지 않거나 검출이 되더라도 인식이 되지 않아 오조제 여부를 판단할 수 없는 경우 육안 검수가 필요하다는 내용을 화면이나 소리를 이용하여 출력함으로써 최종적인 직접 육안 검수가 이루어지도록 할 수 있다. The inspection unit 300 executes an inspection model to detect and recognize each pill in the image of an actual prepared and packaged medicine, and then determines whether or not it is an erroneous preparation. The inspection unit 300 determines whether or not to take a wrong pill by calculating the number of recognized pills for each item and checking whether or not they match the prescription. Optionally, the inspection unit 300 uses a screen or sound to indicate that visual inspection is necessary if each pill is not detected in the medicine image or if it is not recognized even if it is detected, so it is not possible to determine whether or not it is an erroneous pill. By printing it out, final direct visual inspection can be performed.

제어부(400)는 처방이 접수되면 데이터관리부(100)가 처방에 포함된 알약의 범위에서 학습용 데이터를 생성하도록 하고, 학습부(200)가 생성된 학습용 데이터를 이용하여 초기 검수 모델을 학습시키도록 하며, 검수부(300)가 검수 모델을 실행시켜 오조제 여부를 판단하도록 한다. 제어부(400)는 접수된 특정한 처방에 대해 과거에 이와 동일한 처방이 존재하여 학습부(200)에 그 처방에 대해 이미 검수 모델이 존재하는 경우, 학습데이터 생성이나 초기 검수 모델의 학습 과정을 거치지 않고, 검수부(300)로 하여금 검수 모델의 실행을 통해 상기 특정한 처방에 따라 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식함으로써 오조제 여부를 판단하도록 한다. 제어부(400)는 특정 환자의 처방에 대해 검수 모델이 존재하는지 판단할 수도 있다. 이 경우 해당 환자에 대한 처방이 동일하면 검수 모델을 상기와 같이 재사용할 수 있다. When a prescription is received, the control unit 400 causes the data management unit 100 to generate learning data within the range of pills included in the prescription, and the learning unit 200 to learn an initial inspection model using the generated training data. And, the inspection unit 300 executes the inspection model to determine whether there is an error. The control unit 400 does not go through a process of generating learning data or learning an initial inspection model when a review model already exists for the prescription in the learning unit 200 because the same prescription exists in the past for a specific prescription received. , The inspection unit 300 detects and recognizes each pill in the image of medicines dispensed and packaged according to the specific prescription through the execution of the inspection model, thereby determining whether or not an erroneous preparation has been made. The controller 400 may determine whether a verification model exists for a specific patient's prescription. In this case, if the prescription for the patient is the same, the verification model can be reused as described above.

도 9는 본 발명의 일 실시예에 따른 비전 검수 시스템(10)의 데이터관리부(100)의 구성을 나타낸 블록도이다. 9 is a block diagram showing the configuration of the data management unit 100 of the vision inspection system 10 according to an embodiment of the present invention.

본 발명의 일 실시예에 따른 비전 검수 시스템(10)의 데이터관리부(100)는 의약품 영상 DB(110), 학습용 데이터 DB(120) 및 학습용 데이터 생성부(130)를 포함한다.The data management unit 100 of the vision inspection system 10 according to an embodiment of the present invention includes a medicine image DB 110, a learning data DB 120, and a learning data generating unit 130.

의약품 영상 DB(110)는 검수 대상이 될 수 있는 알약 각각의 영상데이터와 영상 조합에 사용될 배경영상을 저장한다. 또한, 의약품 영상 DB(110)는 알약의 이름, 식별 코드 등 알약에 관한 기본 정보를 저장한다. 알약 각각의 영상데이터란 검수 대상이 될 수 있는 각 알약이 가질 수 있는 면 중 적어도 한 면의 영상데이터를 말한다. 예를 들어, 의약품 영상 DB(110)는 검수 대상에 해당하는 알약 각각에 대하여 앞/뒤(정제류 약품 두 면의 형상이 다르거나 인쇄(imprint)가 다른 경우, 캡슐류 약품 내 인쇄의 유/무 면 등 경우), 측면(정제류 원형, 정방형 등 약품이 측면으로 서 있을 수 있는 경우 등) 등 알약이 검수 영상 내 존재할 수 있는 형태의 모든 면에 대한 영상을 저장할 수 있다. 한편 의약품 영상 DB(110)가 저장하는 알약의 식별 코드는 의약품 표준코드(Korea Drug Code)나 의약품 표준코드의 일부(예를 들면 제약사 코드 4자리와 포장을 제외한 품목코드 4자리의 조합)일 수 있다. The medicine image DB 110 stores image data of each pill that can be inspected and a background image to be used for image combination. In addition, the medicine image DB 110 stores basic information about the pill, such as the name of the pill and an identification code. The image data of each pill refers to image data of at least one side among the sides of each pill that can be inspected. For example, the drug image DB 110 is used for each of the pills subject to inspection in front/back (if the shape of the two sides of the tablet drug is different or the imprint is different, the presence/absence of printing in the capsule drug It is possible to save images of all the shapes of pills that can exist in the inspection image, such as non-noodles) and sides (circular or square tablets, etc.). Meanwhile, the identification code of the pill stored in the drug image DB 110 may be a drug standard code (Korea Drug Code) or a part of the drug standard code (for example, a combination of a 4-digit pharmaceutical company code and a 4-digit item code excluding packaging). there is.

학습용 데이터 DB(120)는 초기 검수 모델의 학습에 이용되는 영상데이터를 저장한다. 본 발명에서 이용되는 학습용 영상데이터는 배경 영상에 처방에 포함된 각 알약의 일면의 영상이 조합된 형태이다. 학습용 데이터 DB(120)는 학습용 영상데이터에 레이블링된 각 알약에 관한 데이터(위치, 이름, 식별코드)를 해당하는 학습용 영상데이터와 매칭하여 함께 저장한다. The learning data DB 120 stores image data used for learning of the initial verification model. The image data for learning used in the present invention is a combination of a background image and an image of one side of each pill included in the prescription. The learning data DB 120 matches the data (location, name, identification code) of each pill labeled in the learning image data with the corresponding learning image data and stores them together.

학습용 데이터 생성부(130)는 알약 각각의 영상데이터를 조합하여 학습용 영상데이터를 생성하여 학습용 데이터 DB(120)에 전달한다. 학습용 데이터 생성부(130)는 처방에 포함되는 각 알약에 대한 임의의 면에 대한 영상데이터와 배경영상을 의약품 영상 DB(110)로부터 추출하고, 각 알약에 대한 임의의 면에 대한 영상데이터별로 임의의 각도로 회전하여 배경영상의 임의의 위치에 합성하여 배치하는 방식으로 영상데이터와 배경영상을 조합하여 학습용 영상데이터를 확장 생성한다. 학습용 영상데이터의 장 수는 원하는 만큼 생성할 수 있으며, 후술하는 설정파일이나 사용자 정책으로 설정할 수 있다. 검수 시스템의 처리 속도, 학습에 사용할 수 있는 시간, 조제 환경, 검수 모델의 목표 성능 또는 처방에 포함된 약종별 개수에 따라 학습용 영상데이터의 생성 개수를 증가시킬 수 있고, 최대 개수를 생성하여 이를 이용하여 초기 검수 모델을 학습할 수도 있을 것이다. 처방되는 약 종(품목)이 정해졌다고 할 때, 합성할 수 있는 학습용 데이터의 최대 개수는 각 알약이 가질 수 있는 면 중 하나를 선택하는 조합(한 품목의 알약이 복수 개인 경우 중복 조합)의 곱([수학식 1]의 예시를 참조)에 각 단일 알약 영상의 회전 각도의 경우의 수(예를 들어 1도씩 변화시킨다면 360가지) 및 각 단일 알약 영상의 위치의 경우의 수를 곱한 것이다. 이 때 각 단일 알약 영상의 위치의 경우의 수는 배경 영상의 픽셀 개수(가로와 세로의 곱)에서 각 알약의 영상데이터를 회전하여 배경영상에 배치할 때 모서리 근처에 배치되어 알약의 영상이 배경을 벗어나는 경우를 제외한 것이 된다. 이 때 학습용 데이터 생성부(130)는 학습용 영상데이터에 알약의 이름과 배치된 위치(즉, 알약의 위치)를 자동으로 레이블링하여 학습용 데이터 DB(120)에 함께 전달하여, 학습용 데이터 DB(120)가 학습용 영상데이터에 알약의 이름과 알약의 위치를 매칭하여 저장하도록 할 수 있다. 다른 실시예로서, 알약의 식별 코드를 학습용 영상데이터에 레이블링하여 함께 학습용 데이터 DB(120)에 전달하거나, 알약의 식별 코드를 알약의 이름 대신 전달할 수 있다. 이 경우 학습용 데이터 DB(120)는 학습용 영상데이터에 알약의 위치와 알약의 이름 또는 알약의 식별코드를 매칭하여 저장한다. 한편, 본 발명의 검수 시스템의 사용자는 설정 파일이나 사용자 정책을 통해 처방별 학습용 영상데이터의 생성 개수를 제한 설정할 수 있는데, 이 경우 학습용 데이터 생성부(130)는 설정된 생성 개수까지만 학습용 영상데이터를 생성하여 학습용 데이터 DB(120)에 전달한다. 학습용 데이터 DB(120)는 생성된 학습용 영상데이터를 저장한다. 처방별 학습용 영상데이터의 생성 개수는 앞서 언급한 대로 학습에 사용할 수 있는 시간, 검수 모델의 목표 성능, 처방 등에 따라 달라질 수 있다. The learning data generator 130 combines the image data of each pill to generate the learning image data and transfers it to the learning data DB 120 . The learning data generation unit 130 extracts image data and background images for an arbitrary side of each pill included in the prescription from the medicine image DB 110, and randomly selects image data for an arbitrary side of each pill. The image data for learning is expanded and created by combining the image data and the background image by rotating at an angle of , synthesizing and arranging the background image at an arbitrary position. The number of sheets of image data for learning can be generated as much as desired, and can be set in a setting file or user policy described later. Depending on the processing speed of the inspection system, the time available for learning, the dispensing environment, the target performance of the inspection model, or the number of each drug type included in the prescription, the number of generated image data for learning can be increased, and the maximum number can be generated and used. By doing so, the initial inspection model may be learned. Assuming that the type of drug (item) to be prescribed is determined, the maximum number of training data that can be synthesized is the product of a combination that selects one of the sides that each pill can have (redundant combinations in the case of multiple pills of one item) (Refer to the example of [Equation 1]) multiplied by the number of rotation angle cases of each single pill image (for example, 360 cases when changing by 1 degree) and the number of position cases of each single pill image. At this time, the number of positions of each single pill image is the number of pixels of the background image (product of width and height), and when the image data of each pill is rotated and placed in the background image, it is placed near the corner so that the pill image is displayed in the background. Except for cases outside of At this time, the learning data generation unit 130 automatically labels the name of the pill and the placed position (ie, the position of the pill) in the learning image data and transfers them together to the learning data DB 120, and the learning data DB 120 The name of the pill and the location of the pill can be matched and stored in the image data for learning. As another embodiment, the identification code of the pill may be labeled with the image data for learning and transmitted together to the learning data DB 120, or the identification code of the pill may be transmitted instead of the name of the pill. In this case, the learning data DB 120 matches and stores the location of the pill with the name of the pill or the identification code of the pill in the image data for learning. On the other hand, the user of the inspection system of the present invention can limit the number of generated learning image data for each prescription through a setting file or user policy. In this case, the learning data generator 130 generates learning image data up to the set number of times. and transferred to the learning data DB 120. The learning data DB 120 stores the generated image data for learning. As mentioned above, the number of generated image data for learning for each prescription may vary depending on the time available for learning, the target performance of the inspection model, and the prescription.

도 10은 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수의 전체 과정을 나타낸 흐름도이다. 10 is a flowchart illustrating the entire process of AI-based vision inspection of medicines according to an embodiment of the present invention.

S10 단계는 처방이 있을 경우, 처방에 대한 검수 모델이 존재하는지 판단하는 단계이다. 동일한 처방에 대해 기존 검수 모델이 있을 경우, 이를 재사용함으로써 데이터 확장과 학습 과정을 생략하여 검수에 필요한 시간을 단축하기 위함이다. 또는 해당 환자의 과거 실적이 있을 경우, S10 단계에서 해당 환자의 처방에 대해 검수 모델이 존재하는지 판단할 수 있다. 각 처방에 대하여 한 번 학습한 모델을 환자와 매칭해 둔 경우 다음 처방 시 해당 환자에 대해 처방이 동일하면 검수 모델을 재사용할 수 있기 때문이다. Step S10 is a step of determining whether a verification model for the prescription exists if there is a prescription. This is to reduce the time required for inspection by omitting the data expansion and learning process by reusing the existing inspection model for the same prescription. Alternatively, if there is a past performance of the patient, it may be determined whether a review model exists for the patient's prescription in step S10. This is because, if the model learned once for each prescription is matched with a patient, the verification model can be reused if the prescription is the same for the patient at the next prescription.

S100 단계는 처방에 대한 처방에 대한 검수 모델이 존재하지 않는 경우, 단일 알약에 대한 영상 데이터를 조합하여 학습용 데이터를 확장 생성하는 단계이다. 이 단계는 처방에 포함되는 각 알약에 대한 영상데이터를 의약품 영상 DB(110)로부터 추출하는 단계, 각 알약에 대한 영상데이터를 조합하여 학습용 영상데이터를 생성하는 단계를 포함한다. 상세한 내용은 후술한다.Step S100 is a step of expanding and generating training data by combining image data for a single pill when a verification model for prescriptions does not exist. This step includes extracting image data for each pill included in the prescription from the medicine image DB 110 and generating image data for learning by combining the image data for each pill. Details are described later.

S200 단계는 생성한 학습용 영상데이터로 초기 검수 모델을 학습시키는 단계이다. 학습 이후, 검수 모델을 해당하는 처방(약 종별 개수)에 매칭시켜 함께 내부저장소에 저장한다. 검수 모델을 저장한 이후 동일한 처방이 접수되는 경우, 기존 검수 모델을 재사용하기 위함이다. 이 때 내부저장소에 해당 처방을 받은 환자의 ID나 이름을 함께 저장할 수 있다. 이 경우 동일한 환자에 대해 동일한 처방이 접수되는 경우, 기존 검수 모델을 재사용할 수 있게 된다. 상세한 내용은 후술한다.Step S200 is a step of learning an initial inspection model with the generated image data for learning. After learning, the verification model is matched to the corresponding prescription (number of drugs by type) and stored together in the internal storage. This is to reuse the existing inspection model when the same prescription is received after saving the inspection model. At this time, the ID or name of the patient who received the prescription can be stored in the internal storage. In this case, when the same prescription is received for the same patient, the existing inspection model can be reused. Details are described later.

S300 단계는 처방에 대한 기존 검수 모델이 존재하거나, S200 단계를 통해 검수 모델이 준비된 경우 진행되는 단계로서, 검수 모델을 실행시켜 실제 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식한 후, 오조제 여부를 판단하는 단계이다. 상세한 내용은 후술한다.Step S300 is a step in progress when an existing inspection model for the prescription exists or an inspection model is prepared through step S200. After detecting and recognizing each pill in the image of the actual prepared and packaged medicine by executing the inspection model, This is the step of determining whether or not there is an error. Details are described later.

도 11은 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수를 위한 데이터 확장 방법(S100)을 설명하기 위한 흐름도이다. 11 is a flowchart for explaining a data expansion method (S100) for AI-based pharmaceutical vision inspection according to an embodiment of the present invention.

S110 단계는 변수 i를 1로 초기화하는 단계이다. i는 학습용 영상데이터의 생성 개수를 점검하기 위한 변수이다. 검수 시스템의 사용자는 설정 파일이나 사용자 정책을 통해 처방별 학습용 영상데이터의 생성 개수를 제한 설정할 수 있는데, 학습용 영상데이터를 생성할 때 마다 i를 1만큼 증가시키며, i가 설정된 학습용 영상데이터의 생성 개수(N)에 도달하게 되면 학습용 영상데이터의 생성을 종료한다(S160 단계에 관한 설명 참조). 처방별 학습용 영상데이터의 생성 개수는 앞서 언급한 대로 학습에 사용할 수 있는 시간, 검수 모델의 목표 성능, 처방 등에 따라 달라질 수 있다. Step S110 is a step of initializing the variable i to 1. i is a variable for checking the number of generated image data for learning. The user of the inspection system can limit the number of generated learning image data for each prescription through a setting file or user policy. Every time learning image data is created, i is increased by 1, and When reaching (N), the generation of image data for learning ends (refer to the description of step S160). As mentioned above, the number of generated image data for learning for each prescription may vary depending on the time available for learning, the target performance of the inspection model, and the prescription.

S120 단계는 처방에 포함되는 각 알약에 대한 임의의 면이 촬영된 영상데이터와 배경영상을 의약품 영상 DB(110)로부터 추출하는 단계이다. 의약품 영상 DB(110)는 검수 대상에 해당하는 알약 각각에 대하여 앞/뒤(정제류 약품 두 면의 형상이 다르거나 인쇄(imprint)가 다른 경우, 캡슐류 약품 내 인쇄의 유/무 면 등 경우), 측면(정제류 원형, 정방형 등 약품이 측면으로 서 있을 수 있는 경우 등) 등 알약이 검수 영상 내 존재할 수 있는 형태의 모든 면에 대한 영상을 저장할 수 있다. 학습용 데이터 생성부(130)는 처방에 포함된 알약이 검수 영상 내 존재할 수 있는 형태의 모든 면에 대한 영상 중 임의의 면에 대한 영상데이터를 의약품 영상 DB(110)로부터 추출할 수 있다. 예를 들어, A라는 약품이 정제로서 전면에는 영문이 음각으로 새겨져 있고, 후면에는 직선이 음각으로 새겨진 형태이고, 의약품 영상 DB(110)에 A 약품의 앞면, 뒷면, 측면에 대한 영상데이터가 저장되어 있다고 하자. 이 때, 처방에 포함된 A 약품이 2개일 경우, 학습용 데이터 생성부(130)가 A에 관해 의약품 영상 DB(110)로부터 추출하는 영상은, A의 임의의 면에 대한 영상데이터를 추출한 결과 A의 앞면과 측면 영상이 될 수 있다. Step S120 is a step of extracting image data and a background image of an arbitrary side of each pill included in the prescription from the medicine image DB 110. The drug image DB 110 is used for each of the pills subject to inspection, front/back (when the shape or imprint of the two sides of the tablet drug is different, whether or not there is an imprint in the capsule drug, etc.) ), side (circular, square, etc. of tablets, etc.), images of all aspects of the shape that pills can exist in the inspection image can be saved. The training data generation unit 130 may extract image data for any aspect of images of all aspects of a form in which a pill included in a prescription may exist in an inspection image, from the medicine image DB 110 . For example, drug A is a tablet in which English is engraved on the front and a straight line is engraved on the back, and image data for the front, back, and side of drug A is stored in the drug image DB 110. Let's say it's stored. At this time, when there are two drugs A included in the prescription, the image extracted from the drug image DB 110 for A by the learning data generator 130 is the result of extracting image data for any side of A, A It can be the front and side images of

S130 단계는 각 알약에 대한 영상데이터를 조합하여 학습용 영상데이터를 생성하는 단계이다. 본 발명에서 이용되는 학습용 영상데이터는 배경 영상에 처방에 포함된 각 알약의 임의의 일면의 영상이 조합된 형태이다. 학습용 데이터 생성부(130)는 추출한 영상데이터별로 임의의 각도로 회전하여 배경영상의 임의의 위치에 배치하는 방식으로 영상데이터와 배경영상을 조합하여 학습용 영상데이터를 생성한다. 각 알약의 영상데이터를 회전하여 배경영상에 배치할 때 알약이 배경을 벗어나는 모서리 영역은 제외된다. Step S130 is a step of generating image data for learning by combining image data for each pill. The image data for learning used in the present invention is a combination of a background image and an image of an arbitrary side of each pill included in the prescription. The learning data generation unit 130 generates learning image data by combining the image data and the background image by rotating the extracted image data at an arbitrary angle and arranging them at an arbitrary position of the background image. When the image data of each pill is rotated and placed in the background image, the corner area where the pill is out of the background is excluded.

S140 단계는 학습용 영상데이터에 포함된 각 알약의 이름과 위치를 상기 학습용 영상데이터에 자동으로 레이블링하는 단계이다. 학습용 데이터 생성부(130)는 학습용 영상데이터에 알약의 이름과 알약이 배경영상에 배치된 위치(즉, 알약의 위치)를 자동으로 레이블링할 수도 있고, 알약의 식별 코드를 학습용 영상데이터에 함께 레이블링할 수도 있다. 또한 알약의 식별 코드를 알약의 이름 대신 학습용 영상데이터에 레이블링할 수도 있다. Step S140 is a step of automatically labeling the learning image data with the name and location of each pill included in the learning image data. The learning data generation unit 130 may automatically label the name of the pill and the location where the pill is placed in the background image (ie, the location of the pill) in the image data for learning, or label the identification code of the pill with the image data for learning. You may. In addition, the identification code of the pill may be labeled with the image data for learning instead of the name of the pill.

S150 단계는 상기와 같이 자동으로 레이블링되어 있는 학습용 영상데이터를 학습용 데이터 DB(120)가 저장하는 단계이다. Step S150 is a step in which the learning data DB 120 stores the automatically labeled learning image data as described above.

S160 단계는 i가 N과 일치하는지 판단한다. i가 설정된 학습용 영상데이터의 생성 개수(N)에 도달하였는지를 판단하는 단계이다. 만약 i가 증가한 결과 N에 도달한 경우라면 학습용 데이터의 생성을 종료하고 S210 단계를 진행한다. Step S160 determines whether i coincides with N. This is a step of determining whether i has reached the set number (N) of generating image data for learning. If i reaches N as a result of increasing i, the generation of training data is terminated and step S210 is performed.

S170 단계는 i가 설정된 학습용 영상데이터 생성 개수(N)에 미달한 경우에 i를 1만큼 증가시키는 단계이다. Step S170 is a step of increasing i by 1 when i is less than the set number (N) of generating image data for learning.

도 12는 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수를 위한 학습 방법(S200)을 설명하기 위한 흐름도이다. 12 is a flowchart for explaining a learning method (S200) for AI-based drug vision inspection according to an embodiment of the present invention.

S210 단계는 학습용 영상데이터를 학습용 데이터 DB(120)로부터 추출하는 단계이다. 앞서 설명한대로, 학습용 영상데이터는 처방에 포함되는 각 알약의 일면의 영상데이터가 하나의 배경영상에 조합된 형태이다. 추출하는 학습용 영상데이터의 양은 전술한 학습용 영상데이터 생성 개수(N)일 수 있다. 또한 다른 예시로서, 처방에 따라 생성할 수 있는 학습용 영상데이터의 최대값을 N으로 한 경우, S210 단계에서는 랜덤 샘플링(random sampling)으로 일부 학습용 영상데이터를 추출하는 방식으로 수행될 수 있다.Step S210 is a step of extracting image data for learning from the data DB 120 for learning. As described above, the image data for learning is a form in which image data of one side of each pill included in a prescription is combined with a single background image. The amount of image data for learning to be extracted may be the number (N) of generated image data for learning described above. As another example, when the maximum value of image data for learning that can be generated according to the prescription is N, in step S210, random sampling may be performed to extract some of the image data for learning.

S220 단계는 추출한 학습용 영상데이터로 초기 검수 모델을 학습시켜 검수 모델을 생성하는 단계이다. 추출한 학습용 영상데이터에는 알약의 이름(또는 알약의 식별 코드)과 위치가 레이블링되어 있어서, 이 영상데이터를 이용하여 초기 검수 모델을 학습시켜 검수 모델을 생성한다. 학습 대상이 되는 모델은 신경망일 수 있다.Step S220 is a step of generating an inspection model by learning an initial inspection model with the extracted training image data. The extracted image data for learning is labeled with the name of the pill (or the identification code of the pill) and location, and the initial inspection model is trained using this image data to create an inspection model. A model to be trained may be a neural network.

S230 단계는 검수 모델을 저장하는 단계이다. 학습부(200)는 검수 모델을 해당하는 처방(약종별 개수)에 매칭시켜 처방과 함께 내부저장소에 저장한다. 또한 학습부(200)는 내부저장소에 해당 처방을 받은 환자의 ID나 이름을 함께 저장할 수 있다. 검수 모델을 저장한 이후 동일한 처방이 접수되는 경우, 기존 검수 모델을 재사용하기 위함이다.Step S230 is a step of storing the inspection model. The learning unit 200 matches the verification model to the corresponding prescription (the number of each type of drug) and stores the corresponding prescription in the internal storage together with the prescription. In addition, the learning unit 200 may also store the ID or name of the patient who has received the corresponding prescription in the internal storage. This is to reuse the existing inspection model when the same prescription is received after saving the inspection model.

도 13은 본 발명의 일 실시예에 따른 AI 기반 의약품 비전 검수 방법(S300)을 설명하기 위한 흐름도이다. 13 is a flowchart for explaining an AI-based pharmaceutical vision inspection method (S300) according to an embodiment of the present invention.

S310 단계는 검수 모델을 실행하여 실제 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식하는 단계이다.Step S310 is a step of detecting and recognizing each pill in the image of an actual prepared and packaged medicine by executing the inspection model.

S320 단계는 실제 조제 포장된 의약품 영상 내에서 검출한 알약의 인식 결과를 바탕으로 의약품 품목별 개수를 산출하는 단계이다.Step S320 is a step of calculating the number of medicines by item based on the recognition result of pills detected in the image of medicines actually prepared and packaged.

S330 단계는 산출된 의약품 품목별 개수와 처방을 비교하여 오조제 여부를 판단하는 단계이다. 선택적으로, 오조제 여부를 판단할 수 없는 경우 육안 검수가 필요하다는 내용을 화면이나 소리를 이용하여 출력함으로써 최종적인 직접 육안 검수가 이루어지도록 할 수 있다.Step S330 is a step of comparing the calculated number of medicines for each item with the prescription to determine whether or not there is a mistake. Optionally, when it is impossible to determine whether or not an erroneous preparation has been made, a final direct visual inspection may be performed by outputting information that a visual inspection is necessary using a screen or sound.

참고로, 본 발명의 실시예에 따른 구성 요소들은 소프트웨어 또는 FPGA(Field Programmable Gate Array) 또는 ASIC(Application Specific Integrated Circuit)와 같은 하드웨어 형태로 구현될 수 있으며, 소정의 역할들을 수행할 수 있다. For reference, components according to an embodiment of the present invention may be implemented in software or hardware form such as a Field Programmable Gate Array (FPGA) or Application Specific Integrated Circuit (ASIC), and may perform predetermined roles.

그렇지만 '구성 요소들'은 소프트웨어 또는 하드웨어에 한정되는 의미는 아니며, 각 구성 요소는 어드레싱할 수 있는 저장 매체에 있도록 구성될 수도 있고 하나 또는 그 이상의 프로세서들을 재생시키도록 구성될 수도 있다.However, 'components' are not meant to be limited to software or hardware, and each component may be configured to be in an addressable storage medium or configured to reproduce one or more processors.

따라서, 일 예로서 구성 요소는 소프트웨어 구성 요소들, 객체지향 소프트웨어 구성 요소들, 클래스 구성 요소들 및 태스크 구성 요소들과 같은 구성 요소들과, 프로세스들, 함수들, 속성들, 프로시저들, 서브루틴들, 프로그램 코드의 세그먼트들, 드라이버들, 펌웨어, 마이크로 코드, 회로, 데이터, 데이터베이스, 데이터 구조들, 테이블들, 어레이들 및 변수들을 포함한다.Thus, as an example, a component includes components such as software components, object-oriented software components, class components, and task components, processes, functions, properties, procedures, sub routines, segments of program code, drivers, firmware, microcode, circuits, data, databases, data structures, tables, arrays and variables.

구성 요소들과 해당 구성 요소들 안에서 제공되는 기능은 더 작은 수의 구성 요소들로 결합되거나 추가적인 구성 요소들로 더 분리될 수 있다.Components and the functionality provided within them may be combined into fewer components or further separated into additional components.

이 때, 처리 흐름도 도면들의 각 블록과 흐름도 도면들의 조합들은 컴퓨터 프로그램 인스트럭션들에 의해 수행될 수 있음을 이해할 수 있을 것이다. 이들 컴퓨터 프로그램 인스트럭션들은 범용 컴퓨터, 특수용 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비의 프로세서에 탑재될 수 있으므로, 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비의 프로세서를 통해 수행되는 그 인스트럭션들이 흐름도 블록(들)에서 설명된 기능들을 수행하는 수단을 생성하게 된다. 이들 컴퓨터 프로그램 인스트럭션들은 특정 방식으로 기능을 구현하기 위해 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비를 지향할 수 있는 컴퓨터를 이용하거나 또는 컴퓨터 판독 가능 메모리에 저장되는 것도 가능하므로, 그 컴퓨터를 이용하거나 컴퓨터 판독 가능 메모리에 저장된 인스트럭션들은 흐름도 블록(들)에서 설명된 기능을 수행하는 인스트럭션 수단을 내포하는 제조 품목을 생산하는 것도 가능하다. 컴퓨터 프로그램 인스트럭션들은 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비 상에 탑재되는 것도 가능하므로, 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비 상에서 일련의 동작 단계들이 수행되어 컴퓨터로 실행되는 프로세스를 생성해서 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비를 수행하는 인스트럭션들은 흐름도 블록(들)에서 설명된 기능들을 실행하기 위한 단계들을 제공하는 것도 가능하다.At this time, it will be understood that each block of the process flow chart diagrams and combinations of the flow chart diagrams can be performed by computer program instructions. These computer program instructions may be embodied in a processor of a general purpose computer, special purpose computer, or other programmable data processing equipment, so that the instructions executed by the processor of the computer or other programmable data processing equipment are described in the flowchart block(s). It creates means to perform functions. These computer program instructions may use a computer or may be stored in a computer readable memory, which may be directed to a computer or other programmable data processing equipment to implement function in a particular manner, and thus may be used or computer readable. The instructions stored in the memory are also capable of producing an article of manufacture containing instruction means that perform the functions described in the flowchart block(s). The computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operational steps are performed on the computer or other programmable data processing equipment to create a computer-executed process to generate computer or other programmable data processing equipment. Instructions for performing processing equipment may also provide steps for performing the functions described in the flowchart block(s).

또한, 각 블록은 특정된 논리적 기능(들)을 실행하기 위한 하나 이상의 실행 가능한 인스트럭션들을 포함하는 모듈, 세그먼트 또는 코드의 일부를 나타낼 수 있다. 또, 몇 가지 대체 실행 예들에서는 블록들에서 언급된 기능들이 순서를 벗어나서 발생하는 것도 가능함을 주목해야 한다. 예컨대, 잇달아 도시되어 있는 두 개의 블록들은 사실 실질적으로 동시에 수행되는 것도 가능하고 또는 그 블록들이 때때로 해당하는 기능에 따라 역순으로 수행되는 것도 가능하다.Additionally, each block may represent a module, segment, or portion of code that includes one or more executable instructions for executing specified logical function(s). It should also be noted that in some alternative implementations it is possible for the functions mentioned in the blocks to occur out of order. For example, two blocks shown in succession may in fact be executed substantially concurrently, or the blocks may sometimes be executed in reverse order depending on their function.

이 때, 본 실시예에서 사용되는 '~부'라는 용어는 소프트웨어 또는 FPGA또는 ASIC과 같은 하드웨어 구성요소를 의미하며, '~부'는 어떤 역할들을 수행한다. 그렇지만 '~부'는 소프트웨어 또는 하드웨어에 한정되는 의미는 아니다. '~부'는 어드레싱할 수 있는 저장 매체에 있도록 구성될 수도 있고 하나 또는 그 이상의 프로세서들을 재생시키도록 구성될 수도 있다. 따라서, 일 예로서 '~부'는 소프트웨어 구성요소들, 객체지향 소프트웨어 구성요소들, 클래스 구성요소들 및 태스크 구성요소들과 같은 구성요소들과, 프로세스들, 함수들, 속성들, 프로시저들, 서브루틴들, 프로그램 코드의 세그먼트들, 드라이버들, 펌웨어, 마이크로코드, 회로, 데이터, 데이터베이스, 데이터 구조들, 테이블들, 어레이들, 및 변수들을 포함한다. 구성요소들과 '~부'들 안에서 제공되는 기능은 더 작은 수의 구성요소들 및 '~부'들로 결합되거나 추가적인 구성요소들과 '~부'들로 더 분리될 수 있다. 뿐만 아니라, 구성요소들 및 '~부'들은 디바이스 또는 보안 멀티미디어카드 내의 하나 또는 그 이상의 CPU들을 재생시키도록 구현될 수도 있다.At this time, the term '~unit' used in this embodiment means software or a hardware component such as FPGA or ASIC, and '~unit' performs certain roles. However, '~ part' is not limited to software or hardware. '~bu' may be configured to be in an addressable storage medium and may be configured to reproduce one or more processors. Therefore, as an example, '~unit' refers to components such as software components, object-oriented software components, class components, and task components, processes, functions, properties, and procedures. , subroutines, segments of program code, drivers, firmware, microcode, circuitry, data, databases, data structures, tables, arrays, and variables. Functions provided within components and '~units' may be combined into smaller numbers of components and '~units' or further separated into additional components and '~units'. In addition, components and '~units' may be implemented to play one or more CPUs in a device or a secure multimedia card.

전술한 고형 의약품의 AI 기반 비전 검수를 위한 데이터 확장 방법, 학습 방법 및 AI 기반 의약품 비전 검수 방법은 도면에 제시된 흐름도를 참조로 하여 설명되었다. 간단히 설명하기 위하여 상기 방법은 일련의 블록들로 도시되고 설명되었으나, 본 발명은 상기 블록들의 순서에 한정되지 않고, 몇몇 블록들은 다른 블록들과 본 명세서에서 도시되고 기술된 것과 상이한 순서로 또는 동시에 일어날 수도 있으며, 동일한 또는 유사한 결과를 달성하는 다양한 다른 분기, 흐름 경로, 및 블록의 순서들이 구현될 수 있다. 또한, 본 명세서에서 기술되는 방법의 구현을 위하여 도시된 모든 블록들이 요구되지 않을 수도 있다. The data expansion method, learning method, and AI-based vision inspection method for AI-based vision inspection of solid medicines have been described with reference to the flow chart presented in the drawing. For simplicity, the method is shown and described as a series of blocks, but the invention is not limited to the order of the blocks, and some blocks may occur in a different order or concurrently with other blocks than shown and described herein. and various other branches, flow paths, and sequences of blocks that achieve the same or similar results may be implemented. Also, not all blocks shown may be required for implementation of the methods described herein.

이상, 본 발명의 구성에 대하여 첨부 도면을 참조하여 상세히 설명하였으나, 이는 예시에 불과한 것으로서, 본 발명이 속하는 기술분야에 통상의 지식을 가진자라면 본 발명의 기술적 사상의 범위 내에서 다양한 변형과 변경이 가능함은 물론이다. 따라서 본 발명의 보호 범위는 전술한 실시예에 국한되어서는 아니되며 이하의 특허청구범위의 기재에 의하여 정해져야 할 것이다. In the above, the configuration of the present invention has been described in detail with reference to the accompanying drawings, but this is only an example, and various modifications and changes within the scope of the technical idea of the present invention to those skilled in the art to which the present invention belongs Of course this is possible. Therefore, the scope of protection of the present invention should not be limited to the above-described embodiments, but should be defined by the description of the claims below.

10: 비전 검수 시스템
100: 데이터관리부
110: 의약품 영상 DB
120: 학습용 데이터 DB
130: 학습용 데이터 생성부
200: 학습부
300: 검수부
400: 제어부
10: Vision inspection system
100: data management unit
110: Drug image DB
120: data DB for learning
130: learning data generation unit
200: learning unit
300: inspection department
400: control unit

Claims (18)

알약 각각의 영상데이터 및 의약품 검수 모델 학습용 영상데이터를 저장하고, 상기 알약 각각의 영상데이터를 조합하여 상기 학습용 영상데이터를 생성하는 데이터관리부;
상기 데이터관리부에서 상기 학습용 영상데이터를 추출하고, 초기 검수 모델을 학습시켜 검수 모델을 생성하는 학습부;
상기 검수 모델을 실행시켜 실제 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식한 후, 오조제 여부를 판단하는 검수부; 및
처방이 접수되면 상기 데이터관리부, 상기 학습부 및 상기 검수부의 동작을 제어하는 제어부;
를 포함하는 AI 기반 의약품 비전 검수 시스템.
a data management unit that stores image data of each pill and image data for learning a drug inspection model, and generates the image data for learning by combining the image data of each pill;
a learning unit that extracts the video data for learning from the data management unit and generates an inspection model by learning an initial inspection model;
an inspection unit that executes the inspection model to detect and recognize each pill in the actual prepared and packaged medicine image, and then determines whether or not there is an erroneous preparation; and
a controller for controlling operations of the data management unit, the learning unit, and the inspection unit when a prescription is received;
AI-based pharmaceutical vision inspection system that includes.
제1항에 있어서,
상기 데이터관리부는
검수 대상이 될 수 있는 각 알약의 영상데이터를 저장하는 의약품 영상 DB;
상기 검수 모델 학습용 영상데이터를 저장하는 학습용 데이터 DB; 및
상기 알약 각각의 영상데이터를 조합하여 상기 학습용 영상데이터를 생성하여 상기 학습용 데이터 DB에 전달하는 학습용 데이터 생성부;를 포함하는 것인
AI 기반 의약품 비전 검수 시스템.
According to claim 1,
The data management department
a drug image DB that stores image data of each pill that can be inspected;
a learning data DB for storing image data for learning the verification model; and
And a learning data generator for generating the learning image data by combining the image data of each of the pills and transferring it to the learning data DB.
AI-based pharmaceutical vision inspection system.
제1항에 있어서,
상기 데이터관리부는
검수 대상이 될 수 있는 각 알약이 가질 수 있는 면 중 적어도 한 면의 영상데이터를 저장하는 것인
AI 기반 의약품 비전 검수 시스템.
According to claim 1,
The data management department
To store the image data of at least one side among the sides of each pill that can be inspected
AI-based pharmaceutical vision inspection system.
제1항에 있어서,
상기 데이터관리부는
상기 처방에 포함되는 각 알약에 대한 영상데이터를 추출하고, 추출한 상기 영상데이터별로 임의의 각도로 회전하여 배경영상의 임의의 위치에 배치하는 방식으로 상기 영상데이터와 상기 배경영상을 조합하여 학습용 영상데이터를 생성하는 것인
AI 기반 의약품 비전 검수 시스템.
According to claim 1,
The data management department
Image data for each pill included in the prescription is extracted, rotated at an arbitrary angle for each of the extracted image data, and placed at an arbitrary position in the background image. which will generate
AI-based pharmaceutical vision inspection system.
제1항에 있어서,
상기 데이터관리부는
학습용 영상데이터 생성 시 상기 처방에 포함되는 각 알약의 이름과 위치를 자동 레이블링하는 것인
AI 기반 의약품 비전 검수 시스템.
According to claim 1,
The data management department
Automatically labeling the name and location of each pill included in the prescription when generating image data for learning
AI-based pharmaceutical vision inspection system.
제1항에 있어서,
상기 데이터관리부는
설정파일이나 사용자 정책 중 적어도 하나에 따라 처방별 학습용 영상데이터의 생성 개수를 제한하는 것인
AI 기반 의약품 비전 검수 시스템.
According to claim 1,
The data management department
Limiting the number of generated image data for learning for each prescription according to at least one of a setting file or a user policy
AI-based pharmaceutical vision inspection system.
제1항에 있어서,
상기 학습부는
상기 검수 모델을 해당하는 처방에 매칭시켜 함께 내부저장소에 저장하는 것인
AI 기반 의약품 비전 검수 시스템.
According to claim 1,
The learning department
Matching the inspection model with the corresponding prescription and storing it together in the internal storage
AI-based pharmaceutical vision inspection system.
제1항에 있어서,
상기 제어부는
특정한 처방에 대하여 상기 학습부에 동일한 처방에 대해 이미 검수 모델이 존재하는 경우, 학습용 영상데이터 생성이나 초기 검수 모델의 학습 과정을 거치지 않고, 상기 검수부로 하여금 상기 검수 모델의 실행을 통해 상기 특정한 처방에 따라 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식함으로써 오조제 여부를 판단하도록 하는 것인
AI 기반 의약품 비전 검수 시스템.
According to claim 1,
The control unit
If a review model for the same prescription already exists in the learning unit for a specific prescription, the review unit does not go through the process of generating video data for learning or learning an initial review model, but by executing the review model, It is to determine whether or not to misuse by detecting and recognizing each pill in the image of pharmaceuticals dispensed and packaged according to the
AI-based pharmaceutical vision inspection system.
제1항에 있어서,
상기 검수부는
상기 인식된 알약의 품목별로 개수를 산출하여 상기 처방과 일치하는지 여부를 확인함으로써 오조제 여부를 판단하는 것인
AI 기반 의약품 비전 검수 시스템.
According to claim 1,
The inspection department
Calculating the number of recognized pills for each item and determining whether or not they are mistakenly dispensed by checking whether or not they match the prescription
AI-based pharmaceutical vision inspection system.
제1항에 있어서,
상기 검수부는
상기 의약품 영상 내에서 각각의 알약에 대한 검출 및 인식 중 적어도 하나가 불가능하여 오조제 여부를 판단할 수 없는 경우 육안 검수가 필요하다는 내용을 출력하는 것인
AI 기반 의약품 비전 검수 시스템.
According to claim 1,
The inspection department
If at least one of the detection and recognition of each pill is impossible in the medicine image and it is impossible to determine whether or not it is an erroneous medicine, visual inspection is required.
AI-based pharmaceutical vision inspection system.
처방에 포함되는 각 알약에 대한 영상데이터를 의약품 영상 DB로부터 추출하는 단계;
상기 각 알약에 대한 영상데이터를 조합하여 학습용 영상데이터를 생성하는 단계; 및
상기 생성한 학습용 영상데이터를 학습용 데이터 DB에 저장하는 단계;
를 포함하는 AI 기반 의약품 비전 검수를 위한 데이터 확장 방법.
Extracting image data for each pill included in the prescription from the drug image DB;
generating image data for learning by combining the image data for each of the pills; and
storing the generated image data for learning in a data DB for learning;
A data expansion method for AI-based pharmaceutical vision inspection including.
제11항에 있어서,
상기 각 알약에 대한 영상데이터는
상기 처방에 포함되는 각 알약이 가질 수 있는 면 중 적어도 한 면을 촬영한 영상데이터인 것인
AI 기반 의약품 비전 검수를 위한 데이터 확장 방법.
According to claim 11,
The image data for each pill is
The image data obtained by photographing at least one side among the sides that each pill included in the prescription may have
A data expansion method for AI-based pharmaceutical vision inspection.
제11항에 있어서,
상기 각 알약에 대한 영상데이터의 조합은
상기 각 알약에 대한 영상데이터를 임의의 각도로 회전하여 배경영상의 임의의 위치에 배치하는 방식으로 조합하는 것인
AI 기반 의약품 비전 검수를 위한 데이터 확장 방법.
According to claim 11,
The combination of image data for each pill
Combining the image data for each pill by rotating it at an arbitrary angle and arranging it at an arbitrary position on the background image
A data expansion method for AI-based pharmaceutical vision inspection.
제11항에 있어서,
상기 학습용 영상데이터 생성 단계 이후에
학습용 영상데이터에 포함된 각 알약의 이름과 위치를 상기 학습용 영상데이터에 자동으로 레이블링하는 단계;
를 더 포함하는 AI 기반 의약품 비전 검수를 위한 데이터 확장 방법.
According to claim 11,
After the learning image data generation step
automatically labeling the name and position of each pill included in the image data for learning to the image data for learning;
Data expansion method for AI-based pharmaceutical vision inspection further comprising.
처방에 포함되는 각 알약의 일면의 영상데이터가 하나의 배경영상에 조합된 형태로서, 각 알약의 이름과 위치가 레이블링되어 있는 학습용 영상데이터를 학습용 데이터 DB로부터 추출하는 단계;
상기 추출한 학습용 영상데이터로 초기 검수 모델을 학습시켜 검수 모델을 생성하는 단계; 및
상기 검수 모델을 저장하는 단계;
를 포함하는 AI 기반 의약품 비전 검수를 위한 학습 방법.
Extracting image data for learning, in which the image data of one side of each pill included in the prescription is combined with one background image, and the name and location of each pill are labeled, from the learning data DB;
Creating an inspection model by learning an initial inspection model with the extracted training image data; and
storing the inspection model;
A learning method for AI-based pharmaceutical vision inspection including.
제15항에 있어서,
상기 검수 모델을 저장하는 단계는
상기 검수 모델을 해당하는 처방에 매칭시켜 함께 저장하는 것인
AI 기반 의약품 비전 검수를 위한 학습 방법.
According to claim 15,
The step of storing the inspection model is
Matching the inspection model to the corresponding prescription and storing it together
A learning method for AI-based pharmaceutical vision inspection.
처방에 대한 검수 모델이 존재하는지 판단하는 단계;
상기 처방에 대한 검수 모델이 존재하는 경우, 상기 검수 모델을 실행하여 실제 조제 포장된 의약품 영상 내에서 각각의 알약을 검출하고 인식하는 단계;
상기 인식 결과를 바탕으로 의약품 품목별 개수를 산출하는 단계; 및
상기 산출된 의약품 품목별 개수와 처방을 비교하여 오조제 여부를 판단하는 단계;
를 포함하는 AI 기반 의약품 비전 검수 방법.
Determining whether a review model for the prescription exists;
detecting and recognizing each pill in an image of an actual prepared and packaged medicine by executing the inspection model if there is an inspection model for the prescription;
Calculating the number of medicines for each item based on the recognition result; and
comparing the calculated number of medicines for each item with prescriptions to determine whether or not there is an error;
AI-based pharmaceutical vision inspection method comprising a.
제17항에 있어서,
상기 판단 결과 처방에 대한 검수 모델이 존재하지 않는 경우, 상기 처방에 포함되는 각 알약에 대한 영상데이터를 의약품 영상 DB로부터 추출하는 단계;
상기 각 알약에 대한 영상데이터를 조합하여 학습용 영상데이터를 생성하는 단계; 및
상기 생성한 학습용 영상데이터로 초기 검수 모델을 학습시켜 검수 모델을 생성하는 단계;
를 더 포함하는 AI 기반 의약품 비전 검수 방법.
According to claim 17,
extracting image data for each pill included in the prescription from a drug image DB when the verification model for the prescription does not exist as a result of the determination;
generating image data for learning by combining the image data for each of the pills; and
Creating an inspection model by learning an initial inspection model with the generated image data for learning;
AI-based pharmaceutical vision inspection method further comprising a.
KR1020210109632A 2021-08-19 2021-08-19 Data augmentation and learning method for ai-based vision inspection of solid medications and inspection system thereof KR20230027630A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020210109632A KR20230027630A (en) 2021-08-19 2021-08-19 Data augmentation and learning method for ai-based vision inspection of solid medications and inspection system thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020210109632A KR20230027630A (en) 2021-08-19 2021-08-19 Data augmentation and learning method for ai-based vision inspection of solid medications and inspection system thereof

Publications (1)

Publication Number Publication Date
KR20230027630A true KR20230027630A (en) 2023-02-28

Family

ID=85326892

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020210109632A KR20230027630A (en) 2021-08-19 2021-08-19 Data augmentation and learning method for ai-based vision inspection of solid medications and inspection system thereof

Country Status (1)

Country Link
KR (1) KR20230027630A (en)

Similar Documents

Publication Publication Date Title
US20210082584A1 (en) Drug inspection apparatus and method
JP5916032B2 (en) Drug test support apparatus and method
CA2920349C (en) Remote pharmaceutical verification
Tan et al. Comparison of yolo v3, faster r-cnn, and ssd for real-time pill identification
WO2015046043A1 (en) Drug verification device, drug verification system and drug verification method
CN112069890B (en) Method and device for identifying medicament label and storage medium
US20180204091A1 (en) Method and Apparatus for Medication Identification
CN114388094A (en) Identification and verification of drugs
EP3591655B1 (en) Medication assist device, medication assist system, medication assist method, and program
KR20230027630A (en) Data augmentation and learning method for ai-based vision inspection of solid medications and inspection system thereof
TWI692356B (en) Method of monitoring medication regimen complemented with portable apparatus
JP2022027539A (en) Type determination device and medicament sorting device
Pinto et al. AI-Based Pill Detection and Deblistering Spot Finder System for Smart Medication Dispenser
Rodrigues et al. Hmedasys: home medication intake alert system
KR101646848B1 (en) Drug medicine dispensing system and controlling method for the same
Hsu et al. Real-Time Pill Identification with Prescription Confirmation Using Deep Learning on Embedded System
KR102598969B1 (en) Pill identification system
CN116868231A (en) Methods, systems, and computer program products for verifying pharmaceutical packaging content based on characteristics of a pharmaceutical packaging system
KR20230135101A (en) Method, system and computer program product for removing extraneous content from pharmaceutical packaging and facilitating verification of internal content
JP2009110169A (en) Medicament inspection apparatus and image processing method
Lin et al. ADeep LEARNING-BASED ACCURATE DRUG DETECTION, IDENTIFICATION AND CONFIRMATION MECHANISM FOR MEDICATION DISPENSING PACKAGE OF INPATIENTS