Reputation: 1400
I need to run my script named train.py
but I also need to set up the flas, by issuing this command in bash:
train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
However, it catches this error:
File "/Users/cvsanbuenaventura/miniconda3/lib/python3.6/site-packages/google/protobuf/text_format.py", line 1288, in _ConsumeSingleByteString raise self.ParseError('String missing ending quote: %r' % (text,)) google.protobuf.text_format.ParseError: 123:17 : String missing ending quote: '"/Users/cvsanbuenaventura/Documents/tensorflow/models/research/object_detection/train.record“'
So I want to debug in Python Shell or Jupyter Notebook line by line. However I also need to set th train_dir
flag. How do I accomplish this?
Upvotes: 5
Views: 5378
Reputation: 61
If anyone else has the problem of not being able to add flags to IPython/Jupyter, here's a quick workaround.
# import sys, app and flags
import sys
sys.argv = " --train_dir training/".split(" ")
from absl import app, flags
# add the flags you need:
flags.FLAGS.train_dir = 'training/'
# add the actual code to a function
def main(argvs):
# the code you want to debug
app.run(main)
Upvotes: 5
Reputation: 563
According to the documentation you can add flags to your command line arguments with argparse. An example is given below:
parser.add_argument('integers', metavar='N', type=int, nargs='+',
help='an integer for the accumulator')
Upvotes: -2