当前位置: 首页>>代码示例>>Python>>正文


Python file_utils.makedirs方法代码示例

本文整理汇总了Python中src.file_utils.makedirs方法的典型用法代码示例。如果您正苦于以下问题:Python file_utils.makedirs方法的具体用法?Python file_utils.makedirs怎么用?Python file_utils.makedirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在src.file_utils的用法示例。


在下文中一共展示了file_utils.makedirs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mkdir_if_missing

# 需要导入模块: from src import file_utils [as 别名]
# 或者: from src.file_utils import makedirs [as 别名]
def mkdir_if_missing(output_dir):
  if not fu.exists(output_dir):
    fu.makedirs(output_dir) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:5,代码来源:utils.py

示例2: _launcher

# 需要导入模块: from src import file_utils [as 别名]
# 或者: from src.file_utils import makedirs [as 别名]
def _launcher(config_name, logdir):
  args = _setup_args(config_name, logdir)

  fu.makedirs(args.logdir)

  if args.control.train:
    _train(args)

  if args.control.test:
    _test(args) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:script_nav_agent_release.py

示例3: plot_trajectory

# 需要导入模块: from src import file_utils [as 别名]
# 或者: from src.file_utils import makedirs [as 别名]
def plot_trajectory(dt, hardness, orig_maps, out_dir):
  out_dir = os.path.join(out_dir, FLAGS.config_name+_get_suffix_str(),
                         FLAGS.imset)
  fu.makedirs(out_dir)
  out_file = os.path.join(out_dir, 'all_locs_at_t.pkl')
  dt['hardness'] = hardness
  utils.save_variables(out_file, dt.values(), dt.keys(), overwrite=True)
  
  #Plot trajectories onto the maps
  plt.set_cmap('gray')
  for i in range(4000):
    goal_loc = dt['all_goal_locs'][i, :, :]
    locs = np.concatenate((dt['all_locs'][i,:,:], 
                           dt['all_locs'][i,:,:]), axis=0)
    xymin = np.minimum(np.min(goal_loc, axis=0), np.min(locs, axis=0))
    xymax = np.maximum(np.max(goal_loc, axis=0), np.max(locs, axis=0))
    xy1 = (xymax+xymin)/2. - 1.*np.maximum(np.max(xymax-xymin), 24)
    xy2 = (xymax+xymin)/2. + 1.*np.maximum(np.max(xymax-xymin), 24)

    fig, ax = utils.tight_imshow_figure(plt, figsize=(6,6))
    ax.set_axis_on()
    ax.patch.set_facecolor((0.333, 0.333, 0.333))
    ax.set_xticks([])
    ax.set_yticks([])

    all_locs = dt['all_locs'][i,:,:]*1
    uniq = np.where(np.any(all_locs[1:,:] != all_locs[:-1,:], axis=1))[0]+1
    uniq = np.sort(uniq).tolist()
    uniq.insert(0,0)
    uniq = np.array(uniq)
    all_locs = all_locs[uniq, :]

    ax.plot(dt['all_locs'][i, 0, 0], 
            dt['all_locs'][i, 0, 1], 'b.', markersize=24)
    ax.plot(dt['all_goal_locs'][i, 0, 0], 
            dt['all_goal_locs'][i, 0, 1], 'g*', markersize=19)
    ax.plot(all_locs[:,0], all_locs[:,1], 'r', alpha=0.4, linewidth=2)
    ax.scatter(all_locs[:,0], all_locs[:,1],
               c=5+np.arange(all_locs.shape[0])*1./all_locs.shape[0], 
               cmap='Reds', s=30, linewidth=0)
    ax.imshow(orig_maps, origin='lower', vmin=-1.0, vmax=2.0, aspect='equal')
    ax.set_xlim([xy1[0], xy2[0]])
    ax.set_ylim([xy1[1], xy2[1]])
    
    file_name = os.path.join(out_dir, 'trajectory_{:04d}.png'.format(i))
    print file_name
    with fu.fopen(file_name, 'w') as f: 
      plt.savefig(f)
    plt.close(fig) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:51,代码来源:script_plot_trajectory.py

示例4: plot_trajectory

# 需要导入模块: from src import file_utils [as 别名]
# 或者: from src.file_utils import makedirs [as 别名]
def plot_trajectory(dt, hardness, orig_maps, out_dir):
  out_dir = os.path.join(out_dir, FLAGS.config_name+_get_suffix_str(),
                         FLAGS.imset)
  fu.makedirs(out_dir)
  out_file = os.path.join(out_dir, 'all_locs_at_t.pkl')
  dt['hardness'] = hardness
  utils.save_variables(out_file, dt.values(), dt.keys(), overwrite=True)

  #Plot trajectories onto the maps
  plt.set_cmap('gray')
  for i in range(4000):
    goal_loc = dt['all_goal_locs'][i, :, :]
    locs = np.concatenate((dt['all_locs'][i,:,:],
                           dt['all_locs'][i,:,:]), axis=0)
    xymin = np.minimum(np.min(goal_loc, axis=0), np.min(locs, axis=0))
    xymax = np.maximum(np.max(goal_loc, axis=0), np.max(locs, axis=0))
    xy1 = (xymax+xymin)/2. - 1.*np.maximum(np.max(xymax-xymin), 24)
    xy2 = (xymax+xymin)/2. + 1.*np.maximum(np.max(xymax-xymin), 24)

    fig, ax = utils.tight_imshow_figure(plt, figsize=(6,6))
    ax.set_axis_on()
    ax.patch.set_facecolor((0.333, 0.333, 0.333))
    ax.set_xticks([])
    ax.set_yticks([])

    all_locs = dt['all_locs'][i,:,:]*1
    uniq = np.where(np.any(all_locs[1:,:] != all_locs[:-1,:], axis=1))[0]+1
    uniq = np.sort(uniq).tolist()
    uniq.insert(0,0)
    uniq = np.array(uniq)
    all_locs = all_locs[uniq, :]

    ax.plot(dt['all_locs'][i, 0, 0],
            dt['all_locs'][i, 0, 1], 'b.', markersize=24)
    ax.plot(dt['all_goal_locs'][i, 0, 0],
            dt['all_goal_locs'][i, 0, 1], 'g*', markersize=19)
    ax.plot(all_locs[:,0], all_locs[:,1], 'r', alpha=0.4, linewidth=2)
    ax.scatter(all_locs[:,0], all_locs[:,1],
               c=5+np.arange(all_locs.shape[0])*1./all_locs.shape[0],
               cmap='Reds', s=30, linewidth=0)
    ax.imshow(orig_maps, origin='lower', vmin=-1.0, vmax=2.0, aspect='equal')
    ax.set_xlim([xy1[0], xy2[0]])
    ax.set_ylim([xy1[1], xy2[1]])

    file_name = os.path.join(out_dir, 'trajectory_{:04d}.png'.format(i))
    print(file_name)
    with fu.fopen(file_name, 'w') as f:
      plt.savefig(f)
    plt.close(fig) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:51,代码来源:script_plot_trajectory.py


注:本文中的src.file_utils.makedirs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。