<commit_before>#-*- coding: utf-8 -*-

"""
Usage Example:
    python explore_dims --conf conf/cars.json
"""

import argparse
import numpy as np
import object_detector.file_io as file_io

ap = argparse.ArgumentParser()
ap.add_argument("-c", "--conf", required=True, help="path to the configuration file")
args = vars(ap.parse_args())

conf_ = file_io.FileJson().read(args['conf'])

widths = []
heights = []

files = file_io.list_files(conf_["image_annotations"], "*.mat")
for file_ in files:  
    (y, h, x, w) = file_io.FileMat().read(file_)["box_coord"][0]
    widths.append(w - x)
    heights.append(h - y)
  
# compute the average of both the width and height lists
(avgWidth, avgHeight) = (np.mean(widths), np.mean(heights))
print("[INFO] avg. width: {:.2f}".format(avgWidth))
print("[INFO] avg. height: {:.2f}".format(avgHeight))
print("[INFO] aspect ratio: {:.2f}".format(avgWidth / avgHeight))

<commit_msg>"explore_dims.py" argparser deleted<commit_after>#-*- coding: utf-8 -*-

""" Get information on training dataset."""

import numpy as np
import object_detector.file_io as file_io

CONFIGURATION_FILE = "conf/cars.json"

if __name__ == "__main__":
    conf_ = file_io.FileJson().read(CONFIGURATION_FILE)
    
    widths = []
    heights = []
    
    files = file_io.list_files(conf_["image_annotations"], "*.mat")
    for file_ in files:  
        (y, h, x, w) = file_io.FileMat().read(file_)["box_coord"][0]
        widths.append(w - x)
        heights.append(h - y)
      
    # compute the average of both the width and height lists
    (avgWidth, avgHeight) = (np.mean(widths), np.mean(heights))
    print("[INFO] avg. width: {:.2f}".format(avgWidth))
    print("[INFO] avg. height: {:.2f}".format(avgHeight))
    print("[INFO] aspect ratio: {:.2f}".format(avgWidth / avgHeight))
    

{'fraction_non_alphanumeric': 0.17314095449500555, 'fraction_numerical': 0.005549389567147614, 'mean_word_length': 3.872972972972973, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4961408', 'n_tokens_mistral': 650, 'n_tokens_neox': 653, 'n_words': 148}