Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shutil.SameFileError #4

Closed
bycloudai opened this issue Apr 7, 2020 · 7 comments
Closed

shutil.SameFileError #4

bycloudai opened this issue Apr 7, 2020 · 7 comments

Comments

@bycloudai
Copy link

bycloudai commented Apr 7, 2020

Hi, I tried the command in the README file:

python main_train.py --gpu 0 --train_mode harmonization --train_stages 3 --min_size 120 --lrelu_alpha 0.3 --niter 1000 --batch_norm --input_name Images/Harmonization/scream.jpg

and it popped up an error:

Traceback (most recent call last): File "main_train.py", line 105, in <module> copyfile(py_file, osp.join(dir2save, py_file.split("/")[-1])) File "\Python\lib\shutil.py", line 104, in copyfile raise SameFileError("{!r} and {!r} are the same file".format(src, dst)) shutil.SameFileError: '\\ConSinGAN-master\\ConSinGAN-master\\evaluate_model.py' and '\\ConSinGAN-master\\ConSinGAN-master\\evaluate_model.py' are the same file

Please send help, thank you

@tohinz
Copy link
Owner

tohinz commented Apr 7, 2020

Hm, are you using Windows?
Can you add print(dir2save) before the line that causes the error and check the output (should be something like "ConSinGAN-master/TrainedModels/scream/...").

@bycloudai
Copy link
Author

bycloudai commented Apr 7, 2020

my dir2save is:
TrainedModels/scream/2020_04_07_22_20_08_harmonization_train_depth_3_lr_scale_0.1_BN_act_lrelu_0.3
and yep I am using windows.

@tohinz
Copy link
Owner

tohinz commented Apr 7, 2020

I guess it might have something to do with Windows using "\" instead of "/" (as Ubuntu does) in paths. Does it create the dir2save folder?
What are the paths for py_file and the osp.join() operation in line 105? Does it work if you replace "/" with "\" in py_file.split("/") line 105?
You'll likely have to replace all "/" with "\" in every operation that saves/loads files to/from the hard drive (also in training_harmonization_editing.py)

@bycloudai
Copy link
Author

I've edited the line to:
line 106:
copyfile(py_file, osp.join(dir2save, py_file.split("\\"[-1]))

and this is the error:
File "main_train.py", line 106 copytree(osp.join(current_path, "ConSinGAN"), osp.join(dir2save, "ConSinGAN")) ^ SyntaxError: invalid syntax

It does create a folder in TrainedModels/scream but it only contains parameter

@tohinz
Copy link
Owner

tohinz commented Apr 7, 2020

Please try
copyfile(py_file, osp.join(dir2save, py_file.split("\\")[-1]))

@bycloudai
Copy link
Author

bycloudai commented Apr 7, 2020

I tried the

the error is still:
File "main_train.py", line 106 copytree(osp.join(current_path, "ConSinGAN"), osp.join(dir2save, "ConSinGAN")) ^ SyntaxError: invalid syntax

Nevermind, I missed a closing bracket, sorry.
Changing it to
copyfile(py_file, osp.join(dir2save, py_file.split("\\")[-1]))
does work, thank you.

@Lannister0910
Copy link

I also have the same problem .I use this way and it does work.thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants