Skip to content

Commit

Permalink
Expose learner and dataset classes (issue #132)
Browse files Browse the repository at this point in the history
  • Loading branch information
vniclas committed Oct 5, 2021
1 parent 1433d40 commit 1c693b1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
14 changes: 6 additions & 8 deletions src/opendr/perception/panoptic_segmentation/README.md
Expand Up @@ -39,7 +39,7 @@ Please note that the original repository is heavily based on

**Prepare the downloaded Cityscapes dataset** (see the [datasets' readme](./datasets/README.md) as well)
```python
from opendr.perception.panoptic_segmentation.datasets import CityscapesDataset
from opendr.perception.panoptic_segmentation import CityscapesDataset
DOWNLOAD_PATH = '~/data/cityscapes_raw'
DATA_ROOT = '~/data/cityscapes'
CityscapesDataset.prepare_data(DOWNLOAD_PATH, DATA_ROOT)
Expand All @@ -49,7 +49,7 @@ CityscapesDataset.prepare_data(DOWNLOAD_PATH, DATA_ROOT)
```python
import mmcv
from opendr.engine.data import Image
from opendr.perception.panoptic_segmentation.efficient_ps import EfficientPsLearner
from opendr.perception.panoptic_segmentation import EfficientPsLearner
DATA_ROOT = '~/data/cityscapes'
image_filenames = [
f'{DATA_ROOT}/val/images/lindau_000001_000019.png',
Expand All @@ -58,27 +58,25 @@ image_filenames = [
]
images = [Image(mmcv.imread(f)) for f in image_filenames]
learner = EfficientPsLearner()
learner.load('model.pth')
learner.load('model.pth') # alternatively, one can just specify the path to the folder
predictions = learner.infer(images)
for image, prediction in zip(images, predictions):
EfficientPsLearner.visualize(image, prediction)
```

**Run evaluation**
```python
from opendr.perception.panoptic_segmentation.datasets import CityscapesDataset
from opendr.perception.panoptic_segmentation.efficient_ps import EfficientPsLearner
from opendr.perception.panoptic_segmentation import EfficientPsLearner, CityscapesDataset
DATA_ROOT = '~/data/cityscapes'
val_dataset = CityscapesDataset(path=f'{DATA_ROOT}/val')
learner = EfficientPsLearner()
learner.load('model.pth')
learner.load('model.pth') # alternatively, one can just specify the path to the folder
learner.eval(val_dataset, print_results=True)
```

**Run training**
```python
from opendr.perception.panoptic_segmentation.datasets import CityscapesDataset
from opendr.perception.panoptic_segmentation.efficient_ps import EfficientPsLearner
from opendr.perception.panoptic_segmentation import EfficientPsLearner, CityscapesDataset
DATA_ROOT = '~/data/cityscapes'
train_dataset = CityscapesDataset(path=f'{DATA_ROOT}/training')
val_dataset = CityscapesDataset(path=f'{DATA_ROOT}/val')
Expand Down
4 changes: 4 additions & 0 deletions src/opendr/perception/panoptic_segmentation/__init__.py
@@ -0,0 +1,4 @@
from opendr.perception.panoptic_segmentation.datasets import CityscapesDataset, KittiDataset
from opendr.perception.panoptic_segmentation.efficient_ps import EfficientPsLearner

__all__ = ['CityscapesDataset', 'KittiDataset', 'EfficientPsLearner']
Expand Up @@ -6,7 +6,7 @@
2. Extract both files.
3. Convert the files to the expected folder structure and generate panoptic ground truth data for evaluation
```python
from opendr.perception.panoptic_segmentation.datasets import CityscapesDataset
from opendr.perception.panoptic_segmentation import CityscapesDataset
DOWNLOAD_PATH = '~/data/cityscapes_raw'
DATA_ROOT = '~/data/cityscapes'
CityscapesDataset.prepare_data(DOWNLOAD_PATH, DATA_ROOT)
Expand All @@ -18,7 +18,7 @@ CityscapesDataset.prepare_data(DOWNLOAD_PATH, DATA_ROOT)
2. Extract the file.
3. Convert the files to the expected folder structure and generate panoptic ground truth data for evaluation
```python
from opendr.perception.panoptic_segmentation.datasets import KittiDataset
from opendr.perception.panoptic_segmentation import KittiDataset
DOWNLOAD_PATH = '~/data/KITTI-panoptic-segmentation-dataset'
DATA_ROOT = '~/data/kitti'
KittiDataset.prepare_data(DOWNLOAD_PATH, DATA_ROOT)
Expand Down
Expand Up @@ -16,8 +16,7 @@
import cv2

from opendr.engine.data import Image
from opendr.perception.panoptic_segmentation.datasets import CityscapesDataset, KittiDataset
from opendr.perception.panoptic_segmentation.efficient_ps import EfficientPsLearner
from opendr.perception.panoptic_segmentation import EfficientPsLearner, CityscapesDataset, KittiDataset

DATA_ROOT = '/home/USER/data/efficientPS'
CITYSCAPES_ROOT = f'{DATA_ROOT}/converted_datasets/cityscapes'
Expand Down
Expand Up @@ -21,8 +21,7 @@

from opendr.engine.data import Image
from opendr.engine.target import Heatmap
from opendr.perception.panoptic_segmentation.datasets import CityscapesDataset
from opendr.perception.panoptic_segmentation.efficient_ps import EfficientPsLearner
from opendr.perception.panoptic_segmentation import EfficientPsLearner, CityscapesDataset


def rmfile(path):
Expand Down

0 comments on commit 1c693b1

Please sign in to comment.