def main(hp, model_id, save_base_dir, data_dir, train_epochs, total_epochs, epoch_index): # Xinyi modified
  tf.logging.set_verbosity(tf.logging.ERROR)
  model_dir = save_base_dir + str(model_id)

  for name in list(flags.FLAGS):
    delattr(flags.FLAGS, name)
  define_cifar_flags(hp, model_id, model_dir, data_dir, train_epochs, total_epochs, epoch_index)
  
  absl_app.parse_flags_with_usage(sys.argv)
  return start(0)
def parse_flags(argv=None):
    """Reset flags and reparse. Currently only used in testing."""
    flags.FLAGS.unparse_flags()
    absl_app.parse_flags_with_usage(argv or sys.argv)
Beispiel #3
0
                              "Uses --dataset_path and --feature_spec"
                              "Overrides synthetic dataset dimension flags, other than the number of batches")
    flags.DEFINE_integer('synthetic_dataset_train_batches', default=64008,
                         help='Number of training batches in the synthetic dataset')
    flags.DEFINE_integer('synthetic_dataset_valid_batches', default=1350,
                         help='Number of validation batches in the synthetic dataset')
    flags.DEFINE_list('synthetic_dataset_cardinalities', default=26*[1000],
                         help='Number of categories for each embedding table of the synthetic dataset')
    flags.DEFINE_integer('synthetic_dataset_num_numerical_features', default=13,
                         help='Number of numerical features of the synthetic dataset')

define_command_line_flags()

FLAGS = flags.FLAGS
app.define_help_flags()
app.parse_flags_with_usage(sys.argv)

if FLAGS.xla:
    if FLAGS.cpu:
        os.environ['TF_XLA_FLAGS'] = '--tf_xla_auto_jit=fusible --tf_xla_cpu_global_jit'
    else:
        os.environ['TF_XLA_FLAGS'] = '--tf_xla_auto_jit=fusible'


import time
from lr_scheduler import LearningRateScheduler
import tensorflow as tf
import tensorflow_addons as tfa
import numpy as np
from utils import IterTimer, init_logging, dist_print
from dataloader import create_input_pipelines
Beispiel #4
0
def _flags_parser(argv):
    argv = _benchmark.Initialize(argv)
    return app.parse_flags_with_usage(argv)
Beispiel #5
0
def parse_flags(argv=None):
  """Reset flags and reparse. Currently only used in testing."""
  flags.FLAGS.unparse_flags()
  absl_app.parse_flags_with_usage(argv or sys.argv)
Beispiel #6
0
def flags_parser(args):
    # Plumbs the flags defined in this file to the main module, mostly for the
    # console script wrapper tb-gcp-uploader.
    for flag in set(flags.FLAGS.get_key_flags_for_module(__name__)):
        flags.FLAGS.register_flag_by_module(args[0], flag)
    return app.parse_flags_with_usage(args)
import tensorflow as tf
import numpy as np
from PIL import Image

from absl import flags, app

from yolov3_tf2.models import (YoloV3, YoloV3Tiny)
from yolov3_tf2.utils import draw_outputs, load_darknet_weights
from yolov3_tf2.dataset import transform_images

app.parse_flags_with_usage(['yolo_iou_threshold'])


def get_model(path):
    yolo = YoloV3(classes=80)
    yolo.load_weights(path)
    return yolo


def find_cars(image, yolo):
    #img_arr = np.array(image_orig)
    if type(image) == list:
        images = np.array([np.array(i) for i in image])
        image = transform_images(images, 416)
    else:
        image = tf.expand_dims(np.array(image), axis=0)
        image = transform_images(image, 416)

    boxes, scores, classes, nums = yolo.predict(image, steps=1)

    filtered = []