I want to execute a train.py script inside a colab or jupyter notebook.
Before running I have to set some variables, e.g. dataset-type.
I did as I would type into a terminal command but I get a SyntaxError.
--dataset-type=voc
--dataset-type='voc'
^
SyntaxError: can't assign to operator
Executing from a terminal works fine but how do I declare the variables correctly?
Here is some code of train.py:
parser = argparse.ArgumentParser(description='Single Shot MultiBox Detector Training With PyTorch')
# Params for datasets
parser.add_argument('--dataset-type', default="voc", type=str,
help='Specify dataset type. Currently supports voc and open_images.')
parser.add_argument('--datasets', '--data', nargs='+', default=["data"], help='Dataset directory path')
parser.add_argument('--balance-data', action='store_true',
help="Balance training data by down-sampling more frequent labels.")
I tried:
from sys import argv
argv.append('--dataset-type=voc')
This solved the SyntaxError.
But I get following error in the end. There are more variables to set, but --dataset-type is still listed.
usage: ipykernel_launcher.py [-h] [--dataset-type DATASET_TYPE]
[--datasets DATASETS [DATASETS ...]]
[--balance-data] [--net NET] [--freeze-base-net]
[--freeze-net] [--mb2-width-mult MB2_WIDTH_MULT]
[--base-net BASE_NET]
[--pretrained-ssd PRETRAINED_SSD]
[--resume RESUME] [--lr LR] [--momentum MOMENTUM]
[--weight-decay WEIGHT_DECAY] [--gamma GAMMA]
[--base-net-lr BASE_NET_LR]
[--extra-layers-lr EXTRA_LAYERS_LR]
[--scheduler SCHEDULER] [--milestones MILESTONES]
[--t-max T_MAX] [--batch-size BATCH_SIZE]
[--num-epochs NUM_EPOCHS]
[--num-workers NUM_WORKERS]
[--validation-epochs VALIDATION_EPOCHS]
[--debug-steps DEBUG_STEPS] [--use-cuda USE_CUDA]
[--checkpoint-folder CHECKPOINT_FOLDER]
ipykernel_launcher.py: error: unrecognized arguments: -f /root/.local/share/jupyter/runtime/kernel-f89b4ea1-0c84-4617-af88-0191a91639c0.json
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py:2890: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)