forked from carla-simulator/carla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request carla-simulator#2 from intel-sandbox/enable_tracking
Enable object tracking scenario and add kwcoco/MOTS annotations
- Loading branch information
Showing
12 changed files
with
905 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) 2022 Intel Corporation. | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
FROM carlasim/carla:0.9.13 | ||
USER root | ||
RUN apt-get update | ||
RUN apt-get install -y build-essential | ||
RUN apt-get install -y libjpeg-dev libtiff-dev | ||
RUN apt-get install -y python3.7 python3.7-dev python3-distutils | ||
RUN apt-get install -y python3-pip | ||
RUN apt-get install -y git | ||
RUN apt-get install -y xdg-user-dirs xdg-utils | ||
RUN apt-get install -y fontconfig | ||
RUN apt-get install -y zip | ||
RUN apt-get clean | ||
USER carla | ||
RUN python3.7 -m pip install Cython | ||
RUN python3.7 -m pip install --upgrade pip | ||
RUN python3.7 -m pip install -r /home/carla/PythonAPI/examples/requirements.txt | ||
COPY requirements.txt /tmp/requirements.txt | ||
RUN python3.7 -m pip install -r /tmp/requirements.txt | ||
ENV PYTHONPATH "${PYTHONPATH}:/home/carla/PythonAPI/carla/dist/carla-0.9.13-py3.7-linux-x86_64.egg" | ||
WORKDIR /home/carla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
DATASETS ?= /datasets/data_collector | ||
PORT := $(shell seq 49152 65535 | shuf | head -n1) | ||
TM_PORT := $(shell echo "$(PORT) + 2" | bc) | ||
CARLA_QUALITY_LEVEL ?= Epic | ||
CONFIG_FILE ?= config_tracking | ||
TRACKING_FORMAT ?= mots_png | ||
TRACKING_LABELS ?= Pedestrian | ||
NV_GPU ?= "device=0" | ||
UUID := $(shell uuidgen) | ||
PYTHON = python3.7 | ||
|
||
DOCKER_TAG ?= carla-client:0.9.13 | ||
DOCKER_OPTIONS += --rm | ||
DOCKER_OPTIONS += --net=host | ||
DOCKER_OPTIONS += --volume $(shell pwd)\:/home/carla/PythonAPI/util/data_collector\:ro | ||
DOCKER_OPTIONS += --volume $(DATASETS)\:$(DATASETS)\:rw | ||
DOCKER_OPTIONS += --gpus $(NV_GPU) | ||
DOCKER_RUN = docker run $(DOCKER_OPTIONS) $(DOCKER_TAG) | ||
DOCKER_RUND = docker run -d $(DOCKER_OPTIONS) --name $(UUID) $(DOCKER_TAG) | ||
|
||
# Taken from https://tech.davis-hansson.com/p/make/ | ||
ifeq ($(origin .RECIPEPREFIX), undefined) | ||
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later) | ||
endif | ||
.RECIPEPREFIX = > | ||
|
||
# Taken from https://suva.sh/posts/well-documented-makefiles/ | ||
.PHONY: help | ||
help: ## Display this help | ||
> @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[1-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-36s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
# | ||
# General Targets | ||
# | ||
.PHONY: docker_image | ||
docker_image: Dockerfile requirements.txt ## Build docker image | ||
> docker build -f $< -t $(DOCKER_TAG) . | ||
|
||
.PHONY: kill_carla_servers | ||
kill_carla_servers: ## Kill all CARLA server docker instances | ||
> docker ps --filter="ancestor=carla-client:0.9.13" -q | xargs docker kill | ||
|
||
|
||
.PHONY: clean_annotations | ||
clean_annotations: ## Clean existing annotations | ||
> @echo "Clearing annotations " | ||
> $(DOCKER_RUN) rm -rf $(DATASETS)/*/*/kwcoco_annotations.json | ||
> $(DOCKER_RUN) rm -rf $(DATASETS)/*/*/instances* | ||
|
||
.PHONY: clean | ||
clean: ## Clean all directories | ||
> @echo "Clearing all directories" | ||
> $(DOCKER_RUN) rm -rf $(DATASETS)/* | ||
|
||
$(DATASETS)/%.yaml: ## Run data collection with specified configuration | ||
> $(DOCKER_RUND) /bin/bash ./CarlaUE4.sh -RenderOffScreen -carla-port=$(PORT) -quality-level=$(CARLA_QUALITY_LEVEL) | ||
> while ! nc -z localhost $(PORT); do sleep 1; done | ||
> $(DOCKER_RUN) $(PYTHON) PythonAPI/util/data_collector/carla_data_saver.py --config-name $(@F) carla.port=$(PORT) carla.traffic_manager_port=$(TM_PORT) hydra.run.dir="$(@D)/$*/$(UUID)" | ||
> docker ps --quiet --filter="name=$(UUID)" -q | xargs docker kill | ||
|
||
.PRECIOUS: $(DATASETS)/$(CONFIG_FILE)/%/collection_done | ||
$(DATASETS)/$(CONFIG_FILE)/%/collection_done: ## Run data collection with config_tracking configuration | ||
> $(DOCKER_RUND) /bin/bash ./CarlaUE4.sh -RenderOffScreen -carla-port=$(PORT) -quality-level=$(CARLA_QUALITY_LEVEL) | ||
> while ! nc -z localhost $(PORT); do sleep 1; done | ||
> $(DOCKER_RUN) $(PYTHON) PythonAPI/util/data_collector/carla_data_saver.py --config-name $(CONFIG_FILE).yaml carla.port=$(PORT) carla.traffic_manager_port=$(TM_PORT) hydra.run.dir="$(@D)" | ||
> docker ps --quiet --filter="name=$(UUID)" -q | xargs docker kill | ||
> $(DOCKER_RUN) /bin/bash -c "echo $(UUID) > $@" | ||
|
||
.PRECIOUS: $(DATASETS)/%/kwcoco_annotations.json ## Generate kwcoco annotations | ||
$(DATASETS)/%/kwcoco_annotations.json: $(DATASETS)/%/collection_done | ||
> $(DOCKER_RUN) $(PYTHON) PythonAPI/util/data_collector/carla_annotator.py --format $(TRACKING_FORMAT) --output $@ --dataset_parent_dir $(@D) --labels $(TRACKING_LABELS) | ||
|
||
.PRECIOUS: $(DATASETS)/%/instances.zip ## Generate annotation in MOTS format | ||
$(DATASETS)/%/instances.zip: $(DATASETS)/%/collection_done | ||
> $(DOCKER_RUN) $(PYTHON) PythonAPI/util/data_collector/carla_annotator.py --format $(TRACKING_FORMAT) --output $(@D)/instances --dataset_parent_dir $(@D) --labels $(TRACKING_LABELS) | ||
> $(DOCKER_RUN) /bin/bash -c "cd $(@D) ; zip -r instances.zip instances" |
Oops, something went wrong.