caffe 使用shell自动生成train.txt & val.txt

使用自己的数据集“煮caffe”时候需要生成train.txt 和 val.txt。但是,没有找到一个有效的方法。今天跟大家分享一下使用shell自动生成train.txt 和 val.txt 脚本没有容错性谨慎使用勿喷 无原理,看步骤。1 数据集格式要求文件布局 这样布局也是caffe的要求,shell 下边会贴出来或者→shell脚本下载地址 train中 对应train文件夹
摘要由CSDN通过智能技术生成

使用自己的数据集“煮caffe”时候需要生成train.txt 和 val.txt。但是,没有找到一个有效的方法。今天跟大家分享一下使用shell自动生成train.txt 和 val.txt


脚本没有容错性 谨慎使用 勿喷
无原理,看步骤。


1 数据集格式要求

文件布局
这样布局也是caffe的要求,shell 下边会贴出来或者→shell脚本下载地址
这里写图片描述

train中
这里写图片描述

train文件夹下的图片
这里写图片描述

val中结构
说明: val需要有train一致的结构外,还需要把各个文件中的图片,复制到val文件下。
这里写图片描述

2 Shell 代码

filepath2txt.sh

#!/usr/bin/env sh
# 说明 
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
在C#中使用MyCaffe调用train.caffemodel和prototxt文件的步骤与使用mean.binaryproto文件类似。您可以使用MyCaffe提供的BlobProto和NetParameter类来加载这些文件,并将它们转换为C#中的对象。 以下是一个示例代码片段,展示了如何在C#中使用MyCaffe加载train.caffemodel和prototxt文件: ```csharp using MyCaffe; using MyCaffe.basecode; using MyCaffe.common; using MyCaffe.param; using MyCaffe.proto; using System.Collections.Generic; namespace MyCaffeTest { class Program { static void Main(string[] args) { // Load the prototxt file NetParameter net_param = new NetParameter(); net_param.CopyFrom(LayerParameter.ParseFrom(File.ReadAllBytes("train.prototxt"))); // Load the caffemodel file BlobProto blob_proto = new BlobProto(); blob_proto.Load("train.caffemodel"); // Convert the BlobProto object to a Blob object BlobCollection<float> colBlobs = new BlobCollection<float>(); Blob<float> blob = new Blob<float>(new List<int> { 1, 3, 256, 256 }); blob.FromProto(blob_proto); colBlobs.Add(blob); // Create the solver SolverParameter solver_param = new SolverParameter(); solver_param.net_param = net_param; solver_param.test_iter.Add(0); solver_param.test_interval = 1; solver_param.base_lr = 0.01; solver_param.momentum = 0.9; solver_param.weight_decay = 5e-4; solver_param.lr_policy = "inv"; solver_param.gamma = 0.1; solver_param.power = 0.75; solver_param.display = 1; solver_param.max_iter = 1; solver_param.snapshot = 1; solver_param.snapshot_prefix = "snapshot"; solver_param.type = SolverParameter.SolverType.SGD; // Create the solver and solve the net MyCaffeControl<float> mycaffe = new MyCaffeControl<float>(null, null, null, colBlobs, null, solver_param, null, null, null, null); mycaffe.Solve(); System.Console.ReadKey(); } } } ``` 在上面的代码中,我们使用了MyCaffe提供的NetParameter和BlobProto类,分别加载了train.prototxttrain.caffemodel文件。我们还创建了一个SolverParameter对象,并使用NetParameter对象初始化它。最后,我们使用这些对象创建了一个MyCaffeControl对象,并使用Solve函数来训练网络。 希望这可以帮助您解决问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值