|
| 1 | +English | [简体中文](tools.md) |
| 2 | + |
| 3 | +# Tool scripting |
| 4 | + |
| 5 | +There are some tool scriptings in EISeg in path of `EISeg/tool`. |
| 6 | + |
| 7 | +## How to construct segmentation dataset for PaddleX |
| 8 | + |
| 9 | +After completing image anotation by EISeg,by applying `eiseg2paddlex.py` in `tool` file, yoou can quickly convert data to PaddleX format for training. Execute the following command: |
| 10 | + |
| 11 | +``` |
| 12 | +python eiseg2paddlex.py -d save_folder_path -o image_folder_path [-l label_folder_path] [-m mode -s split_rate] |
| 13 | +``` |
| 14 | + |
| 15 | + |
| 16 | +- `save_folder_path`: path to save PaddleX format data. |
| 17 | +- `image_folder_path`: path of data to be converted. |
| 18 | +- `label_folder_path`: path of the label, optional, default is "image_folder_path/label". |
| 19 | +- `mode`:Type of dataset, optional, default is “seg”, if this dataset is detection dataset, please use “det”. |
| 20 | +- `split_rate`: The devision ratio of training set and validation set, optional, default is 0.9. |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +## Semantic labels to instance labels |
| 25 | + |
| 26 | +The semantic segmentation label is converted to the instance segmentation label (the original label is in range \[0,255\], and the result is a single-channel image that uses a palette to color. Through the `semantic2instance.py`, the semantic segmentation data marked by EISeg can be converted into instance segmentation data. Use the following method: |
| 27 | + |
| 28 | +``` shell |
| 29 | +python semantic2instance.py -o label_path -d save_path |
| 30 | +``` |
| 31 | + |
| 32 | +Parameters: |
| 33 | + |
| 34 | +- `label_path`: path to semantic label, required. |
| 35 | +- `save_path`: path to instance label, required. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +## Video Cut |
| 40 | + |
| 41 | +Due to the huge amount of video data calculation, in order to prevent insufficient video memory, it is recommended to segment the video into 100 frames and label it again. You can find this script in `EISeg/tool/cut_video.py`. |
| 42 | + |
| 43 | +## Convert medical slice into video |
| 44 | + |
| 45 | +3D medical annotation is based on video annotation algorithm. Therefore, before medical image annotation, medical image needs to be converted to `mp4` format and then labeled. You can find this script in `EISeg/tool/medical2video.py`. |
| 46 | + |
| 47 | +## Convert json of labelme to COCO |
| 48 | + |
| 49 | +EISeg will generate a `labelme` folder under the `label` folder after the label is saved, which contains json files and `labels. txt` files with the same format as labelme. At this time, if you want to convert json files into coco files with the same format as labelme, you can execute the following command: |
| 50 | + |
| 51 | +```shell |
| 52 | +python labelme-json2labelme-coco.py label_path save_path --labels txt_path. |
| 53 | + |
| 54 | +# E.g. |
| 55 | +# python labelme-json2labelme-coco.py mydata/label/labelme/ mydata/label/labelme/output --labels mydata/label/labelme/labels.txt |
| 56 | +``` |
| 57 | + |
| 58 | +Parameters: |
| 59 | + |
| 60 | +- `label_path`: path to json format of label, required. |
| 61 | +- `save_path`: path to save coco format data, required. |
| 62 | +- `txt_path`: path to labels.txt, required. |
| 63 | + |
| 64 | +After conversion, it will be displayed in `save_ Path` generates three files, namely `annotations. json`, `JPEGImages` and `Visualization`, in the same format as labelme. |
0 commit comments