nagadomi / nunif

Misc; latest version of waifu2x; 2D video to stereo 3D video conversion
MIT License
1.58k stars 142 forks source link

How do I launch my own model? #22

Closed My12123 closed 1 year ago

My12123 commented 1 year ago

How do I launch my own model? Located in F:\nunif\models\waifu2x_mymodel

nagadomi commented 1 year ago

For CLI, use --model-dir to specify the model directory. example

python -m waifu2x.cli --model-dir F:\nunif\models\waifu2x_mymodel -m scale -i input_image_or_dir.png -o output_image_or_dir.png

For waifu2x.web, use --art-model-dir or --photo-model-dir to specify the model directory. However, the directory used by waifu2x.web must have all the noise level model files. So I would suggest making a copy of waifu2x/pretrained_models/cunet/art first, overwriting the trained model there, and then specifying it.

My12123 commented 1 year ago

(nunif) F:\nunif>python -m waifu2x.cli --model-dir F:\nunif\models\waifu2x_mymodel -m scale -i F:\Загрузки\poster_1521773665852.jpg -o F:\Загрузки\3\poster_1521773665852.jpg Traceback (most recent call last): File "F:\1\envs\nunif\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "F:\1\envs\nunif\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "F:\nunif\waifu2x\cli.py", line 157, in main(args) File "F:\nunif\waifu2x\cli.py", line 107, in main ctx.load_model(args.method, args.noise_level) File "F:\nunif\waifu2x\utils.py", line 128, in load_model self._load_model(method, noise_level) File "F:\nunif\waifu2x\utils.py", line 76, in _load_model self.scalemodel, = load_model( File "F:\nunif\nunif\models\utils.py", line 50, in load_model model = create_model(data["name"], device_ids=device_ids, **data["kwargs"]) File "F:\nunif\nunif\models\register.py", line 38, in create_model raise ValueError(f"Unknown model name: {name}") ValueError: Unknown model name: waifu2x.upcunet

nagadomi commented 1 year ago

No error on my windows env. Does it work when specifying waifu2x/pretrained_models/cunet/art for --model-dir? example

mkdir tmp
python -m waifu2x.cli -m scale --model-dir .\waifu2x\pretrained_models\cunet\art\  -i .\waifu2x\docs\images\miku_128.png -o tmp\out.png

Also, would you post the results with DEBUG=1 when specifying your trained model? (expect powershell)

$env:DEBUG=1
python -m waifu2x.cli -m scale --model-dir F:\nunif\models\waifu2x_mymodel  -i .\waifu2x\docs\images\miku_128.png -o tmp\out.png

Maybe it is a problem related to LOCALE (language setting). Also try the following commands. (add -X utf8 for python )

python -X utf8 -m waifu2x.cli --model-dir F:\nunif\models\waifu2x_mymodel -m scale -i .\waifu2x\docs\images\miku_128.png -o tmp\out.png
nagadomi commented 1 year ago

Looking at #23, there seems to be something wrong with the module loading. Have you made any changes? For example, you accidentally deleted under waifu2x/models/. You can check the differences with the following commands.

git status waifu2x

Restoring nunif source code from the latest in git may fix it.