def Hayao(): path.set(gl_path_) t='generator_Hayao_weight' arg=parse_args(t,gl_path_) test(arg.checkpoint_dir, arg.save_dir, arg.test_dir, arg.if_adjust_brightness) def parse_args(a,b): desc = "AnimeGANv2" parser = argparse.ArgumentParser(description=desc) parser.add_argument('--checkpoint_dir', type=str, default='checkpoint/'+a, help='Directory name to save the checkpoints') parser.add_argument('--test_dir', type=str, default=b, help='Directory name of test photos') parser.add_argument('--save_dir', type=str, default='Shinkai/t', help='what style you want to get') parser.add_argument('--if_adjust_brightness', type=bool, default=True, help='adjust brightness by the real photo') """checking arguments""" return parser.parse_args()代码报错修改
时间: 2024-03-24 14:40:00 浏览: 145
JadGen.rar_.jad generator_cod to jad generator_jad_jad gen downl
这段代码报错可能是因为你没有导入`argparse`模块。你需要在代码开头加上`import argparse`语句。同时,你需要将`gl_path_`传入函数`Hayao()`中,否则会出现`NameError`错误。修改后的代码如下:
```
import argparse
def Hayao(gl_path_):
path.set(gl_path_)
t='generator_Hayao_weight'
arg=parse_args(t,gl_path_)
test(arg.checkpoint_dir, arg.save_dir, arg.test_dir, arg.if_adjust_brightness)
def parse_args(a,b):
desc = "AnimeGANv2"
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('--checkpoint_dir', type=str, default='checkpoint/'+a,
help='Directory name to save the checkpoints')
parser.add_argument('--test_dir', type=str, default=b,
help='Directory name of test photos')
parser.add_argument('--save_dir', type=str, default='Shinkai/t',
help='what style you want to get')
parser.add_argument('--if_adjust_brightness', type=bool, default=True,
help='adjust brightness by the real photo')
"""checking arguments"""
return parser.parse_args()
```
调用`Hayao()`函数时,需要将`gl_path_`作为参数传入。
阅读全文