diff --git a/README.md b/README.md index ab9cefc3de6b59586b3b37c005d5acf16c3513b9..030b187d4b3b5234f3a856d7c222c669d5a1a923 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,8 @@ SiamMOT is a region-based Siamese Multi-Object Tracking network that detects and 1. Change your entrypoint i.e. `run.sh` from `python test.py` to `python siam_mot_test.py`. 2. Copy the Dockerfile present in `siam-mot/Dockerfile` to repository root. -3. Follow common steps shared in [SUBMISSION.md](/docs/SUBMISSION.md) +3. Set `gpu: true` in your `aicrowd.yaml`. +4. Follow common steps shared in [SUBMISSION.md](/docs/SUBMISSION.md) ``` #> cp siam-mot/Dockerfile Dockerfile diff --git a/siam-mot/README.md b/siam-mot/README.md index 05353c6588570525c44165b8beb29ba5c80c42e9..46741a5abd154187c468d6701fee375eda4213b7 100644 --- a/siam-mot/README.md +++ b/siam-mot/README.md @@ -5,5 +5,5 @@ Model checkpoint is taken from [model_zoo.md](https://github.com/amazon-research Additional files: -- `siam_mot_tracker.py`: Interfacing for Airprime Challenge Submission (Contributed by [Dipam Chakraborty](https://github.com/Dipamc77)) -- `Dockerfile`: Docker file for plug and play use (Contributed by [Yoogottam Khandelwal](https://github.com/YoogottamK)) +- `siam_mot_test.py`: Interfacing for AOT Challenge Submission (Contributed by [Dipam Chakraborty](https://github.com/Dipamc77)) +- `Dockerfile`: Docker file for plug and play use of SiamMOT (Contributed by [Yoogottam Khandelwal](https://github.com/YoogottamK)) diff --git a/siam_mot_test.py b/siam_mot_test.py index 346e58161074ca28b33aef71810ff9dbc58ffc5a..fc66a9f8affe17bc94494607446724543b0c4ca9 100644 --- a/siam_mot_test.py +++ b/siam_mot_test.py @@ -5,7 +5,7 @@ import cv2 from PIL import Image from evaluator.airborne_detection import AirbornePredictor -import numpy as np +import torch from tqdm import tqdm import os @@ -14,6 +14,9 @@ from os.path import isfile, join from siam_mot_tracker import SiamMOTTracker +MIN_TRACK_LEN = 30 +MIN_SCORE = 0.985 + class SiamMOTPredictor(AirbornePredictor): """ PARTICIPANT_TODO: You can name your implementation as you like. `RandomPredictor` is just an example. @@ -29,6 +32,7 @@ class SiamMOTPredictor(AirbornePredictor): """ def inference_setup(self): current_path = os.getcwd() + torch.hub.set_dir('./siam-mot/.cache/torch/hub/') config_file = os.path.join(current_path, 'siam-mot/configs/dla/DLA_34_FPN_AOT.yaml') model_path = os.path.join(current_path, 'siam-mot/models/DLA-34-FPN_box_track_aot_d4.pth') self.siammottracker = SiamMOTTracker(config_file, model_path) @@ -41,11 +45,38 @@ class SiamMOTPredictor(AirbornePredictor): frames.append(frame) return frames + def flight_started(self): + self.track_id_results = {} + self.visited_frame = {} + + def proxy_register_object_and_location(self, class_name, track_id, bbox, confidence, img_name): + if track_id not in self.track_id_results: + self.track_id_results[track_id] = [] + if img_name not in self.visited_frame: + self.visited_frame[img_name] = [] + + if track_id in self.visited_frame[img_name]: + raise Exception('two entities within the same frame {} have the same track id'.format(img_name)) + + self.track_id_results[track_id].append([class_name, track_id, bbox, confidence, img_name]) + self.visited_frame[img_name].append(track_id) + + def flight_completed(self): + for track_id in self.track_id_results.keys(): + track_len = len(self.track_id_results[track_id]) + if track_len < MIN_TRACK_LEN: + continue + for entity in self.track_id_results[track_id][MIN_TRACK_LEN:]: + if entity[3] < MIN_SCORE: + continue + self.register_object_and_location(*entity) + """ PARTICIPANT_TODO: During the evaluation all combinations for flight_id and flight_folder_path will be provided one by one. """ def inference(self, flight_id): + self.flight_started() self.siammottracker.tracker.reset_siammot_status() for frame_image in tqdm(self.get_all_frame_images(flight_id)): @@ -56,10 +87,12 @@ class SiamMOTPredictor(AirbornePredictor): class_name = 'airborne' for idx in range(len(results.bbox)): - confidence = results.get_field('scores')[idx] - if confidence < 0.3: # filter low confidence predictions + track_id = results.get_field('ids')[idx] + if track_id < 0: continue + confidence = results.get_field('scores')[idx] + bbox_xywh = results.bbox.cpu().numpy()[idx] # bbox needed is [x0, y0, x1, y1] (top, left, bottom, right) @@ -67,11 +100,10 @@ class SiamMOTPredictor(AirbornePredictor): float(bbox_xywh[0] + bbox_xywh[2]), float(bbox_xywh[1] + bbox_xywh[3])] - track_id = results.get_field('ids')[idx] - - self.register_object_and_location(class_name, int(track_id), + self.proxy_register_object_and_location(class_name, int(track_id), bbox, float(confidence), frame_image) + self.flight_completed() if __name__ == "__main__": submission = SiamMOTPredictor()