I am trying to implement StyleGAN2-ADA PyTorch: https://github.com/NVlabs/stylegan2-ada-pytorch.
On the GitHub repo, it states the following:
The above code requires torch_utils and dnnlib to be accessible via PYTHONPATH. It does not need source code for the networks themselves — their class definitions are loaded from the pickle via torch_utils.persistence.
What does this mean, and how can I do this?
Let's say you have the source code of this repo cloned to /somepath/stylegan2-ada-pytorch
which means that the directories you quoted are at /somepath/stylegan2-ada-pytorch/torch_utils
and /somepath/stylegan2-ada-pytorch/dnnlib
, respectively.
Now let's say you have a python script that you want to access this code. It can be anywhere on your machine, as long as you add this to the top of your python script:
import os
import sys
#save the literal filepath to both directories as strings
tu_path = os.path.join('somepath','stylegan2-ada-pytorch','torch_utils')
dnnlib_path = os.path.join('somepath','stylegan2-ada-pytorch','dnnlib')
#add those strings to python path
sys.path.append(tu_path)
sys.path.append(dnnlib_path )
Note that this only adds those location to PYTHONPATH for the duration of that python script running, so you need this at the top of any python script that intends to use those libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With