Git Product home page Git Product logo

dota_devkit_yolo's Introduction

Brief Introduction

Based on DOTA_devkit.
Add some modules to trans DOTA annotation format to YOLO annotation format.
Add some files for every demo.

Fuction

  • DOTA.py Load image, and show the bounding oriented box.

  • ImgSplit.py Split image and the label.

  • ResultMerge.py Merge the detection result annotation txt.

  • dota_×_evaluation_task×.py Evaluate the detection result annotation txt.

  • YOLO_Transformer.py Trans DOTA format to YOLO(OBB or HBB) format.

  • Draw_DOTA_YOLO.py Picture the YOLO_OBB labels(after augmented).

Installation

Same as DOTA_devkit. Then:

$  pip install -r requirements.txt

More detailed explanation

想要了解这几个函数实现的细节和原理可以看我的知乎文章;
DOTA遥感数据集以及相关工具DOTA_devkit的整理(踩坑记录);
DOTA数据格式转YOLO数据格式工具(cv2.minAreaRect踩坑记录);

Usage Example

  • DOTA.py
$  python DOTA.py

DOTA_HBB_label DOTA_OBB_label

  • ImgSplit.py
$  python ImgSplit_multi_process.py

Img_before_split Img_after_split

  • ResultMerge.py
$  python ResultMerge.py

visualize_detection_result1 visualize_detection_result2 visualize_merged_result

  • dota_v1.5_evaluation_task1.py

change the path with yours.

detpath = r'/.../evaluation_example/result_classname/Task1_{:s}.txt'
annopath = r'/.../evaluation_example/row_DOTA_labels/{:s}.txt'
imagesetfile = r'/.../evaluation_example/imgnamefile.txt'
$  python dota_v1.5_evaluation_task1.py
  • YOLO_Transform.py
$  python YOLO_Transform.py
DOTA format:    poly classname diffcult
    To
YOLO HBB format: classid x_c y_c width height   ——   def dota2Darknet()
longside format: classid x_c y_c longside shortside Θ  Θ∈[0, 180)  ——  def dota2LongSideFormat()
  • Draw_DOTA_YOLO.py

1.Run YOLO_Transformer.py to get the YOLO_OBB_labels first.

2.then augment YOLO_OBB_labels and visualize it:

$  Draw_DOTA_YOLO.py

visualize_augmented_labels

有问题反馈

在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流

  • 知乎(@略略略
  • 代码问题提issues,其他问题请知乎上联系

感激

感谢以下的项目,排名不分先后

关于作者

  Name  : "胡凯旋"
  describe myself:"咸鱼一枚"
  

dota_devkit_yolo's People

Contributors

hukaixuan19970627 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dota_devkit_yolo's Issues

Loss 降不下去

image
batch_size = 4 lr = 0.01 150个epoch Loss 从1 降低到0.5 训练速度很慢,所以就将batch_size 调大了
batch_size = 64 lr =0.16 300个epoch Loss从1降低到0.4

opencv表示法的范围

请问detect:θ计算出现异常,当前数据为:68.0000000000000000, 228.0000000000000000, 0.0001779465237632, 0.0000000000000000, 31.0;超出opencv表示法的范围:[-90,0)

Error running the training file;Multi-distributed training

I have two video cards. I changed the parameters of the corresponding video card during training, but the code of the training file runs incorrectly.
subprocess.CalledProcessError: Command '['/root/miniconda3/envs/yolov5/bin/python', '-u', 'train.py', '--local_rank=1', '--sync-bn']' returned non-zero exit status 1.

resultMerge合并HBB

我发现resultMerge只能合并旋转目标框的检测结果,如果是水平目标框有合并的脚本吗

A problem about data prepare

image
image
image

I applied YOLO_Transform.py to convert data format and draw objects. However, the oriented bounding boxes probably have some deviations, when the objects have large size or angle.

关于融合后生成标签文件的问题

有个问题想请教下各位大神。
我拿一张图片裁剪成4张,然后四张裁剪后的图片和标签去融合后得到4个融合后的txt文件,那我是要把这4个txt文件的内容放到一个txt文件里,算是融合后的标签吗?
还有就是我要怎么得到融合后的图片呢?我看代码里只有生成融合后的标签

Parallelogram occurs from some inclined rectangle.

QQ截图20210520171436
QQ截图20210520172256

Thanks for your precious work! 不愧是成电大佬。
I got the problem as the picture shows, some inclined rectangle have been translated into parallelograms while I am sure about my opencv, pillow and numpy version.
I tried it both on Windows 10 and CentOS 7.5 but both didn't work perfectly.

Could you please help QAQ?

根据labels绘制边框的问题

博主您好。请问我按您给的代码制作yolo数据集然后绘制边框,得到的边框是平行四边形的,我想可能是在反归一化的时候比例出现问题,但是从您绘制的图像来看并没有出现这个问题。
poly[:, 0] = poly[:, 0] * img_w
poly[:, 1] = poly[:, 1] * img_h

运行ResultMerge.py 报错ModuleNotFoundError: No module named '_polyiou'

ubuntu系统, swig我已经装了,步骤如下。 还是报错,不知道啥原因
sudo apt-get install swig
swig -c++ -python polyiou.i
python setup.py build_ext --inplace

完整报错:
Traceback (most recent call last):
File "/home/user/Desktop/ultralytics-v8/dataset/DOTA_devkit_YOLO-master/polyiou.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_polyiou', [dirname(file)])
File "/home/user/anaconda3/lib/python3.9/imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_polyiou'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/user/Desktop/ultralytics-v8/dataset/DOTA_devkit_YOLO-master/ResultMerge.py", line 13, in
import polyiou
File "/home/user/Desktop/ultralytics-v8/dataset/DOTA_devkit_YOLO-master/polyiou.py", line 28, in
_polyiou = swig_import_helper()
File "/home/user/Desktop/ultralytics-v8/dataset/DOTA_devkit_YOLO-master/polyiou.py", line 20, in swig_import_helper
import _polyiou
ModuleNotFoundError: No module named '_polyiou'

YOLO_Transform转换过程中解决出现图片占用问题(windows系统下)

最近在使用作者的YOLO_Transform.py转换DOTA数据格式时,如果是转换split后的图片的数据格式,因为split后有时会出现一个图片中gt为0的情况,这时需要删除该gt数目为0的图片和对应的label文件,此时出现了图片占用问题,需要修改一下代码。在dota2LongSideFormat这个方法中,将 img = Image.open(img_fullname)修改为
fp = open(img_fullname, 'rb') img = Image.open(fp) fp.close()
修改后运行正常,Linux下没试过,应该不会出现这种情况。

变量命名问题

在ImgSplit.py中weight改用width,是不是可以增强代码可读性

ImgSplit.py和ImgSplit_multi_process.py的区别

首先很感谢大佬写的这个项目!已经给项目星星了^ ^
然后就是我看到项目里有ImgSplit.py和ImgSplit_multi_process.py
还有ResultMerge.py和ResultMerge_multi_process.py
SplitOnlyImage.py和SplitOnlyImage_multi_process.py
这些有啥区别呢 要使用的话 应该使用哪一个
还有dota-v1.5_evaluation_task1.py和dota-v1.5_evaluation_task2.py
dota_evaluation_task1.py和dota_evaluation_task2.py
分了1和2的意思是。。

ResultMerge

raceback (most recent call last):
File "/home/lfz/DOTA_devkit_YOLO/ResultMerge.py", line 197, in
mergebypoly(r'/home/lfz/yolov5_obb/runs/detect/exp13/labels', r'/home/lfz/yolov5_obb/runs/detect/exp13/labels2')
File "/home/lfz/DOTA_devkit_YOLO/ResultMerge.py", line 192, in mergebypoly
mergebase(srcpath,
File "/home/lfz/DOTA_devkit_YOLO/ResultMerge.py", line 146, in mergebase
x_y_2 = re.findall(r'\d+', x_y[0]) # 匹配subname中的字符串 eg: x_y_2= ['0','0']
IndexError: list index out of range

用ResultMerge_multi_process.py也会报同样的错

图像数据归一化的问题

image
这里的
x[:, 1] - x[:, 3] / 2
x[:, 2] - x[:, 4] / 2
x[:, 1] + x[:, 3] / 2
x[:, 2] + x[:, 4] / 2
是你对长边表示法转poly的过程,但是我觉得这个转换的过程是有问题的,如下图:
731b72ab9bbb02fe5dd429d00553053
可以看到长边表示法并不能确定长边对应的是x坐标还是y坐标,这就会导致转的poly其实是有问题的,我这个理解不知道对不对?

将图像转成height=width的问题

您在文章里面提到过这个:
image
我的数据集图像大小是 1280x720 设置 subsize = 1280以后运行代码并没有pad,请问您这个pad功能是哪部分代码实现的呢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.