コード例 #1
0
 def testLevelsPooler(self):
     with self.test_session() as sess:
         num_level = 3
         features = []
         t_features = []
         for i in range(num_level):
             fea = np.ones([1, 10, 10, 1]) * i
             features.append(fea)
             t_features.append(np.ones([1, 2, 2, 1]) * (2 - i))
         t_features = np.concatenate(t_features, axis=0)
         boxes = [[[0.0, 0.0, 0.59, 0.9], [0.0, 0.0, 0.3, 0.3],
                   [0.0, 0.0, 0.1, 0.1]]]
         img_size = [224, 224]
         cfg = config.get_cfg()
         config.set_global_cfg(cfg)
         cfg = cfg.MODEL.ROI_BOX_HEAD
         cfg.canonical_box_size = 0.3 * 224
         cfg.canonical_level = 1
         p = wmodule.WModule(cfg)
         pooler = ROIPooler(cfg, parent=p, output_size=[2, 2])
         features = pooler.forward(features,
                                   tf.convert_to_tensor(boxes,
                                                        dtype=tf.float32),
                                   img_size=img_size)
         features = sess.run(features)
         self.assertAllClose(t_features, features, atol=1e-3)
コード例 #2
0
def setup(args):
    """
    Create configs and perform basic setups.
    """
    cfg = config.get_cfg()
    print(f"Config file {args.config_file}")
    cfg.merge_from_file(args.config_file)
    cfg.merge_from_list(args.opts)
    cfg.log_dir = args.log_dir
    cfg.ckpt_dir = args.ckpt_dir
    return cfg
コード例 #3
0
ファイル: mot_track.py プロジェクト: vghost2008/wml
def setup(args):
    """
    Create configs and perform basic setups.
    """
    cfg = config.get_cfg()
    if args.gpus is not None:
        gpus = args.gpus
    else:
        gpus = []

    gpus_str = ""
    for g in gpus:
        gpus_str += str(g) + ","
    gpus_str = gpus_str[:-1]
    os.environ['CUDA_VISIBLE_DEVICES'] = gpus_str
    print(f"Config file {args.config_file}")
    config_path = get_config_file(args.config_file)
    cfg.merge_from_file(config_path)
    cfg.merge_from_list(args.opts)
    cfg.log_dir = args.log_dir
    cfg.ckpt_dir = args.ckpt_dir
    return cfg
コード例 #4
0
ファイル: utest.py プロジェクト: vghost2008/wml
from object_detection2.modeling.backbone import *
from object_detection2.modeling.backbone.dla import build_any_dla_backbone
from object_detection2.config.config import get_cfg
import tensorflow as tf
from object_detection2.modeling.backbone.mobilenets import *
import wml_utils as wmlu
import wmodule

global_cfg = get_cfg()
#global_cfg.MODEL.MOBILENETS.MINOR_VERSION = "SMALL"
global_cfg.MODEL.DLA.BACKBONE = "build_hrnet_backbone"
global_cfg.MODEL.RESNETS.DEPTH = 34
#global_cfg.MODEL.MOBILENETS.MINOR_VERSION = "LARGE"
net = tf.placeholder(tf.float32, [2, 512, 512, 3])
x = {'image': net}
parent = wmodule.WRootModule()
mn = build_any_dla_backbone(global_cfg, parent=parent)
res = mn(x)

sess = tf.Session()
summary_writer = tf.summary.FileWriter(wmlu.home_dir("ai/tmp/tools_log"),
                                       sess.graph)