0

This is the script that I need to convert to batch file in windows :

#!/usr/bin/env sh

TOOLS=./build/tools

$TOOLS/caffe train \
    --solver=examples/cifar10/cifar10_full_relu_solver_bn.prototxt

this is the script I came up with so far:

REM go to the caffe root
cd ../../Build/x64/Release
caffe.exe train --solver=../../../examples/cifar10/cifar10_full_relu_solver_bn.prototxt

pause

This executes the executable (caffe.exe) and passes the needed argument file as needed, but the problem is the argument file itself is pointing to another file which is relative to itself, and this second file is not found.
This is how the second file inside our argument file addressed :

net: "examples/cifar10/cifar10_full_relu_train_test_bn.prototxt"

To make things more clear, the hierarchy of the folders is like this :

|Build 
   |--X64
      |--Release
         |--caffe.exe
|Examples
   |--Cifar10
      |-- cifar10_full_relu_solver_bn.prototxt
      |-- Cifar10_train_test.prototxt
      |-- other files as well

my question is, Is there a way that I can use so that I dont need to change all relative file addresses as well ?

  • Put caffe.exe in your path. In the batch file cd examples. – DavidPostill Mar 31 '16 at 8:39
  • its not applicable at the moment, both folders contain lots of stuff. – Breeze Mar 31 '16 at 10:28
  • Thanks but Its not applicable at the moment, I try some other methods and see if I can get it in the way I intend – Breeze Mar 31 '16 at 13:21
  • Why did you delete your answer containing your solution? – DavidPostill Mar 31 '16 at 16:31
  • @DavidPostill, I noticed NOLFXceptMe has already posted the answer, although not completely correct, I thought its a good Idea to accept his answer and then apply the needed correction to it and make perfect. – Breeze Mar 31 '16 at 19:50
1
SET TOOLS=Build/x64/Release
%TOOLS%/caffe.exe train --solver=examples/cifar10/cifar10_full_relu_solver_bn.prototxt

pause

That should be the ideal conversion of the shell script. We always stay at the root folder, so paths inside the file provided as an argument should be referenced correctly.

  • yes thanks, but you are missing a cd ../../ command the very beginning or otherwise this wont work. – Breeze Mar 31 '16 at 15:32
  • Your shell script should be at the top folder. Placing it inside Build/x64/Release is a bad practice. – NOLFXceptMe Apr 1 '16 at 12:39
  • why is it bad practice ? – Breeze Apr 1 '16 at 15:46
  • by the way I'd be grateful if you could add this notice that, this script should be executed from the root or otherwise it wont work(if called from the sub directory where the actual bat file resides). – Breeze Apr 1 '16 at 16:08
  • by the way there is slight problem here, When I run this script from the root sth like this ( T:\Git\CaffeRoot> data\mnist\get_mnist_data.bat` the files are not save inside the mnist folder, they are saved in the root folder which is wrong! How to solve this problem ? – Breeze Apr 1 '16 at 16:18
0

The possible solution is duplicating the entire Cifar10 folder to the proper location.

  • not a practical solution at all. but thanks anyway – Breeze Mar 31 '16 at 13:21
  • I don't know the logic of this program. I thought if it doesn't matter where the second (text) file is located then one can copy this file to the location where the program expects it to be just to make it accessible. If it does matter then this isn't the case. – Oleg Bolden Mar 31 '16 at 14:09
  • actually, the folders contain lots of stuff and moving them around is not logical at all, thats why I asked this in first place, in linux I have no problem, everything works as expected, but on windows i was abit off till I figured it out just now :) Thanks by the way – Breeze Mar 31 '16 at 15:35
0

Update :

Here is a note, this script is for when you want to execute a batch file by lets say double clicking on it directly. (I mean execute the batch file directly from the (sub)directory inwhich it resides.
but if you intend on either calling it from the root of your folders, you need to see the accepted answer. I leave my answer here aswell, in case it may come in handy for some others.

Actual Answer

I myself am using the standard method which is accepted as the answer.
Thanks to dear God, I finally Got it working, the actual equivalent batch script is as follows:

REM go to the caffe root
cd ../../

set BIN=build/x64/Release

"%BIN%/caffe.exe" train --solver=examples/cifar10/cifar10_full_relu_solver_bn.prototxt

pause

using this, I no longer need to change anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.