Since the free version of Colab cannot directly use the terminal, it can only be realized through command line statements in the notebook
The actual measurement found that the initial path of the Colab terminal is\content
equivalent to that of the Windows terminal:C:\content>
Therefore, when running region_control.py through the command line in the notebook, it should be executed !python /content/multidiffusion-region-based/region_control.py
( it cannot be written !python /multidiffusion-region-based/region_control.py
, it must be /content
added) , which is equivalent to the Windows terminal like this:C:\content>python multidiffusion-region-based\region_control.py
The path of the mask map was originally masks/XXX.png
, indicating the relative path between mask.png and region_control.py, it should be changed now /content/multidiffusion-region-based/masks/XXX.png
( it cannot be written /multidiffusion-region-based/masks/XXX.png
, it must be /content
added ), because the current root path is /content
, if it is still masks/XXX.png
, an error will be reported can't find/content/masks/XXX.png
At the same time, it can also be found that the output result out.png
should have been in the same directory as region_control.py, but it is also \content\out.png
in it now, not \content\multidiffusion-region-based\out.png
in
If you want to use the relative path between mask.png and region_control.py as you usually run region_control.py, you should do this in the Windows terminal:
# 先切换路径到multidiffusion-region-based下
C:\content>cd multidiffusion-region-based
C:\content\multidiffusion-region-based>python region_control.py
The corresponding code is (I don’t know why it’s invalid to use !cd, but it’s OK to use %cd):
# 先切换路径到/content/multidiffusion-region-based下,不能写成%cd /multidiffusion-region-based,必须把/content加上
%cd /content/multidiffusion-region-based
!python region_control.py