Skip to content

Commit

Permalink
Created using Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
nagolinc committed Jan 28, 2021
1 parent 472b0c3 commit 38eb780
Showing 1 changed file with 59 additions and 35 deletions.
94 changes: 59 additions & 35 deletions TADNE_and_CLIP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "TADNE and CLIP",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyMjRLnk3T9vEvD/iqPprPm9",
"authorship_tag": "ABX9TyOBS5xCzerK/UqQ3LviLL7+",
"include_colab_link": true
},
"kernelspec": {
Expand Down Expand Up @@ -3215,6 +3215,30 @@
"<a href=\"https://colab.research.google.com/github/nagolinc/notebooks/blob/main/TADNE_and_CLIP.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "xfzvteVuLjFn"
},
"source": [
"##readme\r\n",
"\r\n",
"This notebook was created by Logan Zoellner (@nagolinc, https://loganzoellner.com)\r\n",
"\r\n",
"\r\n",
"This notebook makes use of @AydaoAI's \"This Anime Does not exist\" (which you can read more about here: https://www.gwern.net/Faces#extended-stylegan2-danbooru2019-aydao) and CLIP (which you can read more about here https://github.com/openai/CLIP).\r\n",
"\r\n",
"Much of it was based off of this notebook: https://colab.research.google.com/github/openai/clip/blob/master/Interacting_with_CLIP.ipynb created by @openai\r\n",
"\r\n",
"And this notebook: https://colab.research.google.com/drive/1oxcJ1tbG77hlggdKd_d8h22nBcIZsLTL by @arfa\r\n",
"\r\n",
"TADNE is under a CC BY-NC liscence and CLIP is under the MIT Liscence.\r\n",
"\r\n",
"Any code in this notebook not otherwise liscenced is herein released under the MIT Liscence.\r\n",
"\r\n",
"\r\n"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -5429,7 +5453,7 @@
"text_probs = (image_features @ text_features.T).softmax(dim=0)#get best image for each label\r\n",
"top_probs, top_labels = text_probs.cpu().topk(5, dim=0)#top 5"
],
"execution_count": 138,
"execution_count": null,
"outputs": []
},
{
Expand Down Expand Up @@ -5473,7 +5497,7 @@
" pass\r\n",
" plt.axis('off')"
],
"execution_count": 140,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -5633,7 +5657,7 @@
"\r\n",
" return latent,scoreLatents,displayLatent"
],
"execution_count": 143,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -5650,7 +5674,7 @@
"latent,scoreLatents,displayLatent=doTheWork(26000)\r\n",
"display(displayLatent(latent))"
],
"execution_count": 145,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -5702,7 +5726,7 @@
" return v0\r\n",
" "
],
"execution_count": 199,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -5718,7 +5742,7 @@
"start=np.random.randn(*latent.shape)\r\n",
"result=optimize(start,scoreLatents,rounds=100,_density=1,_delta=1)"
],
"execution_count": 202,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -5770,7 +5794,7 @@
"display(displayLatent(start))\r\n",
"display(displayLatent(result))"
],
"execution_count": 203,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
Expand Down Expand Up @@ -5814,7 +5838,7 @@
"result=optimize(start,scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))\r\n"
],
"execution_count": 204,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -5878,7 +5902,7 @@
"source": [
""
],
"execution_count": 205,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
Expand Down Expand Up @@ -5936,7 +5960,7 @@
"[display(displayLatent(randomBatch[t])) for t in top5]\r\n",
"top5Latents=[randomBatch[t] for t in top5]"
],
"execution_count": 219,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
Expand Down Expand Up @@ -5991,7 +6015,7 @@
"[display(displayLatent(randomBatch[t])) for t in top5]\r\n",
"top5Latents=[randomBatch[t] for t in top5]"
],
"execution_count": 220,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6077,7 +6101,7 @@
"\r\n",
"result=optimize(top5Latents[-1],scoreLatents,rounds=100,_density=1,_delta=1)\r\n"
],
"execution_count": 222,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6137,7 +6161,7 @@
"source": [
"display(displayLatent(result))"
],
"execution_count": 223,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
Expand Down Expand Up @@ -6166,7 +6190,7 @@
"result=optimize(result,scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))"
],
"execution_count": 224,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6202,7 +6226,7 @@
"source": [
"display(displayLatent(result))"
],
"execution_count": 225,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
Expand Down Expand Up @@ -6235,7 +6259,7 @@
"result=optimize(start,scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))"
],
"execution_count": 227,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6322,7 +6346,7 @@
"result=optimize(result,scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))"
],
"execution_count": 228,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6386,7 +6410,7 @@
"result=optimize(start,scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))"
],
"execution_count": 229,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6488,7 +6512,7 @@
"result=optimize(start,scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))"
],
"execution_count": 231,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6575,7 +6599,7 @@
"result=optimize(start,scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))"
],
"execution_count": 236,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6696,7 +6720,7 @@
"[display(displayLatent(randomBatch[t])) for t in top5]\r\n",
"top5Latents=[randomBatch[t] for t in top5]"
],
"execution_count": 237,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
Expand Down Expand Up @@ -6798,7 +6822,7 @@
"result=optimize(top5Latents[3],scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))"
],
"execution_count": 238,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6865,7 +6889,7 @@
"result=optimize(start,scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))"
],
"execution_count": 245,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -6966,7 +6990,7 @@
"[display(displayLatent(randomBatch[t])) for t in top5]\r\n",
"top5Latents=[randomBatch[t] for t in top5]"
],
"execution_count": 246,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
Expand Down Expand Up @@ -7068,7 +7092,7 @@
"result=optimize(top5Latents[4],scoreLatents,rounds=100,_density=1,_delta=1)\r\n",
"display(displayLatent(result))"
],
"execution_count": 247,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -7191,7 +7215,7 @@
"\r\n",
"\r\n"
],
"execution_count": 293,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -7218,7 +7242,7 @@
"latent,scoreLatents,displayLatent=doTheWork(description=\"a girl covered in blood\",psi=2.0)\r\n",
"result=collapse(scoreLatents,n=100,k=10,rounds=100)\r\n"
],
"execution_count": 283,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -7285,7 +7309,7 @@
"source": [
"display(displayLatent(result))"
],
"execution_count": 284,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
Expand Down Expand Up @@ -7326,7 +7350,7 @@
"result=collapse(scoreLatents,n=100,k=20,rounds=40)\r\n",
"display(displayLatent(result))"
],
"execution_count": 287,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -7416,7 +7440,7 @@
"result=collapse(scoreLatents,n=100,k=20,rounds=40)\r\n",
"display(displayLatent(result))"
],
"execution_count": 291,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -7500,7 +7524,7 @@
"result=collapse(scoreLatents,n=100,k=20,rounds=40)\r\n",
"display(displayLatent(result))"
],
"execution_count": 292,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -7585,7 +7609,7 @@
"result=collapse(scoreLatents,n=100,k=20,rounds=40)\r\n",
"display(displayLatent(result))"
],
"execution_count": 294,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -7675,7 +7699,7 @@
"result=collapse(scoreLatents,n=1000,k=30,rounds=40)\r\n",
"display(displayLatent(result))"
],
"execution_count": 295,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down Expand Up @@ -7753,7 +7777,7 @@
"result=collapse(scoreLatents,n=400,k=20,rounds=40)\r\n",
"display(displayLatent(result))"
],
"execution_count": 310,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
Expand Down

0 comments on commit 38eb780

Please sign in to comment.