<jupyter_start><jupyter_text>概要1. [remove_bg](https://github.com/takecx/remove_bg)で入力人物画像の背景を切り取った画像とmask画像を生成する2. [PIFu](https://github.com/shunsukesaito/PIFu)で`.obj`ファイルを生成する3. [obj2schematic](https://github.com/takecx/obj2schematic)で`.obj`ファイルを`.schematic`ファイルに変換する<jupyter_code>input_image = 'data/sample.png'

# remove_bg
kernel_size = 5
iteration = 3

# obj2schematic
w_max = 100
h_max = 100
import sys,os
input_basename = os.path.splitext(os.path.basename(input_image))[0]<jupyter_output><empty_output><jupyter_text>remove_bg<jupyter_code>remove_bg_path = os.path.join(os.path.abspath(''), 'remove_bg/FBA_Matting')
if not remove_bg_path in sys.path:
    sys.path.append(remove_bg_path)
!python remove_bg/BackgroundRemover.py $input_image --kernel_size $kernel_size --iteration $iteration<jupyter_output><empty_output><jupyter_text>PIFu<jupyter_code># Training
GPU_ID=0
NAME='pifu_demo'

# Network configuration
BATCH_SIZE=1
MLP_DIM='257 1024 512 256 128 1'
MLP_DIM_COLOR='513 1024 512 256 128 3'

# Reconstruction resolution
# NOTE: one can change here to reconstruct mesh in a different resolution.
VOL_RES=256

CHECKPOINTS_NETG_PATH='./PIFu/checkpoints/net_G'
CHECKPOINTS_NETC_PATH='./PIFu/checkpoints/net_C'

TEST_FOLDER_PATH='./output'

# command
!CUDA_VISIBLE_DEVICES=$GPU_ID python ./PIFu/apps/eval.py \
    --name $NAME \
    --batch_size $BATCH_SIZE \
    --mlp_dim $MLP_DIM \
    --mlp_dim_color $MLP_DIM_COLOR \
    --num_stack 4 \
    --num_hourglass 2 \
    --resolution $VOL_RES \
    --hg_down 'ave_pool' \
    --norm 'group' \
    --norm_color 'group' \
    --test_folder_path $TEST_FOLDER_PATH \
    --load_netG_checkpoint_path $CHECKPOINTS_NETG_PATH \
    --load_netC_checkpoint_path $CHECKPOINTS_NETC_PATH<jupyter_output><empty_output><jupyter_text>obj2schematic<jupyter_code>pifu_obj = os.path.join('./results/pifu_demo/', 'result_' + input_basename + '_fg.obj')
!python obj2schematic/Obj2SchemticConverter.py $pifu_obj  --h_max $h_max --w_max $w_max<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12861415752741776, 'fraction_numerical': 0.029411764705882353, 'mean_word_length': 5.412140575079873, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '50359', 'license': 'MIT', 'n_tokens_mistral': 890, 'n_tokens_neox': 846, 'n_words': 111, 'path': 'TitanCraft.ipynb', 'repo_name': 'takecx/TitanCraft', 'size': '2006'}