jantic / DeOldify

A Deep Learning based project for colorizing and restoring old images (and video!)
MIT License
18.02k stars 2.57k forks source link

output path doesn't not cast as Path object correctly #47

Closed gmerrall closed 5 years ago

gmerrall commented 5 years ago

Had another minor issue when running from command line

Traceback (most recent call last):
  File "test.py", line 28, in <module>
    vis.plot_transformed_image("/tmp/Alfred-James-Boyce.jpg")
  File "/mnt/disks/400gb_ssd/DeOldify/fasterai/visualize.py", line 37, in plot_transformed_image
    self._save_result_image(path, result)
  File "/mnt/disks/400gb_ssd/DeOldify/fasterai/visualize.py", line 46, in _save_result_image
    result_path = self.results_dir/source_path.name
AttributeError: 'str' object has no attribute 'name'

Looked like the output path wasn't being handled correctly?

In fasterai/visualize.py plot_transformed_image() accepts path as a string and converts it to a Path object but by the time we get to calling self._save_result_image() it's reverted back to a string. Maybe the casting on line 31 is by reference and not by value - I don't know enough about internals to know if that's the case.

Anyway, I just re-cast in the call to _save_result_image() and we're all hunky dory again self._save_result_image(Path(path), result)

EDIT: Ubuntu Xenial 16.,06 Python 3.6.6 :: Anaconda, Inc.

jantic commented 5 years ago

That's quite odd...You haven't altered that visualize.py file locally at all besides the re-cast you mentioned..?

gmerrall commented 5 years ago

Not AFAIK unless I monkeyed with it when trying to solve the previous issue with images downloaded via git cmdline. I'll revert the file and see if that fixes it.