Skip to content

Commit

Permalink
add editing notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
avdravid authored Jun 13, 2024
1 parent ebca7cc commit 9770e62
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 22 deletions.
32 changes: 20 additions & 12 deletions editing/identity_editing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append('/nfs/amil/peft/examples/w2w/')\n",
"import os \n",
"sys.path.append(os.path.abspath(os.path.join(\"\", \"..\")))\n",
"import torch\n",
"import gc\n",
"import warnings\n",
Expand Down Expand Up @@ -52,13 +53,13 @@
"metadata": {},
"outputs": [],
"source": [
"mean = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/mean.pt\").bfloat16().to(device)\n",
"std = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/std.pt\").bfloat16().to(device)\n",
"v = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/V.pt\").bfloat16().to(device)\n",
"proj = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/proj_1000pc.pt\").bfloat16().to(device)\n",
"pinverse = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/pinverse_1000pc.pt\").bfloat16().to(device)\n",
"df = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/identity_df.pt\")\n",
"weight_dimensions = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/weight_dimensions.pt\")"
"mean = torch.load(\"../files/mean.pt\").bfloat16().to(device)\n",
"std = torch.load(\"../files/std.pt\").bfloat16().to(device)\n",
"v = torch.load(\"../files/V.pt\").bfloat16().to(device)\n",
"proj = torch.load(\"../files/proj_1000pc.pt\").bfloat16().to(device)\n",
"pinverse = torch.load(\"../files/pinverse_1000pc.pt\").bfloat16().to(device)\n",
"df = torch.load(\"../files/identity_df.pt\")\n",
"weight_dimensions = torch.load(\"../files/weight_dimensions.pt\")"
]
},
{
Expand Down Expand Up @@ -99,13 +100,20 @@
"## Load up Identity Model in *w2w* Space"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can load a model from the dataset of *w2w* weights (proj), or you can load up one of the models from sampling or inversion."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"weights0 = torch.load(\"/nfs/amil/peft/examples/w2w/output/real_inversion_w2w/w2wmodel.pt\").to(device)"
"weights0 = torch.load(\"../output/real_inversion_w2w/w2wmodel.pt\").to(device)"
]
},
{
Expand Down Expand Up @@ -143,7 +151,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -159,7 +167,7 @@
}
],
"source": [
"image = Image.open(\"/nfs/amil/peft/examples/w2w/inversion/images/real_image/real/im/43883.png\")\n",
"image = Image.open(\"../inversion/images/real_image/real/im/43883.png\")\n",
"image.show()"
]
},
Expand Down Expand Up @@ -461,7 +469,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.1.-1"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
28 changes: 18 additions & 10 deletions editing/multiple_edits.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
],
"source": [
"import sys\n",
"sys.path.append('/nfs/amil/peft/examples/w2w/')\n",
"import os \n",
"sys.path.append(os.path.abspath(os.path.join(\"\", \"..\")))\n",
"import torch\n",
"import gc\n",
"import warnings\n",
Expand Down Expand Up @@ -61,13 +62,13 @@
"metadata": {},
"outputs": [],
"source": [
"mean = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/mean.pt\").bfloat16().to(device)\n",
"std = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/std.pt\").bfloat16().to(device)\n",
"v = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/V.pt\").bfloat16().to(device)\n",
"proj = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/proj_1000pc.pt\").bfloat16().to(device)\n",
"pinverse = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/pinverse_1000pc.pt\").bfloat16().to(device)\n",
"df = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/identity_df.pt\")\n",
"weight_dimensions = torch.load(\"/nfs/amil/peft/examples/lora_dreambooth/evaluation/files/weight_dimensions.pt\")"
"mean = torch.load(\"../files/mean.pt\").bfloat16().to(device)\n",
"std = torch.load(\"../files/std.pt\").bfloat16().to(device)\n",
"v = torch.load(\"../files/V.pt\").bfloat16().to(device)\n",
"proj = torch.load(\"../files/proj_1000pc.pt\").bfloat16().to(device)\n",
"pinverse = torch.load(\"../files/pinverse_1000pc.pt\").bfloat16().to(device)\n",
"df = torch.load(\"../files/identity_df.pt\")\n",
"weight_dimensions = torch.load(\"../files/weight_dimensions.pt\")"
]
},
{
Expand Down Expand Up @@ -115,13 +116,20 @@
"## Load up Identity Model in *w2w* Space"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can load a model from the dataset of *w2w* weights (proj), or you can load up one of the models from sampling or inversion."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"weights0 = torch.load(\"/nfs/amil/peft/examples/w2w/output/real_inversion_w2w/w2wmodel.pt\").to(device)"
"weights0 = torch.load(\"../output/real_inversion_w2w/w2wmodel.pt\").to(device)"
]
},
{
Expand Down Expand Up @@ -175,7 +183,7 @@
}
],
"source": [
"image = Image.open(\"/nfs/amil/peft/examples/w2w/inversion/images/real_image/real/im/43883.png\")\n",
"image = Image.open(\"../inversion/images/real_image/real/im/43883.png\")\n",
"image.show()"
]
},
Expand Down

0 comments on commit 9770e62

Please sign in to comment.