min-dalle-test/min_dalle.ipynb

132 lines
78 KiB
Plaintext
Raw Normal View History

2022-06-28 00:58:17 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/kuprel/min-dalle/blob/main/min_dalle.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3WL-G_f2_ld8"
},
"source": [
"# min(DALL·E)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Zl_ZFisFApeh"
},
"source": [
"### Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ix_xt4X1_6F4",
"cellView": "form"
},
"outputs": [],
"source": [
"#@title Setup\n",
"! pip install torch flax wandb\n",
"! git lfs install\n",
"! git clone https://github.com/kuprel/min-dalle\n",
"! git clone https://huggingface.co/dalle-mini/vqgan_imagenet_f16_16384 ./pretrained/vqgan\n",
"\n",
"import wandb\n",
"import os\n",
"\n",
"wandb.login()\n",
"os.chdir('min-dalle')\n",
"\n",
"! wandb artifact get --root=./pretrained/dalle_bart_mini dalle-mini/dalle-mini/mini-1:v0"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c52TV1GbBNgS"
},
"source": [
"### Generate an Image"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 480
},
"id": "nQ0UG05dA4p2",
"outputId": "30bfbe18-ccc0-4d1b-bbe3-a4c6f838067c"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"parsing metadata from ./pretrained/dalle_bart_mini\n",
"tokenizing text\n",
"['Ġalien']\n",
"['Ġlife']\n",
"text tokens [0, 8925, 742, 2]\n",
"loading flax encoder\n",
"encoding text tokens\n",
"loading flax decoder\n",
"sampling image tokens\n",
"image tokens [6965, 6172, 1052, 14447, 6172, 12062, 15771, 2193, 10710, 4147, 1052, 6172, 2528, 14447, 5772, 8447, 6965, 14447, 14447, 14447, 11665, 6879, 15798, 9479, 910, 15303, 5605, 7542, 1052, 14447, 14447, 2528, 6965, 1052, 14447, 6078, 3386, 2519, 12838, 16017, 867, 8447, 11993, 12426, 11196, 14447, 14447, 2528, 6965, 14447, 14447, 7491, 16147, 13512, 8269, 271, 10397, 15945, 15945, 4903, 12892, 14447, 14447, 2528, 6965, 14447, 14447, 351, 358, 10362, 6001, 8612, 14037, 7864, 14246, 5201, 2810, 14447, 14447, 2528, 6965, 14447, 14447, 10549, 15618, 11792, 13401, 16223, 1464, 12861, 6992, 572, 601, 14447, 14447, 2528, 6965, 14447, 14447, 14447, 13183, 194, 14633, 1994, 10912, 2778, 5495, 12187, 2528, 14447, 14447, 2528, 6965, 14447, 14447, 14447, 2528, 14068, 4054, 5071, 1948, 5286, 7771, 12062, 12016, 14447, 14447, 2528, 6965, 14447, 14447, 14447, 7504, 15433, 7781, 4816, 12062, 663, 3812, 8447, 8173, 14447, 14447, 2528, 6965, 14447, 14447, 6078, 13401, 6790, 2813, 10121, 4301, 4811, 5984, 3851, 8493, 14447, 14447, 2528, 6965, 14447, 14447, 4465, 12509, 4238, 12290, 10543, 8222, 11348, 13909, 5919, 6965, 14447, 14447, 2528, 11591, 14447, 6172, 11665, 9501, 2810, 9570, 7781, 910, 10549, 4395, 10639, 16147, 8173, 14164, 2528, 11591, 14164, 11993, 11610, 15891, 6242, 1936, 14602, 4903, 3583, 11574, 7516, 12892, 8173, 14447, 2528, 11591, 7467, 5243, 13157, 2810, 6790, 16017, 7236, 4301, 11725, 10689, 11941, 12659, 8173, 1052, 2528, 6965, 6598, 4465, 4816, 2895, 11820, 3132, 15917, 1811, 4904, 6933, 6690, 4811, 7504, 2528, 11605, 7467, 4815, 351, 6948, 10228, 7771, 9479, 9213, 11196, 6628, 9897, 12480, 5885, 14247, 5772, 5772]\n",
"detokenizing image\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"<PIL.Image.Image image mode=RGB size=256x256 at 0x7FD4B6712710>"
],
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAADagklEQVR4nMT9W7AtS3Ydho05s2qttfc+r3vuq/vevkCjQTS60QCBbpAgAQIkAQKgAMGUaFlSMBRhy+EIy//+95d/HPrRl8Pylx0O+8PhcIRsRThEWRZFMmDKlEyQEAFQaAFsoIG+3X1f57X3qso55/BHVtXKeqx99rndCGff3qdWVVZmVuZ8jJw5c6agSgIAICAAqzuLJGOeu6R1Ubzbi4tX1tUtSr57sbd/IFcFvmrLF/kX3cV5LfVbi0esXqnvyKt87J9FkjPX052XEs+5pyWV75Vbv1eqcdzMsPm0XCsQAMvTUlN82m49RysvTete4IpW1nW9tKL6E2T1SFZU9arMc0vapOl1qzZzTvm54s9Px+T//0p3IYA75RGA4/euSVMALolnkRZSox5ujP3cKETHH/PCh4tN+X37B9yFTM+18qX5pfqSus11OZuFnCOd29n+FiF0dx14rpZb5Ba2R3wjz13E1veLbTaFPeZdsSl0XlrOZl2futmbvYqqtUUD6Cj3zw7zQtO90pCv090/6XYWul181m/dIjs3+e2lXIQ5zd3SXXVLbvlwOU/x6zvnyrl7Cd+XdIt+vvvNcyj0jnLwXOLW9WJMCwMAcEAA3VQvt/ydin7Vzr0FnJxLL+3Tc0qw1mm3kAWrnKzuYHVnnbPOIFv5pxSr6s5Vca6R55p9x8/8/qZzxdaNeSk4wZaUOfct66FZZ153oLxM+pSktfJafMA5SSyrO3dPdwQ5mFPVpy62Jtn6S2V+gS0mr+HWupbNfmPV7+tadFXLunCu3pLVfzoWtahlUY6eafn3ntbUhnljbkeVmI/LVKbcoZCJ7WVLJJ1Twlw9mt6Vog4KJOL8hQUR1GoLK6r6vqTNL/9eqlg0chO6bN5ZP3ppLy8qWnR6Xc6aLjdHa829UzYdFcu6hM30fdcGa6rCmZFaSw1WH7V+5RbCXadF5vXNGAVBbeYpZTqQAEmjSehccxetub0r19n+LDikJ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2lUYiceYj3b5JcpjvfUH6a+l7hub7p7N8/s+vnN9bMXzz9+8fzZs5vrY+5yZAZMgUAkiEACQciAjua9cW6sb2eJxf3FW+cA59Tz58qRrVfqqte6ZY3BFgSw5t7ys9lsyi2qrZYZi6bf8uK6nPVbcu7xeFNwMime0+ZSPVs+mvfmQs8s2lO/pRVqCqIBQkEBicZwcW/3+N23P/uDn33wzoOHn73/4PUHr7/+6Or+bn9oDhcXjSIxQVoGSCPN4VDRhiJCIpQSEDjd0YQy6EY398yIYARcBZAMpweTa3ZPCN3bfhd2kBTt7lG7PzYXLy4uXzx4+Ozxi6fPX3x8ff38ur/ujzfXDBhYpIqOH7cwj8rq228ZSlld4AwVbv5dKwepni3KqWWTrG+OZpI1+61biy1Sb9YvLBq3KezvohzWPLcuX6pGcSTfyTI4vTPZgqafhR+G/pKqB0+dVcD5jNbrltS9piuJWF/7mF8T1JGBy4SrB/t7r91/+5133v78a5//gXdff/e1+w8v9w+ai8uG0ihEoBRxChQE0YBsAtg1rSA8Ike4IUAnQIkQD0FIzuHmfe/h7haU0BCHICQkTCXtdwQDFplB1/BWyJ0lstk3V5d677XUvXHx7MnVzccvXnzSHp8e+2POCAEJNtAAiLhFda+vN2l9IeMX8vsWySI4/R7u8GzmdXuWj26dKtQjPr0+XW9DoDUL1hdrHt3sqc1CFtdDcdN9ni508v3g6pVym6eLaYmkyjko+rXs8WXNy28pfxvA5s0Mx+Ei/cDn337jnbfeeO/td979zKPXH732+PDgwf3DVXNoRXchRGgADFBVBKpNSqoUgkpNCrgbPRoSq
},
"metadata": {}
}
],
"source": [
"from min_dalle.generate_image import generate_image_from_text\n",
"\n",
"image = generate_image_from_text(\"alien life\", seed=7)\n",
"display(image)"
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"name": "min-dalle",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyN4GmrxHSaJohIwh+MpDD4p",
"include_colab_link": true
},
"gpuClass": "standard",
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}