Reputation: 155
Running my code including this line:
def parse_args():
parser = argparse.ArgumentParser(description='test with parser')
parser.add_argument("--model", type=str, default= "E:\Script\weights\resnext101.pth")
I got this error:
OSError: [Errno 22] Invalid argument: 'E:\\Script\\weights\resnext101.pth'
What is the error for and how I can fix it?
Upvotes: 0
Views: 28
Reputation: 531275
You aren't passing a path ending with the name resnext101.pth
; you are passing a path ending with the name weights␍esnext101.pth
, which contains a literal carriage return.
Use a raw string literal to protect all backslashes from expansion, regardless of the character that follows the backslash.
parser.add_argument("--model", type=str, default= r"E:\Script\weights\resnext101.pth")
Upvotes: 2