Skip to content

toyxyz/toyxyz_tools

Repository files navigation

toyxyz_tools

Easy-to-use AI tools.

GUI with a collection of handy tools

image

This tool is intended for use on 2D illustrative images where normal estimation does not work well.

Create a depth using Depthanything v2, and generate a normal map from the depth.

ComfyUI version : https://github.com/toyxyz/ComfyUI_toyxyz_test_nodes

image

Example

Blender image

Clip studio paint image

image

Installation

  git clone https://github.com/toyxyz/toyxyz_tools

  cd toyxyz_tools

  python -m venv venv

  cd venv/Scripts

  activate

  cd ../..

Install pytorch for the CUDA version installed on your machine.

https://pytorch.org/get-started/locally/

  pip install -r requirements.txt

  gui.py

If you want faster processing and less VRAM usage, install the appropriate version of xformers.

https://github.com/facebookresearch/xformers#installing-xformers

How to use

Add Image: Select one image.

Add Path: Select the path where the images are located.

D2N: Generates a plane mesh with a normal map from an image.

Lineart: Creates line art from an image.

image

1. D2N / Depth to normal

image

Generates a depth using the input image, generates a normal map from the depth, and exports a .gITF 3D file.

If the input image has an alpha channel, it will also be applied to the glTF material.

You can import it into programs like Blender, Unity, or Clip studio paint.

image

Input_size: Specifies the resolution of the depth. Higher gives more detail, but uses more VRAM.

normal_depth: Adjusts the blue channel (depth) of the normal map: lower makes it look more three-dimensional, higher makes it flatter.

normal_min: Depths lower than this value are excluded from the normal map.

Sobel_ratio : Mix ratio of sobel gradients used in normal map computation. The higher it is, the more depth, but the coarser it is.

image

metallic: Specifies the metallic value of the material.

roughness: Specifies the roughness value of the material.

bilateral_blur: Specifies the strength of the bilateral filter applied to the normal map.

sigmaColor : Filter sigma in the color space.

sigmaSpace : Filter sigma in the coordinate space.

guided_blur : Specifies the strength of the guided filter applied to the normal map.

loop : loop count of guided filter

eps : guided filter parameter. The higher the value, the smoother the surface.

Background : Specifies the color to fill in the background if the input image has an alpha channel. It's more effective to use a color that contrasts with the color of the object.

Upscale_tile : Specifies the tile size to use for normal map upscaling. If you lack vram, use a lower value. If it's 0, no tiles are used.

Detail_mult : enhances the detail of the surface. Too high values make the image flat. Add 0.01 each.

Blur/Blur_sigma : GaussianBlur for detail.

Detail_RGB : Specifies the RGB ratio to convert the original image to grayscale for detail. Red is black when R is 0.

Use color texture : Specifies whether to apply color texture to the mesh. White is used when disabled.

Show BG Color: Displays the input image to be used for depth creation. Used to check background colors.

Upscale normal: Upscales the normal map using the upscale model.

Use path : Use images located in the path added as 'Add Path'.

Save glTF: Saves the glTF file. If you only need normals and depth, turn this off.

Depth Model Selection: Select the DepthAnything v2 model to use to generate depth. Larger models use more VRAM and are more accurate. small < base < large

It will automatically download the model. If you have any problems, download it from the path below and put it in toyxyz_tools/checkpoints.

https://huggingface.co/depth-anything/Depth-Anything-V2-Small/resolve/main/depth_anything_v2_vits.pth?download=true

https://huggingface.co/depth-anything/Depth-Anything-V2-Base/resolve/main/depth_anything_v2_vitb.pth?download=true

https://huggingface.co/depth-anything/Depth-Anything-V2-Large/resolve/main/depth_anything_v2_vitl.pth?download=true

Upscale Model Selection: Select the RealESRGAN model to use for upscaling.

It will automatically download the model. If you have any problems, download it from the path below and put it in toyxyz_tools/weights.

https://github.com/xinntao/Real-ESRGAN

Add Texture: Select an image to use as a color texture for the material instead of the input image.

Select Texture Directory: When using the 'Use Path' mode, select the path where the images to be used for the material's color texture are located. They should have the same name and format as the input images.

Select Output Directory: Specify the path where the generated image and glTF will be saved. If not selected, they will be saved in the output folder.

Generate : Generate start

2. Lieart extract

image

Generates line art from an input image.

image

resolution: Specifies the resolution of the lineart. Higher values provide more detail, but use more resources.

blur_b, sigmaColor_b, sigmaSpace_b: Apply a bilateral filter to the image before it is processed. Increase the intensity if the image is noisy.

blur_a, sigmaColor_a, sigmaSpace_a: Apply a bilateral filter to the image after it is processed. Increase the intensity if the lineart image is noisy.

line_color: Specifies the color(RGB) of the line. White is not available.

Background : Specifies the color to fill in the background if the input image has an alpha channel. It's more effective to use a color that contrasts with the color of the object.

Upscale_tile : Specifies the tile size to use for lineart upscaling. If you lack vram, use a lower value. If it's 0, no tiles are used.

Threshold: Sets pixels above the threshold to black and pixels below to white. Lowering it increases detail.

image

Use Alpha: If the input image has an alpha channel, it will be applied to the line art image.

Show BG Color: Displays the input image to be used for depth creation. Used to check background colors.

Upscale lineart: Upscales the lineart using the upscale model.

Use path : Use images located in the path added as 'Add Path'.

Use threshold: Use a threshold value.

Method selection: Specify the method to use for generating lineart.

Upscale Model Selection: Select the RealESRGAN model to use for upscaling.

Select Output Directory: Specify the path where the generated image and glTF will be saved. If not selected, they will be saved in the output folder.

Generate : Generate start

https://github.com/DepthAnything/Depth-Anything-V2

https://github.com/xinntao/Real-ESRGAN

About

Easy-to-use AI tools.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages