Deep Learning/Computer Vision 10

augmentation을 통해서 data imbalance 맞춰주기

학습할 때, 가장 중요한 것 중 하나가 data balance를 맞춰 주는 것일 겁니다. 만약 두 개의 클래스가 한 개의 클래스는 100장, 한 개의 클래스는 1000장이 있다고 하면, 두 개의 클래스의 밸런스를 맞춰주기 위해서는 1000장을 100장으로 맞춰주기보다는 100장을 1000장으로 맞춰주는게 나을 것입니다. import os from tensorflow.keras.preprocessing.image import ImageDataGenerator, img_to_array, load_img import numpy as np from PIL import Image, ImageEnhance ​ # Directory containing the images to augment input_dir = 'c..

ChatGPT 로 쓴 data split script (Image classification)

ChatGPT로 다음과 Image classification 관련해서 train, val, test 관련된 python script 를 써달라고 말해 봤습니다. 다음은 말한 ChatGPT Script 입니다. 더보기 write me a script in python that splits images into train/val/test. The source will have several directories with images in it. Target will be empty at first. the Target will output three directories, which will maintain the directory structure as the source directory. We shou..

keras를 이용한 image classification 구현하고 저장하기 (mobilenet, tflite)

안녕하세요 저번 포스트에서 tflite model maker를 통해서 안드로이드에서 tflite model maker를 통해 모델을 만드는 법을 포스팅하였습니다. 2023.06.02 - [모바일/안드로이드] - 안드로이드에서 Image classification 모델 만들기 하지만 tflite_model_maker의 경우 여러가지 제약상황이 많았습니다. 그 중 하나는, tflite_model_maker로 나온 결과는 uint8의 데이터타입으로 나온다는 점입니다. 딱히 이를 고칠 수 있는 방법이 없는 것 같습니다. 하지만 keras api를 사용하면 훨씬 쉽고 커스텀하기 편하게 만들 수 있습니다. 예를들어 이 코드를 봅시다. import numpy as np from tensorflow.keras.appl..

Yolov5를 이용해서 Transfer Learning에서 Early Overfitting을 방지하는 방법

Yolov5를 사용할 때, 보통 Pretrained model을 사용합니다. (small, medium, large, Xlarge.. 이번에 nano도 추가) Pretrained Model의 경우 80개의 Coco dataset을 detect합니다. 이 80개의 모델에 내가 원하는 class가 없는 경우, transfer learning(전이 학습)을 통해서 내가 원하는 class를 학습해야 합니다. Pretrained model이 아닌 scratch model에서 학습을 하는 경우 너무 학습이 오래 걸린다는 단점이 있고, (체감상 pretrained model보다 적어도 두배, 많으면 세네배 이상 시간이 걸립니다. 정확한 레퍼런스는 없네요) freeze layer를 하고 학습을 하는 경우 더 빠르게 할..

Yolov5의 model을 Tx2 engine을 만들어봅시다 (Onnx, netron)

안녕하세요 Yolov5는 pytorch 기반의, 객체 검출을 쉽게 해 줄수 있는 프레임워크입니다. 하지만 yolov5에서 만든 모델을 다른곳에서 사용하려면, 그에 맞게 모델을 변환시켜 주어야 합니다. 그럴때 사용할 수 있는 기술이 Onnx 입니다. onnx소개 : https://github.com/onnx/onnx, https://www.megazone.com/techblog_180816_aws-deep-learning-amis/#:~:text=ONNX%20%EB%9E%80%20%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80%3F,%EC%97%B0%EC%82%B0%EC%9E%90%20%EB%AA%A9%EB%A1%9D%EC%9D%84%20%EC%A0%95%EC%9D%98%ED%95%A9%..

labelImg 맥에다 설치하기

https://github.com/tzutalin/labelImg GitHub - tzutalin/labelImg: 🖍️ LabelImg is a graphical image annotation tool and label object bounding boxes in images 🖍️ LabelImg is a graphical image annotation tool and label object bounding boxes in images - GitHub - tzutalin/labelImg: 🖍️ LabelImg is a graphical image annotation tool and label object bounding b... github.com pipenv 로 설치하는 방법도 있지만, 파이썬 3.6..

mAP란 무엇일까요? (ft. IOU)

yolov5 github : https://github.com/ultralytics/yolov5 참고 url : https://jonathan-hui.medium.com/map-mean-average-precision-for-object-detection-45c121a31173 yolov5 github를 살펴보면, mAP라는 개념이 나옵니다. mAP는 mean Average Precision의 약자이며, Precision은 positive 들에서 true positive rate을 말합니다. 즉, object detection의 경우에는, detection되는 bounding box를 말한다고 보면 됩니다. 그럼 average precision이란 어떤 걸 의미할까요? 이를 위해서는 IOU(Interse..

yolov5를 이용해서 custom data 학습시키기, people training

yolov5는 성능면에서 yolov4보다 훨씬 낫다고 할 수는 없지만, 확실히 pytorch를 이용해서 편합니다. yolov5 pretrained version의 경우에는 80개의 class가 train되어 있습니다. 여기서 우리가 원하는 데이터를 학습 시키기 위해서는 다음 roboflow 블로그를 참고하면 될 거 같습니다. blog.roboflow.com/how-to-train-yolov5-on-a-custom-dataset/ 블로그에서는, rbc, wbc (백혈구, 적혈구)를 위주로 학습을 진행하였습니다. 근데 과연 사람을 학습하려고 하면 어떻게 해야될까요? 또, 80개의 class중 몇 가지의 class만 학습하려고 하면 어떻게 해야될까요? 저는 사람 class만 사용하려고 하였습니다. 물론, de..

Multi object Tracking(MOT) 과 활용

사람들을 tracking 하는데 있어서, inference만 하려고 하면 여러 가지 방법이 있지만, YOLO를 사용하는 방법이 많이 알려져 있습니다. YOLOv4, YOLOv5가 많이 사용되고, 그 중에서 tiny나 small의 경우 작은 디바이스에서도 사용할 수 있을 정도로 가볍고 빠릅니다. 하지만 실제 상황에서 사용할 때, tracking이 필요한 경우가 많습니다. 예를 들어, 선을 그어 놓고, 이 선을 넘어간 사람들의 수를 구할 때, tracking을 사용하지 않는 방법 (opencv)를 사용하는 방법도 있겠지만, 정확도가 떨어질 수도 있습니다. (특히 사람들이 많이 지나갈 경우) 관련 링크 : www.pyimagesearch.com/2018/08/13/opencv-people-counter/ 아직..

Yolov5 를 이용해서 객체검출하기

towardsdatascience.com/how-to-train-a-custom-object-detection-model-with-yolo-v5-917e9ce13208 How to Train A Custom Object Detection Model with YOLO v5 In this post, we will walk through how you can train the new YOLO v5 model to recognize your custom objects for your custom use case. towardsdatascience.com yolo (you only look once) 는 가장 유명한 데이터 검출기구 중 하나입니다. DarkNet 이라는 프레임워크를 사용하였으며, 버전이 지날수록 ..