Skip to content

Commit

Permalink
Remove converter functionality.
Browse files Browse the repository at this point in the history
Post v0.3.0, converter functionality will not be supported. This was motivated by two reasons:
1. Only TFRecord was supported till now. Tensorflow is a large library and it does not make sense for it to be a project requirement when it's only used for a singular function.
2. There are too many conversion formats. Trying to include even the most popular ones makes the project unwieldy. Better to use one of the readily available scripts online.
  • Loading branch information
ashnair1 committed Apr 19, 2020
1 parent 6d47135 commit 96add96
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 172 deletions.
Binary file removed .github/coco.png
Binary file not shown.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

![CircleCI](https://circleci.com/gh/ashnair1/COCO-Assistant/tree/master.svg?style=shield&circle-token=553c83e37198fe02a71743d42ee427c292336743) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/5299d18c95da4991b4f3a6ae6e8a0b7a)](https://www.codacy.com/manual/ashnair1/COCO-Assistant?utm_source=github.com&utm_medium=referral&utm_content=ashnair1/COCO-Assistant&utm_campaign=Badge_Grade) [![PyPI version](https://badge.fury.io/py/coco-assistant.svg)](https://badge.fury.io/py/coco-assistant) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Helper for dealing with MS-COCO annotations. <img src=".github/coco.png" height="40">
Helper for dealing with MS-COCO annotations.

## Overview
The MS COCO annotation format along with the pycocotools library is quite popular among the computer vision community. Yet I for one found it difficult to play around with the annotations. Deleting a specific category, combining multiple mini datasets to generate a larger dataset, viewing distribution of classes in the annotation file are things I would like to do without writing a separate script for each. The COCO Assistant is designed (or being designed) to assist with this problem. **Please note that currently, the Assistant can only help out with object detection datasets**. Any contributions and/or suggestions are welcome.

### Requirements
Your data directory should look as follows:

```shell script
```markdown
Example:
.
├── images
Expand All @@ -32,7 +32,7 @@ Example:
`pip install coco-assistant`

### 2. Installation: From Source
```shell script
```markdown
# Clone the repository
git clone https://github.com/ashnair1/COCO-Assistant.git
# Build and install the library
Expand All @@ -43,7 +43,7 @@ make

Usage is similar to how you would use `pycocotools`

```shell script
```markdown
from coco_assistant import COCO_Assistant

# Specify image and annotation directories
Expand All @@ -59,7 +59,7 @@ cas = COCO_Assistant(img_dir, ann_dir)

The `merge` function allows you to merge multiple datasets.

```shell script
```markdown
In[1]: cas = COCO_Assistant(img_dir, ann_dir)
loading annotations into memory...
Done (t=0.09s)
Expand All @@ -83,7 +83,7 @@ The merged dataset (images and annotation) can be found in `./results/combinatio

Removes a specific category from an annotation file.

```shell script
```markdown
In[1]: cas = COCO_Assistant(img_dir, ann_dir)
loading annotations into memory...
Done (t=0.09s)
Expand Down Expand Up @@ -125,7 +125,7 @@ The modified annotation can be found in `./results/removal`

Couldn't `pycocotools` visualise annotations (via [showAnns](https://github.com/cocodataset/cocoapi/blob/636becdc73d54283b3aac6d4ec363cffbb6f9b20/PythonAPI/pycocotools/coco.py#L233)) as well? Sure it could, but I required a way to freely view all the annotations of a particular dataset so here we are.

```shell script
```markdown
In[1]: cas.visualise()
Choose directory:
['tiny', 'tiny2']
Expand All @@ -142,6 +142,3 @@ The `cas.get_segmasks()` function allows you to create segmentation masks from y
| **SpaceNet** | <img src="./.github/SpaceNet.png" alt="SpaceNet" title="SpaceNet" width=310 /> | <img src="./.github/SpaceNet_mask.png" alt="SpaceNet_mask" title="SpaceNet_mask" width=310 /> |
| **iSAID** | <img src="./.github/iSAID.png" alt="iSAID" title="iSAID" width=310 /> | <img src="./.github/iSAID_mask.png" alt="iSAID_mask" title="iSAID_mask" width=310 /> |

### Todo
1. Converter for converting COCO annotations to YOLO format.
2. Write tests for untested functions :)
2 changes: 1 addition & 1 deletion coco_assistant/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.1
0.3.0
23 changes: 1 addition & 22 deletions coco_assistant/coco_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

from tqdm import tqdm

from . import coco_converters as converter
from . import coco_stats as stats
from . import coco_visualiser as cocovis
from coco_assistant.utils import anchors
from coco_assistant.utils import det2seg
from coco_assistant.utils import anchors, det2seg

logging.basicConfig(level=logging.ERROR)
logging.getLogger().setLevel(logging.WARNING)
Expand Down Expand Up @@ -292,25 +290,6 @@ def get_segmasks(self):
output_dir = os.path.join(self.res_dir, 'segmasks', name)
det2seg.det2seg(ann, output_dir)

def converter(self, to="TFRecord"):
"""
Function for converting annotations to other formats
:param to: Format to which annotations are to be converted
"""
print("Choose directory:")
print(self.imgfolders)

dir_choice = input()

if dir_choice.lower() not in [item.lower() for item in self.imgfolders]:
raise AssertionError("Choice not in images folder")
ind = self.imgfolders.index(dir_choice.lower())
ann = self.annfiles[ind]
img_dir = os.path.join(self.img_dir, dir_choice)

converter.convert(ann, img_dir, _format=to)

def visualise(self):
"""
Function for visualising annotations.
Expand Down
138 changes: 0 additions & 138 deletions coco_assistant/coco_converters.py

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Pillow>=6.2.2
git+https://github.com/ashnair1/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI
seaborn
scikit-image
tensorflow==1.12.0
tqdm

# packaging
Expand Down

0 comments on commit 96add96

Please sign in to comment.