Skip to content

Commit

Permalink
Add web demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterouZh committed Oct 27, 2021
1 parent aee4025 commit e62f0bc
Show file tree
Hide file tree
Showing 5 changed files with 381 additions and 2 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cd CIPS-3D
conda create -y --name cips3d python=3.6.7
conda activate cips3d

pip install torch==1.8.2+cu102 torchvision==0.9.2+cu102 torchaudio==0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
pip install torch==1.8.2+cu102 torchvision==0.9.2+cu102 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html

pip install --no-cache-dir tl2==0.0.3
pip install --no-cache-dir -r requirements.txt
Expand All @@ -60,11 +60,26 @@ pip install -e pytorch_ema_lib


## Model interpolation demo
```bash

A web script:
```bash
streamlit run --server.port 8650 -- scripts/web_demo.py \
--outdir results/model_interpolation \
--cfg_file configs/web_demo.yaml \
--command model_interpolation

```
Then open the browser: `http://your_ip_address:8650`.

You can debug the script with this command:
```bash
python scripts/web_demo.py \
--outdir results/model_interpolation \
--cfg_file configs/web_demo.yaml \
--command model_interpolation \
--debug True

```

## Training

Expand Down
79 changes: 79 additions & 0 deletions configs/web_demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
network_pkl: &network_pkl
- "FFHQ_r256: datasets/pretrained/G_ema_ffhq.pth"

target_network_pkl: &target_network_pkl
- "Cartoon_r256: datasets/pretrained/G_ema_cartoon.pth"


G_cfg_3D2D: &G_cfg_3D2D
register_modules:
- exp.dev.nerf_inr.models.generator_nerf_inr_v16
name: exp.dev.nerf_inr.models.generator_nerf_inr_v16.GeneratorNerfINR
z_dim: 256
nerf_cfg:
in_dim: 3
# hidden_dim: 256
hidden_dim: 128
hidden_layers: 2
rgb_dim: 32
# style_dim: 256
style_dim: 128
mapping_nerf_cfg:
z_dim: 256
# hidden_dim: 256
hidden_dim: 128
base_layers: 4
head_layers: 0
inr_cfg:
input_dim: 32
# style_dim: 256
# hidden_dim: 256
style_dim: 512
hidden_dim: 512
# pre_rgb_dim: 32
pre_rgb_dim: 3
mapping_inr_cfg:
z_dim: 512
# hidden_dim: 256
hidden_dim: 512
# base_layers: 4
base_layers: 8
head_layers: 0
norm_out: true


model_interpolation:
mode:
- model_interpolation
model_interpolation:
G_cfg: *G_cfg_3D2D
network_pkl: *network_pkl
target_network_pkl: *target_network_pkl
swapped_layers: [1024, 512, 256, 128, 64, 32, 16, 8, 4]
gamma_target: 0.4
metadata: "datasets/pretrained/metadata.json"
num_steps: 24
image_size: 512
psi: 0.95
trajectory_mode:
- circle_near_far
- translate_circle_near_far
- circle
- yaw
seeds_gallery:
- 72216891
- 88542011
- 92577341
- 86271113
- 92674084
- 578916
- 99738897
- 99860786
- 354348
fps: 40
num_frames: 70
num_samples_translate: 30
fov: 12
max_fov: 20
alpha_pi_div: 15
forward_points: 256
Empty file added datasets/pretrained/.gitignore
Empty file.
43 changes: 43 additions & 0 deletions datasets/pretrained/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"batch_size": 4,
"num_steps": 12,
"img_size": 256,
"batch_split": 1,
"gen_lr": 5e-05,
"disc_lr": 0.0001,
"dataset_path": "",
"fov": 12,
"ray_start": 0.88,
"ray_end": 1.12,
"fade_steps": 10000,
"h_stddev": 0.3,
"v_stddev": 0.155,
"h_mean": 1.5707963267948966,
"v_mean": 1.5707963267948966,
"sample_dist": "gaussian",
"topk_interval": 2000,
"topk_v": 0.0,
"betas": [
0,
0.999
],
"unique_lr": false,
"weight_decay": 0,
"r1_lambda": 10.0,
"latent_dim": 256,
"grad_clip": 10,
"model": "SPATIALSIRENBASELINE",
"generator": "ImplicitGenerator3d",
"discriminator": "CCSEncoderDiscriminator",
"dataset": "FFHQ",
"clamp_mode": "relu",
"z_dist": "gaussian",
"hierarchical_sample": true,
"z_lambda": 0,
"pos_lambda": 0.0,
"last_back": false,
"eval_last_back": true,
"horizontal_flip": true,
"image_list_file": "datasets/ffhq/ffhq_256.txt",
"nerf_noise": 0
}
Loading

0 comments on commit e62f0bc

Please sign in to comment.