# Path: detectron/datasets/dataset_catalog.py
# def get_ann_fn(name):
#     """Retrieve the annotation file for the dataset."""
#     return _DATASETS[name][_ANN_FN]
# 
# Path: detectron/utils/timer.py
# class Timer(object):
#     """A simple timer."""
# 
#     def __init__(self):
#         self.reset()
# 
#     def tic(self):
#         # using time.time instead of time.clock because time time.clock
#         # does not normalize for multithreading
#         self.start_time = time.time()
# 
#     def toc(self, average=True):
#         self.diff = time.time() - self.start_time
#         self.total_time += self.diff
#         self.calls += 1
#         self.average_time = self.total_time / self.calls
#         if average:
#             return self.average_time
#         else:
#             return self.diff
# 
#     def reset(self):
#         self.total_time = 0.
#         self.calls = 0
#         self.start_time = 0.
#         self.diff = 0.
#         self.average_time = 0.


import argparse
import json
import os
import sys
from detectron.datasets.dataset_catalog import get_ann_fn
from detectron.utils.timer import Timer
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals




def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--json', dest='json_file',
        help='detections json file',
        default='', type=str)
    parser.add_argument(
        '--output-dir', dest='output_dir',
        help='output directory',
        default='/tmp', type=str)
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    args = parser.parse_args()
    return args


def convert(json_file, output_dir):
    print('Reading: {}'.format(json_file))
    with open(json_file, 'r') as fid:
        dt = json.load(fid)
    print('done!')


# Path: detectron/datasets/dataset_catalog.py
# def get_ann_fn(name):
#     """Retrieve the annotation file for the dataset."""
#     return _DATASETS[name][_ANN_FN]
# 
# Path: detectron/utils/timer.py
# class Timer(object):
#     """A simple timer."""
# 
#     def __init__(self):
#         self.reset()
# 
#     def tic(self):
#         # using time.time instead of time.clock because time time.clock
#         # does not normalize for multithreading
#         self.start_time = time.time()
# 
#     def toc(self, average=True):
#         self.diff = time.time() - self.start_time
#         self.total_time += self.diff
#         self.calls += 1
#         self.average_time = self.total_time / self.calls
#         if average:
#             return self.average_time
#         else:
#             return self.diff
# 
#     def reset(self):
#         self.total_time = 0.
#         self.calls = 0
#         self.start_time = 0.
#         self.diff = 0.
#         self.average_time = 0.


# Path: tools/generate_testdev_from_test.py
import argparse
import json
import os
import sys
from detectron.datasets.dataset_catalog import get_ann_fn
from detectron.utils.timer import Timer

from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals




def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--json', dest='json_file',
        help='detections json file',
        default='', type=str)
    parser.add_argument(
        '--output-dir', dest='output_dir',
        help='output directory',
        default='/tmp', type=str)
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    args = parser.parse_args()
    return args


def convert(json_file, output_dir):
    print('Reading: {}'.format(json_file))
    with open(json_file, 'r') as fid:
        dt = json.load(fid)
    print('done!')


    test_image_info = get_ann_fn('coco_2017_test')