Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Fix curdir error #363

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 03.image_classification/README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def load_image(file):
return im

test_data = []
cur_dir = os.path.dirname(os.path.realpath(__file__))
cur_dir = os.path.dirname(os.path.realpath('__file__'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加了单引号后,就不是当前路径了。
可以考虑换成:

os.path.abspath(os.path.dirname(sys.argv[0]))

参考:https://www.blog.pythonlibrary.org/2013/10/29/python-101-how-to-find-the-path-of-a-running-script/

test_data.append((load_image(cur_dir + '/image/dog.png'),))

# with open('params_pass_50.tar', 'r') as f:
Expand Down
2 changes: 1 addition & 1 deletion 03.image_classification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def load_image(file):
im = im / 255.0
return im
test_data = []
cur_dir = os.path.dirname(os.path.realpath(__file__))
cur_dir = os.path.dirname(os.path.realpath('__file__'))
test_data.append((load_image(cur_dir + '/image/dog.png'),))

# users can remove the comments and change the model name
Expand Down
2 changes: 1 addition & 1 deletion 03.image_classification/index.cn.html
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@
return im

test_data = []
cur_dir = os.path.dirname(os.path.realpath(__file__))
cur_dir = os.path.dirname(os.path.realpath('__file__'))
test_data.append((load_image(cur_dir + '/image/dog.png'),))

# with open('params_pass_50.tar', 'r') as f:
Expand Down
2 changes: 1 addition & 1 deletion 03.image_classification/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@
im = im / 255.0
return im
test_data = []
cur_dir = os.path.dirname(os.path.realpath(__file__))
cur_dir = os.path.dirname(os.path.realpath('__file__'))
test_data.append((load_image(cur_dir + '/image/dog.png'),))

# users can remove the comments and change the model name
Expand Down
3 changes: 2 additions & 1 deletion 03.image_classification/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def load_image(file):
return im

test_data = []
cur_dir = os.path.dirname(os.path.realpath(__file__))
cur_dir = os.path.dirname(os.path.realpath('__file__'))

test_data.append((load_image(cur_dir + '/image/dog.png'), ))

# users can remove the comments and change the model name
Expand Down