[MYAI Studio SDK] Image-Object-Detection-CSPResNeXt50-PANet-SPP-CPP-Jupyter

This solution can be applied to factory defect detection, medical image analysis, biological image analysis, industrial safety image analysis, mask image analysis, etc.

[Instructions]

1_annotation_pascal_voc_xml.ipynb

Open the marking software. Prepare a png or jpg image for annotation. It is recommended that the image has the same aspect ratio. 

2_prepare_config_file.ipynb

Setting parameters. classes= 4 : The number of detection classes.

Open data/csresnext50-panet-spp-original-optimal.cfg, search for "classes=", under anchors =, there are 3 places where you need to set the number of categories.

Then search for #filters =(classes + 5)x3 #255, modify the filters= below this string, for example : 4 categories, then filters=27, there are 3 places to be set. 

To set the category name, please set the category name in data/label.names. The category name must be exactly the same as the category name when labeling. 

3_convert_yolo_format.ipynb

The labeled converted into yolo voc xml format.

4_prepare_train_txt.ipynb

Prepare a list of training images.

  • image_path = "data/train/images": Training image path.
  • txt = "data/train.txt": The output training image list. 

5_prepare_val_txt.ipynb

To prepare the verification image list.

  • image_path = "data /val/ images": verification image path.
  • txt = "data/val.txt": The output verification image list. 

99_calculate_anchors.ipynb

Please remember to execute this ipynb before training. -width 608 -height 608 is the size of the image to be trained (can be modified).

If the image is not in size, it will be scaled. It is recommended that the aspect ratio of the image is the same. 

After execution, please copy the 

anchors =  62, 99,  79,223, 160,192,  73,469, 424,111, 331,225, 254,369, 151,640, 315,603

Paste this group of numbers on all anchors in data/csresnext50-panet-spp-original-optimal.cfg, there are three places that need to be modified. Next, modify width=608 and height=608 in cfg, which need to be the same as the value set by ipynb. 

6_train_CPU.ipynb

6_train_GPU.ipynb

For training, if the device supports GPU accelerated computing, please select 6_train_GPU, otherwise, please select 6_train_CPU.

model/csresnext50-panet-spp-original-optimal_best.weights :Continue training with this model. If you do not continue, please delete this parameter. 

os.system("start src/darknet/build/darknet/x64/darknet_no_gpu.exe detector train data/voc.data data/csresnext50-panet-spp-original-optimal.cfg model/csresnext50-panet-spp-original-optimal_best.weights -map -clear")

7_inference_CPU.ipynb

7_inference_GPU.ipynb

Inferring a single image. 

  • model/csresnext50-panet-spp-original-optimal_best.weights : Inferred model. 
  • data/test/images/inclusion-2.jpg : Inferred image.
  • -thresh 0.75 : The threshold of inference. 

8_inference_webcam_CPU.ipynb

8_inference_webcam_GPU.ipynb

Use webcam inference. -c 0 is the webcam device id. 

9_inference_folder_1_CPU.ipynb

9_inference_folder_1_GPU.ipynb

Infer all images in the folder. 

  • image_path = "data/test/images" : Inference folder (jpg, png). 
  • model_path = "model/csresnext50-panet-spp-original-optimal_best.weights" : Inferred model. 

10_inference_api_CPU.ipynb

10_inference_api_GPU.ipynb

11_inference_api_browser.ipynb

Inference API, run 10_inference_api_CPU.ipynb to open the server, and then run 11_inference_api_browser.ipynb, jump out of the browser, you can select a picture for inference.  

  • --port 8801 : The opened port. 
  • --model_file model/csresnext50-panet-spp-original-optimal_best.weights : Inferred model. 
  • --threshold 0.7 : Inference threshold, the higher the value, the stricter the similarity. 

99_auto_labeling_GPU.ipynb

Use the trained model to infer, and automatically mark the voc xml format. 

  • image_path = "data/auto_labeling/image" :The image folder to be annotated.
  • model_path = "model/csresnext50-panet-spp-original-optimal_best.weights": The model to be inferred. 
  • output_folder = 'data/auto_labeling/annotation': The path of the output annotation file. 

inference.png

This SDK is built in AppForAI - AI Dev Tools.

Purchase license separately: USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.

Further Reading

1.
MYAI Studio for Windows

2.
MYAI Studio for Linux

3.
AI PC

Thanks for the support from our clients

National Taiwan University, National Tsing Hua University, National Yang Ming Chiao Tung University, National Cheng Kung University, Taipei Medical University, Kaohsiung Medical University, National Taipei University of Nursing and Health Sciences, China Medical University, National Chung Hsing University, National Central University, National Sun Yat-sen University, National Chung Cheng University, National Chi Nan University, National Chiayi University, National Ilan University, National Taipei University of Education, National United University, Tamkang University, Feng Chia University, Chang Gung University, I-Shou University, Shih Chien University, Tatung University, Chung Yuan Christian University, Soochow University, Tzu Chi University, Tzu Chi University of Science and Technology, National Taiwan University of Science and Technology, National Taipei University of Technology, National Taichung University of Science and Technology, National Yunlin University of Science and Technology, National Chin-Yi University of Technology, National Formosa University, National Pingtung University of Science and Technology, National Kaohsiung University of Science and Technology, Chaoyang University of Technology, Ming Chi University of Technology, Minghsin University of Science and Technology, Southern Taiwan University of Science and Technology, Asia Eastern University of Science and Technology, China University of Technology, National Taiwan Sport University, National Defense University, Republic of China Naval Academy, Republic of China Army Academy, Luodong Senior High School, Gushan Senior High School, Kaohsiung Girls Senior High School, National Taiwan University Hospital, National Cheng Kung University Hospital, Taipei Veterans General Hospital, Chang Gung Memorial Hospital, Tzu Chi Hospital, E-Da Hospital, Far Eastern Memorial Hospital, Lien Hsin International Hospital, National Chung-Shan Institute of Science and Technology, Armaments Bureau, Ministry of National Defense, Ministry of Justice Investigation Bureau, Industrial Technology Research Institute, Institute for Information Industry, Institute of Nuclear Energy Research, Atomic Energy Council, Endemic Species Research Institute, Council of Agriculture, Institute of Labor, Occupational Safety and Health, Ministry of Labor, Taiwan Textile Research Institute, Metal Industries Research & Development Centre, Taiwan Instrument Research Institute, Automotive Research & Testing Center, Chunghwa Telecom, Taiwan Water Corporation, Taiwan Semiconductor Manufacturing Company, United Microelectronics Corporation, Nanya Technology Corporation, Winbond Electronics Corporation, Wafer Works Corporation, Grandtop Optoelectronics, AU Optronics, Innolux Corporation, HannStar Display Corporation, Formosa Plastics Corporation, Formosa Petrochemical Corporation, Formosa Technologies Corporation, Nan Ya Plastics Corporation, Formosa Chemicals & Fibre Corporation, CPC Corporation, Taiwan, Logitech, Elan Microelectronics Corporation, Lextar Electronics Corporation, Darfon Electronics Corporation, Sercomm Corporation, EZconn Corporation, Foxconn Technology Group, WPG Holdings, World Peace Industrial Co., Ltd., Mirle Automation Corporation, Shuttle Machinery Co., Ltd., ChipMOS Technologies Inc., Simplo Technology Co., Ltd., Primax Electronics Ltd., Intesys Technology, Feng Hsin Iron & Steel Co., Ltd., China Ecotek Corporation, Zhu Sheng Technology, Advantech Co., Ltd., Stark Technology Inc., Hong Teng Technology, MiTAC International Corp., SYNNEX Technology International Corp., Allion Labs, Inc., Co-in International, Feng An Auto, Hong Hu International, Blue Ocean Intelligence, TOPPAN IDGATE Co., LTd., Far EasTone Telecommunications, SYSTEX Corporation, Cooler Master, Lion Travel, Beigang Wude Temple, Xiluo Fuxing Temple, etc.