use absolute path in script
authorchyojn <chyojn@gmail.com>
Fri, 28 Feb 2014 06:46:13 +0000 (14:46 +0800)
committerchyojn <chyojn@gmail.com>
Fri, 28 Feb 2014 06:46:13 +0000 (14:46 +0800)
tools/extra/parselog.sh
tools/extra/plot_training_log.py.example

index 8b7ce47..39927a6 100755 (executable)
@@ -3,6 +3,9 @@
 # It creates two files one caffe.log.test that contains the loss and test accuracy of the test and
 # another one caffe.log.loss that contains the loss computed during the training
 
+#get the dirname of the script
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
 if [ "$#" -lt 1 ]
 then
 echo "Usage parselog.sh /path/to/your.log"
@@ -18,7 +21,7 @@ grep 'Test score #1' aux.txt | awk '{print $8}' > aux2.txt
 # For extraction of time since this line constains the start time
 grep '] Solving ' $1 > aux3.txt
 grep 'Testing net' $1 >> aux3.txt
-./extract_seconds.py aux3.txt aux4.txt
+$DIR/extract_seconds.py aux3.txt aux4.txt
 
 # Generating
 echo '# Iters Seconds TestAccuracy TestLoss'> $LOG.test
@@ -33,7 +36,7 @@ grep ', loss = ' $1 | awk '{print $9}' > aux1.txt
 grep ', lr = ' $1 | awk '{print $9}' > aux2.txt
 
 # Extracting elpased seconds
-./extract_seconds.py aux.txt aux3.txt
+$DIR/extract_seconds.py aux.txt aux3.txt
 
 # Generating
 echo '# Iters Seconds TrainingLoss LearningRate'> $LOG.train
index b40cbc7..a68ab2f 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+import inspect
 import os
 import random
 import sys
@@ -9,7 +10,8 @@ import matplotlib.legend as lgd
 import matplotlib.markers as mks
 
 def get_log_parsing_script():
-    return './parselog.sh'
+    dirname = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
+    return dirname + '/parselog.sh'
 
 def get_log_file_suffix():
     return '.log'
@@ -22,7 +24,7 @@ def is_x_axis_field(field):
     return field in x_axis_fields
 
 def create_field_index():
-    train_key = 'Training'
+    train_key = 'Train'
     test_key = 'Test'
     field_index = {train_key:{'Iters':0, 'Seconds':1, train_key + ' loss':2,
                               train_key + ' learning rate':3},
@@ -59,7 +61,7 @@ def get_data_file_type(chart_type):
     return data_file_type
 
 def get_data_file(chart_type, path_to_log):
-    return path_to_log + '.' + get_data_file_type(chart_type).lower()
+    return os.path.basename(path_to_log) + '.' + get_data_file_type(chart_type).lower()
 
 def get_field_descriptions(chart_type):
     description = get_chart_type_description(chart_type).split(