CF-Fontを windows で動かす

2024年11月14日

ユニックスを前提に作られているため Windows では動きません

from torch.nn.parallel import DistributedDataParallel as DDPを使わないで動かすことを試みます

CF-Font

少量のフォント生成は、次のような文字を生成することを目指しています。
ほんの数個の参照に従って、ソースドメインからターゲットドメインにフォ
ントイメージを変換することで新しいフォントを作成します。
特にロゴグラフィックのフォントを新しく作成する専門デ
ザイナーの労力を大幅に削減できます。
中国語など複数の文字を含む言語
(6万文字以上)、日本語(5万文字以上)、
韓国語(11K文字以上)は、参照が数個しかないため、
画像は手動でデザインする必要があるため、フォント生成は古代のフ
ォント補完に広く応用されています。

ダウンロードとインストール

git clone https://github.com/wangchi95/CF-Font

requirements.txt


tqdm
numpy
opencv-python  
scipy

matplotlib  
pillow  
tensorboardX
scikit-image
scikit-learn
lpips
pandas
kornia

仮想環境実行バッチ

@echo off
call %~dp0\scripts\env_for_icons.bat  %*
SET PATH=%PATH%;%WINPYDIRBASE%\PortableGit;%WINPYDIRBASE%\PortableGit\bin
SET PATH=%PATH%;%WINPYDIRBASE%\ffmpeg\bin
If not exist %WINPYDIRBASE%\content mkdir  %WINPYDIRBASE%\content 

set APP_NAME=CF-Font
set APP_DIR=%WINPYDIRBASE%\content\%APP_NAME%
echo %APP_DIR%
cd %WINPYDIRBASE%\content\

If not exist  %APP_DIR% git clone https://github.com/wangchi95/CF-Font


cd %APP_DIR%
timeout /t 5
if not defined VENV_DIR (set "VENV_DIR=%APP_DIR%\venv")
if EXIST %VENV_DIR% goto :activate_venv

::python.exe -m venv "%VENV_DIR%" 
python.exe -m venv "%VENV_DIR%" --system-site-packages 
if %ERRORLEVEL% == 0 goto :pip
echo Unable to create venv 
goto :skip_venv

:pip
call "%VENV_DIR%\Scripts\activate"
pip install -r requirements.txt

cmd.exe /k

:activate_venv
call "%VENV_DIR%\Scripts\activate"
cmd.exe /k
:skip_cmd
::
:skip_venv
cmd.exe /k

DCNのインストール

git clone https://github.com/ziplab/LITv2
cd LITv2\classification\mm_modules\DCN
pip install -v --no-cache-dir --no-build-isolation .

プログラムの変更

“D:\WinPython\content\CF-Font\functions\modulated_deform_conv_func.py"

#        output = DCN.modulated_deform_conv_forward(input, weight, bias,
        output = DCN.modulated_deform_conv2d_forward(input, weight, bias,

“D:\WinPython\content\CF-Font\venv\Lib\site-packages\kornia\feature\lightglue.py"


@torch.amp.custom_fwd(cast_inputs=torch.float32, device_type='cuda')
#@torch.cuda.amp.custom_fwd(cast_inputs=torch.float32)

“D:\WinPython\content\CF-Font\inf_with_style_ft_cf.py"


def init_distributed_mode(args):
    global local_rank


    else:
        print('Not using distributed mode')
        args.distributed = False
        local_rank = 0

#    dist.barrier()


#        style_sampler = torch.utils.data.distributed.DistributedSampler(style_val_dataset)
        style_sampler = None

#        assert not len(style_val_dataset) % (args.world_size * args.sty_batch_size), 'for ddp'


#                dist.barrier()
#                dist.all_reduce(s_refs, op=dist.ReduceOp.SUM)
#                dist.all_reduce(s_refs_count, op=dist.ReduceOp.SUM)
#                dist.barrier()


    # Run inf
#    content_sampler = torch.utils.data.distributed.DistributedSampler(base_dataset)
    content_sampler = None


            c_src_basis, skip1_basis, skip2_basis = G_EMA.cnt_encoder(samples) # [10,c,h,w]
#            c_src_basis, skip1_basis, skip2_basis = G_EMA.module.cnt_encoder(samples) # [10,c,h,w]
            

                x_res_ema, _ = G_EMA.decode(c_src, s_ref, skip1, skip2)
#                x_res_ema, _ = G_EMA.module.decode(c_src, s_ref, skip1, skip2)
                

#    style_sampler = torch.utils.data.distributed.DistributedSampler(ft_dataset)
    style_sampler = None


#            c_src_basis, skip1_basis, skip2_basis = G_EMA.module.cnt_encoder(imgs_basis) # [10,c,h,w]
            c_src_basis, skip1_basis, skip2_basis = G_EMA.cnt_encoder(imgs_basis) # [10,c,h,w]

        networks[name] = net_tmp
#        networks[name] =  torch.nn.parallel.DistributedDataParallel(net_tmp, device_ids=[args.gpu])

#    encoder = Encoder()

#    mini_bn = 4
    mini_bn = 2


“D:\WinPython\content\CF-Font\eval\get_scores_test.py"

#if opt.methods is '':
if opt.methods == '':

Windows 用 バッチファイルの作成

“D:\WinPython\content\CF-Font\scripts\00_env.bat"

call D:\WinPython\scripts\env_for_icons.bat  %*
SET PATH=%PATH%;%WINPYDIRBASE%\PortableGit;%WINPYDIRBASE%\PortableGit\bin
SET PATH=%PATH%;%WINPYDIRBASE%\ffmpeg\bin

set APP_NAME=CF-Font
set APP_DIR=%WINPYDIRBASE%\content\%APP_NAME%
echo %APP_DIR%
cd %WINPYDIRBASE%\content\

cd %APP_DIR%
if not defined VENV_DIR (set "VENV_DIR=%APP_DIR%\venv")
if EXIST %VENV_DIR% goto :activate_venv
goto :skip_venv
:activate_venv
call "%VENV_DIR%\Scripts\activate"
echo on
::cmd.exe /k

“D:\WinPython\content\CF-Font\scripts\01a_gen_date.bat"

call %~dp0\00_env.bat  %*

setlocal enabledelayedexpansion

set img_size=80
set chara_size=50
set chara=charset/GB2312_CN6763.txt
set chara=charset/JIS-X0208-1997_1234.txt
rem charset/test.txt
set font_basefolder=data/fonts
set out_basefolder=data/imgs

for %%f in (Seen240,Unseen60) do (
    set font_folder=!font_basefolder!/Font_%%f
    set out_folder=!out_basefolder!/%%f_S!img_size!F!chara_size!_FULL
    mkdir .\data\imgs\%%f_S%img_size%F%chara_size%_FULL
    python font2img.py --ttf_path !font_folder! ^
                       --img_size !img_size! ^
                       --chara_size !chara_size! ^
                       --chara !chara! ^
                       --save_path !out_folder!
)

endlocal

timeout /t 55&goto:eof
"D:\WinPython\content\CF-Font\data\imgs\Seen240_S80F50_FULL"

“D:\WinPython\content\CF-Font\scripts\01b_copy_subset.bat"

call %~dp0\00_env.bat  %*

set img_size=80
set chara_size=50
set chara=charset/GB2312_CN6763.txt
set chara=charset/JIS-X0208-1997_1234.txt
rem charset/test.txt
set font_basefolder=data/fonts
set out_basefolder=data/imgs

set full_ch=charset/GB2312_CN6763.txt
set full_ch=charset/JIS-X0208-1997_1234.txt
set train_ch=charset/TRAIN800.txt
set train_ch=charset/TRAIN800INDEX.txt
set test_ch=charset/TEST5646.txt
set test_ch=charset/JIS-X0208-1997_1234.txt
set fewshot_ch=charset/FS16.txt
set fewshot_ch=charset/FS16INDEX.txt

setlocal enabledelayedexpansion

for %%f in (Seen240,Unseen60) do (
    set fp=data/imgs/%%f_S%img_size%F%chara_size%

    set full_fp=!fp!_FULL
    set train_fp=!fp!_TRAIN800
    set test_fp=!fp!_TEST5646
    set fewshot_fp=!fp!_FS16
    python scripts/data_preparation/gen_subset.py -i !full_fp! -o !train_fp! -ic !full_ch! -oc !train_ch!
    python scripts/data_preparation/gen_subset.py -i !full_fp! -o !test_fp! -ic !full_ch! -oc !test_ch!
    python scripts/data_preparation/gen_subset.py -i !full_fp! -o !fewshot_fp! -ic !full_ch! -oc !fewshot_ch!
)

timeout /t 55&goto:eof
:skip_venv
"D:\WinPython\content\CF-Font\data\imgs\Seen240_S80F50_FS16"
"D:\WinPython\content\CF-Font\data\imgs\Seen240_S80F50_FULL"
"D:\WinPython\content\CF-Font\data\imgs\Seen240_S80F50_TRAIN800"

“D:\WinPython\content\CF-Font\scripts\02a_run_ddp.bat"

call %~dp0\00_env.bat  %*

set RANK=0
set WORLD_SIZE=1
set MASTER_ADDR=localhost
set MASTER_PORT=12345

mkdir output
mkdir output\models

set folder_path=output\models\logs

rem サブディレクトリを確認して削除
for /d %%s in ("%folder_path%\B0_K*") do (
rem     rmdir /s %folder_path%\%%~ns%%~xs
    rmdir /s /q "%folder_path%\%%s"
    echo Deleted subfolder: %%~ns%%~xs
)

python  main.py ^
    --img_size 80 ^
    --data_path data/imgs/Seen240_S80F50_TRAIN800 ^
    --lr 1e-4 ^
    --output_k 6 ^
    --batch_size 16 ^
    --iters 1000 ^
    --epoch 20 ^
    --val_num 6 ^
    --baseline_idx 0 ^
    --save_path output/models ^
    --model_name B0_K6BS16I1000E20_LR1e-4-wdl0.01 ^
    --wdl --w_wdl 0.01 ^
    --no_val
timeout /t 240&goto:eof
:skip_venv
    --data_path data/imgs/font_set_S80F50_TRAIN800 ^
    assert args.val_batch <= args.val_num or (not args.on_oss)

timeout /t 555
python -m torch.distributed.launch ^
    --nproc_per_node=2 --use_env main.py ^
python main.py ^

    --ddp ^
    --epoch 200 ^
    --output_k 240 ^
    --val_num 10 ^
    --model_name B0_K240BS32I1000E200_LR1e-4-wdl0.01 ^
 
"D:\WinPython\content\CF-Font\output\models\logs\B0_K6BS16I1000E20_LR1e-4-wdl0.01_20241108-175322\model_20.ckpt"

“D:\WinPython\content\CF-Font\scripts\03a_get_content_embeddings.bat"

call %~dp0\00_env.bat  %*

md output\embeddings
set k=6
set item=20
set img_size=80
set batch_size=16
set model_base=B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241103-185529
set model=output/models/logs/%model_base%/model_%item%.ckpt
set data=data/imgs/Seen240_S80F50_TRAIN800
rem !!! The more characters used to cluster, the better.
rem However, since the memory limitation, you can also use a subset of data_K240_S80F50_TRAIN800 to cluster.
rem like random choose 50 characters or simply use few-shot 16 characters.
set data=data/imgs/Seen240_S80F50_FS16

set folder_path=output\models\logs

for /d %%s in ("%folder_path%\B0_K*") do (
    set model_base=%%~ns%%~xs
    echo  subfolder: %%~ns%%~xs
)
set model=output/models/logs/%model_base%/model_%item%.ckpt

timeout /t 5

set CUDA_VISIBLE_DEVICES=0
python collect_content_embeddings.py --img_size %img_size% ^
                                    --data_path %data% ^
                                    --output_k %k% ^
                                    --batch_size %batch_size% ^
                                    --load_model %model% ^
                                    --save_path output/embeddings/embedding_%model_base%_%item% ^
                                    --baseline_idx 0 ^
                                    --n_atts %k% ^
                                    --no_skip

timeout /t 240&goto:eof
:skip_venv

timeout /t 555

                                    --batch_size 32 ^
set item=180
set k=240
"D:\WinPython\content\CF-Font\output\embeddings\embedding_B0_K6BS16I1000E20_LR1e-4-wdl0.01_20241108-175322_20\c_src.pth"

“D:\WinPython\content\CF-Font\scripts\03b_cluster_get_cf_basis.bat"

call %~dp0\00_env.bat  %*

set n_basis=6
set model_name=B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241103-185529
set item=20
set content_fm=output/embeddings/embedding_%model_name%_%item%/c_src.pth
set folder_path=output\models\logs

for /d %%s in ("%folder_path%\B0_K*") do (
    set model_name=%%~ns%%~xs
    echo  subfolder: %%~ns%%~xs
)
set content_fm=output/embeddings/embedding_%model_name%_%item%/c_src.pth
timeout /t 5

set CUDA_VISIBLE_DEVICES=0
python scripts/basis/get_basis_simple.py ^
-c %content_fm% ^
-lbs 6 ^
-nb %n_basis% ^
-m %model_name%_%item%

timeout /t 240&goto:eof
:skip_venv
-lbs 10 ^

timeout /t 555
set item=180

set n_basis=10
    assert k%per == 0
"D:\WinPython\content\CF-Font\basis\B0_K6BS16I1000E20_LR1e-4-wdl0.01_20241108-175322_20_basis_6_id_6.txt"

“D:\WinPython\content\CF-Font\scripts\03c_copy_basis_subset.bat"

call %~dp0\00_env.bat  %*

set img_size=80
set chara_size=50

setlocal enabledelayedexpansion

set base_n=10
set model_name=B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241103-185529
set item=20
    set k=6
    set basis_len=6

set content_fm=basis/%model_name%_%item%_basis_240_id_10.txt

set folder_path=output\models\logs

for /d %%s in ("%folder_path%\B0_K*") do (
    set model_name=%%~ns%%~xs
    echo  subfolder: %%~ns%%~xs
)
set content_fm=basis/%model_name%_%item%_basis_%k%_id_%basis_len%.txt

timeout /t 5

for %%f in (TRAIN800,TEST5646,FS16) do (
    set basis=%content_fm%
    set in_folder=data/imgs/Seen240_S%img_size%F%chara_size%_%%f
    set out_folder=data/imgs/BASIS_S%img_size%F%chara_size%_%%f
    rd /s/q data\imgs\BASIS_S%img_size%F%chara_size%_%%f

    python scripts\basis\copy_basis_imgs.py -b !basis! -i !in_folder! -o !out_folder!

)

endlocal

timeout /t 55&goto:eof
:skip_venv
timeout /t 555
"D:\WinPython\content\CF-Font\data\imgs\BASIS_S80F50_FS16"
"D:\WinPython\content\CF-Font\data\imgs\BASIS_S80F50_TEST5646"
"D:\WinPython\content\CF-Font\data\imgs\BASIS_S80F50_TRAIN800"

“D:\WinPython\content\CF-Font\scripts\03d_cal_cf_weights.bat"

call %~dp0\00_env.bat  %*

set img_size=80
set chara_size=50

setlocal enabledelayedexpansion

set base_n=6
set model_base=B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241103-185529
set item=20
    set k=240
    set k=6
    set basis_len=6
    set temperature=0.01

    set model=output/models/logs/%model_base%/model_%item%.ckpt

set folder_path=output\models\logs

for /d %%s in ("%folder_path%\B0_K*") do (
    set model_base=%%~ns%%~xs
    echo  subfolder: %%~ns%%~xs
)
    set model=output/models/logs/%model_base%/model_%item%.ckpt
    set basis_fn=%model_base%_%item%_basis_240_id_10
    set basis_fn=%model_base%_%item%_basis_%k%_id_%basis_len%

timeout /t 5


for %%o in (seen,unseen) do (
    if "%%o" == "seen" (
        set font_len=240
        set font_len=6
        set data=data/imgs/Seen240_S80F50_FS16
        set data=data/imgs/Seen240_S80F50_TRAIN800
        set basis_data=data/imgs/BASIS_S80F50_FS16
        set basis_data=data/imgs/BASIS_S80F50_TRAIN800
        set save_fn=basis/%basis_fn%_ws_!font_len!x10_t%temperature%.pth
        set save_fn=basis/%basis_fn%_ws_!font_len!x%basis_len%_t%temperature%.pth
    ) else (
        set font_len=60
        set font_len=6
        set data=data/imgs/Unseen60_S80F50_FS16
        set data=data/imgs/Unseen60_S80F50_TRAIN800
        set basis_data=data/imgs/BASIS_S80F50_FS16
        set basis_data=data/imgs/BASIS_S80F50_TRAIN800
        set save_fn=basis/%basis_fn%_unseen_ws_!font_len!x10_t%temperature%.pth
        set save_fn=basis/%basis_fn%_unseen_ws_!font_len!x%basis_len%_t%temperature%.pth
    )


    python cal_cf_weight.py ^
        --img_size %img_size% ^
        --data_path !data! ^
        --basis_path !basis_data! ^
        --output_k %k% ^
        --load_model %model% ^
        --font_len !font_len! ^
        --basis_len %basis_len% ^
        --baseline_idx 0 ^
        -t %temperature% ^
        --save_fn !save_fn!
)

endlocal


timeout /t 555&goto:eof
:skip_venv
timeout /t 555
    set item=180
set base_n=10

    set basis_len=10
RuntimeError: torch.cat(): expected a non-empty list of Tensors
"D:\WinPython\content\CF-Font\basis\B0_K6BS16I1000E20_LR1e-4-wdl0.01_20241108-175322_20_basis_6_id_6_ws_6x6_t0.01.pth"

“D:\WinPython\content\CF-Font\scripts\03e_init_cf_env.bat"

call %~dp0\00_env.bat  %*


set model=B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241103-185529
set item=20

set folder_path=output\models\logs

for /d %%s in ("%folder_path%\B0_K*") do (
    set model=%%~ns%%~xs
    echo  subfolder: %%~ns%%~xs
)

set model_base_folder=output\models\logs
set model_cf=CF_from_%model%_%item%
set ckpt=model_%item%.ckpt
timeout /t 5

mkdir %model_base_folder%\%model_cf%
copy %model_base_folder%\%model%\%ckpt% %model_base_folder%\%model_cf%
echo %ckpt% > %model_base_folder%\%model_cf%\checkpoint.txt


timeout /t 55&goto:eof
:skip_venv
timeout /t 555
    set item=10
"D:\WinPython\content\CF-Font\output\models\logs\CF_from_B0_K6BS16I1000E20_LR1e-4-wdl0.01_20241108-175322_20\checkpoint.txt"

“D:\WinPython\content\CF-Font\scripts\03f_run_ddp_cf.bat"

call %~dp0\00_env.bat  %*

set RANK=0
set WORLD_SIZE=1
set MASTER_ADDR=localhost
set MASTER_PORT=12345

set model_base=B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241103-185529
set item=20

set size=80
set k=240
set k=6
set basis_n=10
set basis_n=6
set data=data/imgs/Seen240_S80F50_TRAIN800
set folder_path=output\models\logs

for /d %%s in ("%folder_path%\B0_K*") do (
    set model_base=%%~ns%%~xs
    echo  subfolder: %%~ns%%~xs

)

set model_name=CF_from_%model_base%_%item%
set base_idxs=basis/%model_base%_%item%_basis_%k%_id_%basis_n%.txt
set base_ws=basis/%model_base%_%item%_basis_%k%_id_%basis_n%_ws_%k%x%basis_n%_t0.01.pth

timeout /t 5

set CUDA_VISIBLE_DEVICES=0,1
python  main.py ^
    --content_fusion ^
    --img_size %size% ^
    --data_path %data% ^
    --lr 1e-4 ^
    --output_k %k% ^
    --batch_size 16 ^
    --iters 1000 ^
    --epoch 20 ^
    --val_num 6 ^
    --baseline_idx 0 ^
    --save_path output/models ^
    --load_model %model_name% ^
    --base_idxs %base_idxs% --base_ws %base_ws% ^
    --no_val ^
    --wdl --w_wdl 0.01



timeout /t 55&goto:eof
:skip_venv
timeout /t 555
set item=180
    --ddp ^
    --val_num 10 ^
    --epoch 200 ^

python -m torch.distributed.launch ^
    --nproc_per_node=2 --use_env main.py ^

“D:\WinPython\content\CF-Font\scripts\04a_run_inf_cf.bat"

call %~dp0\00_env.bat  %*

mkdir output\test_rsts
rem set RANK=0
set LOCAL_RANK=0
set WORLD_SIZE=1
set MASTER_ADDR=localhost
set MASTER_PORT=12345

set n_basis=10
set n_basis=6
set model_base_src=B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241103-185529

set folder_path=output\models\logs

for /d %%s in ("%folder_path%\B0_K*") do (
    set model_base_src=%%~ns%%~xs
    echo  subfolder: %%~ns%%~xs
)

setlocal enabledelayedexpansion
    set item=200
    set item=20
    set k=240
    set k=6
    set img_size=80
    set base_n=10
    set base_n=6

    set topk=-1
    set ftep=0
    set ftep=10
    set wdl_ft=0.01
    set wdl=0.01
    set lr=0.01
    set t=0.01
set basis_n=6


    set model_cf=CF_from_!model_base_src!_180
    set model_cf=CF_from_!model_base_src!_%item%
    set model=output/models/logs/!model_cf!/model_!item!.ckpt
    set basis_content_folder=data/imgs/BASIS_S80F50_TEST5646
    set basis_style_ft_folder=data/imgs/BASIS_S80F50_FS16
    set basis_style_ft_folder=data/imgs/BASIS_S80F50_TRAIN800
    set basis_style_ft_folder=data/imgs/BASIS_S80F50_FS16

    rem set load_sv=basis/!model_base_src!_2_basis_4_id_4_ws_4x4_t0.01.pth

#for %%o in (seen,unseen) do (
for %%o in (seen) do (

    if "%%o" == "seen" (
        set font_len=240
        set font_len=6
        set target_style=data/imgs/Seen240_S80F50_FS16
        set basis_ws=basis/!model_base_src!_180_basis_240_id_10_ws_240x10_t0.01.pth
        set basis_ws=basis/!model_base_src!_%item%_basis_%k%_id_%basis_n%_ws_%k%x%base_n%_t0.01.pth

        set save_path=output/test_rsts/!model_cf!_!item!_top!topk!_ft!ftep!_wdl!wdl!_lr!lr!
    ) else (
        set font_len=60
        set font_len=6
        set target_style=data/imgs/Unseen60_S80F50_FS16
        set basis_ws=basis/!model_base_src!_180_basis_240_id_10_unseen_ws_60x10_t0.01.pth
        set basis_ws=basis/!model_base_src!_%k%_id_%basis_n%_unseen_ws_%k%x%base_n%_t0.01.pth
        set save_path=output/test_rsts/unseen_!model_cf!_!item!_top!topk!_ft!ftep!_wdl!wdl!_lr!lr!
    )


    python  inf_with_style_ft_cf.py ^
        --img_size !img_size! ^
        --data_path !target_style! ^
        --output_k !k! ^
        --load_model !model! ^
        --save_path !save_path! ^
        --font_len !font_len! ^
        --baseline_idx 0 ^
        --sty_batch_size 16 ^
        --basis_ws  !basis_ws! ^
        --top_k !topk! ^
        --basis_folder !basis_content_folder! ^
        --basis_ft_folder !basis_style_ft_folder! ^
        --ft_epoch !ftep! ^
        --lr !lr! ^
        --wdl --w_wdl !wdl_ft! 

 rem        --load_style !load_sv!
        rem --pkl --w_pkl !wdl_ft!
        rem --wdl --w_wdl !wdl_ft!
)

endlocal


timeout /t 240&goto:eof
:skip_venv

timeout /t 555
set item=180

        --sty_batch_size 40 ^

    python -m torch.distributed.launch ^
        --nproc_per_node 1 --use_env --master_port 34545 inf_with_style_ft_cf.py ^
RuntimeError: use_libuv was requested but PyTorch was build without libuv support

│   294 │   mini_bs = args.font_len // mini_bn                                                     │
"D:\WinPython\content\CF-Font\output\test_rsts\CF_from_B0_K6BS16I1000E20_LR1e-4-wdl0.01_20241108-175322_20_20_top-1_ft10_wdl0.01_lr0.01"

“D:\WinPython\content\CF-Font\scripts\04b_get_scores.bat"

call %~dp0\00_env.bat  %*
set model_base=B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241103-185529

set folder_path=output\models\logs
for /d %%s in ("%folder_path%\B0_K*") do (
    set model_base=%%~ns%%~xs
    echo  subfolder: %%~ns%%~xs
)

timeout /t 5
@echo off
setlocal enabledelayedexpansion
    
    set item=20
    set k=6

set "gid=%1"
if "%gid%"=="" set "gid=0"

for %%o in (seen,unseen) do (
    if "%%o"=="seen" (
        set "rst_name=CF_from_%model_base%_%item%_%item%_top-1_ft0_wdl0.01_lr0.01"
        set "gt_path=data/imgs/Seen240_S80F50_TEST5646"
    ) else (
        set "rst_name=unseen_CF_from_%model_base%_%item%_%item%_top-1_ft0_wdl0.01_lr0.01"
        set "gt_path=data/imgs/Unseen60_S80F50_TEST5646"
    )

    set "pred_path=output/test_rsts/!rst_name!"

    set CUDA_VISIBLE_DEVICES=!gid!
    python eval/get_scores_test.py ^
        -gt !gt_path! ^
        -pred !pred_path! ^
        --gpu
        rem -m l1
)

endlocal

timeout /t 240&goto:eof
:skip_venv
CF_from_B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241105-153034_2_2_top-1_ft0_wdl0.01_lr0.01
timeout /t 555
        rst_name=CF_from_B0_K240BS32I1000E200_LR1e-4-wdl0.01_20230426-233306_180_200_top-1_ft10_wdl0.01_lr0.01

                                    --batch_size 32 ^
set item=180
set k=240

“D:\WinPython\content\CF-Font\scripts\04c_cal_mean_scores.bat"

call %~dp0\00_env.bat  %*
set model_base=B0_K240BS32I1000E200_LR1e-4-wdl0.01_20241103-185529

set folder_path=output\models\logs

for /d %%s in ("%folder_path%\B0_K*") do (
    set model_base=%%~ns%%~xs
    echo  subfolder: %%~ns%%~xs
)

 
    set item=20
    set k=6

timeout /t 5
@echo off
setlocal enabledelayedexpansion

set "gid=%1"
if "%gid%"=="" set "gid=0"

for %%o in (seen,unseen) do (
    if "%%o"=="seen" (
        set "rst_name=CF_from_B0_%model_base%_180_200_top-1_ft10_wdl0.01_lr0.01"
        set "rst_name=CF_from_%model_base%_%item%_%item%_top-1_ft0_wdl0.01_lr0.01"
        set "font_len=4"
    ) else (
        set "rst_name=unseen_CF_from_%model_base%_180_200_top-1_ft10_wdl0.01_lr0.01"
        set "rst_name=unseen_CF_from_%model_base%_%item%_%item%_top-1_ft0_wdl0.01_lr0.01"
        set "font_len=60"
    )
    set "pred_path=output/test_rsts/!rst_name!"

    set CUDA_VISIBLE_DEVICES=!gid!
    python eval/cal_mean.py ^
    -f !pred_path!/a_scores/ ^
    -k !font_len!
    rem -j 1 3 4 ## !!! jump some fonts like basis font
)

endlocal

timeout /t 240&goto:eof
:skip_venv

timeout /t 555

                                    --batch_size 32 ^
set item=180
set k=240

JIS漢字コード:JIS第一・第二・第三・第四水準漢字

“D:\WinPython\content\CF-Font\charset\JIS-X0208-1997_1234.txt"

“D:\WinPython\content\CF-Font\charset\FS16INDEX.txt"

娃哀愛挨姶握渥旭梓斡扱宛姐絢綾或

“D:\WinPython\content\CF-Font\charset\TRAIN800INDEX.txt"トレーニングするデータは実在するフォントの文字にしてください

font,Python

Posted by eightban