I have been experiencing an issue with tag_images_by_wd14_tagger.py.
I ran finetune/tag_images_by_wd14_tagger.py by using the options shown below:
$ accelerate launch "sd-scripts/finetune/tag_images_by_wd14_tagger.py" \
> --batch_size=8 --general_threshold=0.35 --character_threshold=0.35 \
> --caption_extension=".txt" --caption_separator="," \
> --model="SmilingWolf/wd-v1-4-convnextv2-tagger-v2" \
> --max_data_loader_n_workers="2" --debug --remove_underscore \
> --frequency_tags "data/images"
Then I got this UnboundLocalError:
Traceback (most recent call last):
File "/workspace/sd-scripts/finetune/tag_images_by_wd14_tagger.py", line 514, in <module>
main(args)
File "/workspace/sd-scripts/finetune/tag_images_by_wd14_tagger.py", line 333, in main
data = torch.utils.data.DataLoader(
UnboundLocalError: local variable 'torch' referenced before assignment
Traceback (most recent call last):
File "/opt/conda/bin/accelerate", line 8, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.10/site-packages/accelerate/commands/accelerate_cli.py", line 46, in main
args.func(args)
File "/opt/conda/lib/python3.10/site-packages/accelerate/commands/launch.py", line 1075, in launch_command
simple_launcher(args)
File "/opt/conda/lib/python3.10/site-packages/accelerate/commands/launch.py", line 681, in simple_launcher
raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
I have investigated why the error occurs, and I noticed an unnecessary extra import of torch is made here:
|
# モデルを読み込む |
|
if args.onnx: |
|
import torch |
|
import onnx |
I suspect this extra import statement makes torch a local, unbound variable, and it is only available when run with the --onnx option.
torch is already imported this line:
And the import statement on line 115 must be removed.
I have been experiencing an issue with
tag_images_by_wd14_tagger.py.I ran
finetune/tag_images_by_wd14_tagger.pyby using the options shown below:Then I got this UnboundLocalError:
I have investigated why the error occurs, and I noticed an unnecessary extra import of torch is made here:
sd-scripts/finetune/tag_images_by_wd14_tagger.py
Lines 113 to 116 in 71e2c91
I suspect this extra import statement makes
torcha local, unbound variable, and it is only available when run with the--onnxoption.torchis already imported this line:sd-scripts/finetune/tag_images_by_wd14_tagger.py
Line 8 in 71e2c91
And the import statement on line 115 must be removed.