Friday, September 5, 2014

Script to create in a bash script

Here is a shell script I use to create multiple nohup commands and put them in bash script called scripts1to100.txt. Each nohup command runs a matlab function called  runFunctionWithVariablesAandB which takes a and b as inputs.

for i in {1..100};
 do
let a=(i-1)*100+1;
let b=i*100;
echo nohup matlab -nodisplay -nosplash -r \"runFunctionWithVariablesAandB\($a:$b\)\; exit\;\" \> \/home\/logs\/batch$i.log \& >>scriptsFor1to100.txt;
 done

Once script1to100.txt is ready, you can run it by calling 'bash script1to100.txt'

Note: This particular script launches 100 parallel runs of runFunctionWithVariablesAandB, each with a different set of inputs.

Tuesday, September 2, 2014

Inserting text in visual mode in vim

Steps:

1) Ctrl+v (takes you to visual mode)
2) up/down/left/right arrows to select location for inserting text.
3) Gto select all lines in the file
4) Actual commands for inserting: 'I' takes to insert mode
5) type the text you want to insert. It gets inserted in the first line
6) hit Esc. the inserting done in all the lines you selected.

Friday, August 29, 2014

Comparing strings

strcmp(var,'<string>')

Thursday, August 28, 2014

checking for a field in struct matlab

To check if stuct S has a field called 'fieldName', use:

isfield(S, 'fieldname')

Tuesday, August 19, 2014

Changes to run BING (objectness)

General changes to run on our servers:
-- In the objectness folder: change line 15:
from
set(OPENMP_FLAG "-fopenmp -std=c++11 -ftree-vectorize")
to
set(OPENMP_FLAG "-fopenmp -std=c++0x -ftree-vectorize")
--Put absolute path to the dataset as opposed to relativepath in Main.cpp


Specific changes to make it compaible with ImageNet:
in Objectness/CmFile.cpp line number: added these lines:
415                                     if (line.find (' ') != string::npos)
416                                     {
417                                       int position = line.find (' ');
418                                       strs.push_back(line.substr(0,position));
419                                     }
420                                       else
421                                       strs.push_back(line);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
The xml annotation file had some inconsistencies for imagenet:
                        ILSVRC2012_val_00029561.xml
                        ILSVRC2012_val_00047711
                        ILSVRC2012_val_00037916
                        ILSVRC2012_val_00027851
                        ILSVRC2012_val_00008272
                           ILSVRC2012_val_00004948
                            ILSVRC2012_val_00000400
                           ILSVRC2012_val_00008009
                          ILSVRC2012_val_00019545
                         ILSVRC2012_val_00032716
                         ILSVRC2012_val_00000922
                         ILSVRC2012_val_00023854
                         ILSVRC2012_val_00035744
  ILSVRC2012_val_00019316
ILSVRC2012_val_00021400
ILSVRC2012_val_00004522
ILSVRC2012_val_00006974
and many more. this cannot be done manually.!
(the coordinates cannot be 0 in matlab!)

%%%%%%%%%%%%%%%
The changes in everything above xml file issues can be ignored




Monday, August 11, 2014

deleting data from a cell in matlab

if A is a cell:
A{m,n}=[] creates an empty element in the (m,n) index
A(m,:)=[] deletes the entire m'th row, A ow has one less row 

Monday, August 4, 2014

Replacing some part of a string or remmoving a part of a string

a=<your_string>
 b=`echo $a | sed 's/<string_you_want_to_replace>//'

(you don't need to put any quotes around <string_you_want_to_replace>)