Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inf800/labelme_to_detectron2
https://github.com/inf800/labelme_to_detectron2
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/inf800/labelme_to_detectron2
- Owner: INF800
- License: apache-2.0
- Created: 2021-11-03T04:23:11.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-03T08:50:32.000Z (about 3 years ago)
- Last Synced: 2024-08-10T10:57:13.503Z (4 months ago)
- Language: Python
- Size: 7.81 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# labeleme_to_detectron2
Convert labelme annotations to detectron2 annotation format.
**USAGE:**
```
python -m labelme_to_detectron2.convert_annotations {labelme_annotations_dir}
```Copy the unique labels that will be displayed.
Files will be created in `*.d2json` format (same as json)
Divide into train and test datasets and then register dataset using the code below:
```python
from pathlib import Pathunique_labels=['person', 'vehicle']
def get_dataset_dicts(img_dir):
dataset_dicts = []
img_dir = Path(img_dir)
for i, jsonpath in enumerate([*img_dir.glob("*.d2json")]):
with open(str(jsonpath), 'r') as fp:
annot = json.load(fp)
annot['image_id'] = i
annot['file_name'] = str(img_dir/Path(annot['file_name']).name)
dataset_dicts.append(annot)
return dataset_dictsfor d in ["train", "test"]:
DatasetCatalog.register("dataset_" + d, lambda d=d: get_dataset_dicts(f"{base}/{d}"))
MetadataCatalog.get("dataset_" + d).set(thing_classes=unique_labels)
```### Insatallation
Install locally with sym-link for fast code updates
```
pip install -e .
```Generate distributable file
```
python3 setup.py sdist
```
Can install using: `pip install https://github.com/INF800/labelme_to_detectron2/raw/main/dist/labelme_to_detectron2-x.x.x.tar.gz`Share distributable using pypi
```
twine upload dist/*
```