Skip to content

Commit

Permalink
doc notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhertz committed Nov 30, 2023
1 parent cb667bd commit 4d2e02f
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 22 deletions.
6 changes: 3 additions & 3 deletions style_aligned_sdxl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@
"outputs": [],
"source": [
"# run StyleAligned\n",
"\n",
"sets_of_prompts = [\n",
" \"a toy train. macro photo. 3d game asset\",\n",
" \"a toy airplane. macro photo. 3d game asset\",\n",
" \"a toy bicycle. macro photo. 3d game asset\",\n",
" \"a toy car. macro photo. 3d game asset\",\n",
" \"a toy boat. macro photo. 3d game asset\",\n",
"] \n",
"g_cuda = torch.Generator(device='cuda')\n",
" \"a toy boat. macro photo. 3d game asset\",\n",
"]\n",
"images = pipeline(sets_of_prompts,).images\n",
"mediapy.show_images(images)"
]
Expand Down
54 changes: 43 additions & 11 deletions style_aligned_w_controlnet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
{
"cell_type": "markdown",
"id": "f86ede39-8d9f-4da9-bc12-955f2fddd484",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Copyright 2023 Google LLC"
]
Expand All @@ -12,7 +16,11 @@
"cell_type": "code",
"execution_count": null,
"id": "3f3cbf47-a52b-48b1-9bd3-3435f92f2174",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# Copyright 2023 Google LLC\n",
Expand All @@ -33,7 +41,11 @@
{
"cell_type": "markdown",
"id": "22de629b-581f-4335-9e7b-f73221d8dbcb",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# ControlNet depth with StyleAligned over SDXL"
]
Expand All @@ -42,7 +54,11 @@
"cell_type": "code",
"execution_count": null,
"id": "486b7ebb-c483-4bf0-ace8-f8092c2d1f23",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL\n",
Expand All @@ -58,7 +74,11 @@
"cell_type": "code",
"execution_count": null,
"id": "2a7e85e7-b5cf-45b2-946a-5ba1e4923586",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# init models\n",
Expand Down Expand Up @@ -98,7 +118,11 @@
"cell_type": "code",
"execution_count": null,
"id": "94ca26b4-9061-4012-9400-8d97ef212d87",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# get depth maps\n",
Expand All @@ -113,7 +137,11 @@
"cell_type": "code",
"execution_count": null,
"id": "c8f56fe4-559f-49ff-a2d8-460dcfeb56a0",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# run ControlNet depth with StyleAligned\n",
Expand All @@ -122,9 +150,9 @@
"target_prompts = [\"a train in flat design style\", \"the sun in flat design style\"]\n",
"controlnet_conditioning_scale = 0.8\n",
"num_images_per_prompt = 3 # adjust according to VRAM size\n",
"# latents = torch.randn(1 + num_images_per_prompt, 4, 128, 128).to(pipeline.unet.dtype)\n",
"latents[1:] = torch.randn(num_images_per_prompt, 4, 128, 128).to(pipeline.unet.dtype)\n",
"latents = torch.randn(1 + num_images_per_prompt, 4, 128, 128).to(pipeline.unet.dtype)\n",
"for deph_map, target_prompt in zip((depth_image1, depth_image2), target_prompts):\n",
" latents[1:] = torch.randn(num_images_per_prompt, 4, 128, 128).to(pipeline.unet.dtype)\n",
" images = pipeline_calls.controlnet_call(pipeline, [reference_prompt, target_prompt],\n",
" image=deph_map,\n",
" num_inference_steps=50,\n",
Expand All @@ -139,7 +167,11 @@
"cell_type": "code",
"execution_count": null,
"id": "437ba4bd-6243-486b-8ba5-3b7cd661d53a",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": []
}
Expand All @@ -165,4 +197,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
46 changes: 38 additions & 8 deletions style_aligned_w_multidiffusion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
{
"cell_type": "markdown",
"id": "50fa980f-1bae-40c1-a1f3-f5f89bef60d3",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Copyright 2023 Google LLC"
]
Expand All @@ -12,7 +16,11 @@
"cell_type": "code",
"execution_count": null,
"id": "5da5f038-057f-4475-a783-95660f98238c",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# Copyright 2023 Google LLC\n",
Expand All @@ -33,7 +41,11 @@
{
"cell_type": "markdown",
"id": "c3a7c069-c441-4204-a905-59cbd9edc13a",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# MultiDiffusion with StyleAligned over SD v2"
]
Expand All @@ -42,7 +54,11 @@
"cell_type": "code",
"execution_count": null,
"id": "14178de7-d4c8-4881-ac1d-ff84bae57c6f",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import torch\n",
Expand All @@ -56,7 +72,11 @@
"cell_type": "code",
"execution_count": null,
"id": "738cee0e-4d6e-4875-b4df-eadff6e27e7f",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# init models\n",
Expand All @@ -81,9 +101,15 @@
"cell_type": "code",
"execution_count": null,
"id": "ea61e789-2814-4820-8ae7-234c3c6640a0",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# run MultiDiffusion with StyleAligned\n",
"\n",
"reference_prompt = \"a beautiful papercut art design\"\n",
"target_prompts = [\"mountains in a beautiful papercut art design\", \"giraffes in a beautiful papercut art design\"]\n",
"view_batch_size = 25 # adjust according to VRAM size\n",
Expand All @@ -97,7 +123,11 @@
"cell_type": "code",
"execution_count": null,
"id": "791a9b28-f0ce-4fd0-9f3c-594281c2ae56",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": []
}
Expand All @@ -123,4 +153,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}

0 comments on commit 4d2e02f

Please sign in to comment.