From 544036b1e89d47b2c8131809cebe3c5a38d497b2 Mon Sep 17 00:00:00 2001 From: HugoTini <65409496+HugoTini@users.noreply.github.com> Date: Sun, 7 Aug 2022 16:52:59 +0200 Subject: [PATCH] Update readme, remove cli --- cli.md | 24 --------------------- deepbump_cli.py | 57 ------------------------------------------------- readme.md | 26 +++++++++------------- 3 files changed, 10 insertions(+), 97 deletions(-) delete mode 100644 cli.md delete mode 100644 deepbump_cli.py diff --git a/cli.md b/cli.md deleted file mode 100644 index 52f72ba..0000000 --- a/cli.md +++ /dev/null @@ -1,24 +0,0 @@ -# Command line interface - -## Installation - -To use DeepBump from the terminal, you must have Python -installed as well as the following dependencies : - - pip install onnxruntime - pip install Pillow - -By installing `onnxruntime`, be aware -of [Microsoft conditions](https://github.com/microsoft/onnxruntime/blob/master/docs/Privacy.md). This add-on use available APIs to disable telemetry. - -Then either [download DeepBump as a ZIP](https://github.com/HugoTini/DeepBump/releases) and extract it somewhere, or clone it with : - - git clone https://github.com/HugoTini/DeepBump.git - -## Usage - -Go to the DeepBump folder, then use with : - - python deepbump_cli.py -i -n -o - -where `` can be `small`, `medium` or `large`. \ No newline at end of file diff --git a/deepbump_cli.py b/deepbump_cli.py deleted file mode 100644 index f4bdda1..0000000 --- a/deepbump_cli.py +++ /dev/null @@ -1,57 +0,0 @@ -from PIL import Image -import numpy as np -import utils_inference -import onnxruntime as ort -from argparse import ArgumentParser - - -def progress_print(current, total): - print('{}/{}'.format(current, total)) - - -# Disable MS telemetry -ort.disable_telemetry_events() - -# Parse cli arguments -parser = ArgumentParser() -parser.add_argument('-i', '--img_path', dest='img_path', required=True, - help='path to the input image') -parser.add_argument('-n', '--normal_path', dest='normal_path', required=True, - help='path where the generated normal map is saved') -parser.add_argument('-o', '--overlap', dest='overlap', required=True, - help='tiles overlap size, must be "small", "medium" or "large"', - choices=['small', 'medium', 'large']) -args = parser.parse_args() - -# Load image -img = np.array(Image.open(args.img_path)) / 255.0 -# Reshape to C,H,W -img = np.transpose(img, (2, 0, 1)) -# Grayscale -img = np.mean(img[0:3], axis=0, keepdims=True) - -# Split image in tiles -print('tilling') -tile_size = 256 -overlaps = {'small': tile_size//6, 'medium': tile_size//4, - 'large': tile_size//2} -stride_size = tile_size-overlaps[args.overlap] -tiles, paddings = utils_inference.tiles_split(img, (tile_size, tile_size), - (stride_size, stride_size)) - -# Predict tiles normal map -print('generating') -ort_session = ort.InferenceSession('./deepbump256.onnx') -pred_tiles = utils_inference.tiles_infer(tiles, ort_session, - progress_callback=progress_print) - -# Merge tiles -print('merging') -pred_img = utils_inference.tiles_merge(pred_tiles, (stride_size, stride_size), - (3, img.shape[1], img.shape[2]), - paddings) - -# Save image -pred_img = pred_img.transpose((1, 2, 0)) -pred_img = Image.fromarray((pred_img*255.0).astype(np.uint8)) -pred_img.save(args.normal_path) diff --git a/readme.md b/readme.md index bfa7ace..b252ff6 100644 --- a/readme.md +++ b/readme.md @@ -2,35 +2,29 @@ # DeepBump -DeepBump is a tool to generate normal maps from single -pictures. See this [blog post](https://hugotini.github.io/deepbump) -for an introduction. It can be used either as a Blender add-on or -as a command-line program. +DeepBump is a machine-learning driven tool to generate normal & height maps from single pictures. See this [blog post](https://hugotini.github.io/deepbump) for an introduction. # Installation 1) [Download DeepBump as a ZIP](https://github.com/HugoTini/DeepBump/releases). -2) In Blender, go to _Edit -> Preferences -> Add-ons -> Install_ -and select the downloaded ZIP file. Then enable the add-on. +2) In Blender, go to _Edit -> Preferences -> Add-ons -> Install_ and select the downloaded ZIP file. Then enable the add-on. -3) In the add-on preference, click the '_Install dependencies_' button (this -requires an internet connection and might take a while). - -By installing those dependencies, be aware of -[Microsoft conditions](https://github.com/microsoft/onnxruntime/blob/master/docs/Privacy.md). -This add-on use available APIs to disable telemetry. +3) In the add-on preference, click the '_Install dependencies_' button (this requires an internet connection and might take a while). +By installing those dependencies, be aware of [Microsoft conditions](https://github.com/microsoft/onnxruntime/blob/master/docs/Privacy.md). This add-on use available APIs to disable telemetry. # Usage Check the [blog post](https://hugotini.github.io/deepbump) first video. -In the Shader Editor, select an _Image Texture Node_ and -click _Generate Normal Map_ in the right panel under -the _DeepBump_ tab. +In the Shader Editor, in the right panel under the _DeepBump_ tab: + +**Color (albedo) → Normals** : Select a color image node and click _Generate Normal Map_. + +**Normals → Height (displacement)** : Select the generated normal map image node and click _Generate Height Map_. -(For advanced usage, see [cli.md](cli.md) for the command-line interface.) +**Normals → Curvature** : Select the generated normal map image node and click _Generate Curvature Map_. # License