2022-06-28 00:58:17 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
2022-07-02 13:04:13 +00:00
"id": "view-in-github",
"colab_type": "text"
2022-06-28 00:58:17 +00:00
},
"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": [
2022-07-01 22:16:55 +00:00
"### Install"
2022-06-28 00:58:17 +00:00
]
},
{
"cell_type": "code",
2022-07-02 13:04:13 +00:00
"execution_count": 4,
2022-06-28 00:58:17 +00:00
"metadata": {
2022-06-30 14:02:08 +00:00
"cellView": "code",
2022-07-02 13:04:13 +00:00
"id": "ix_xt4X1_6F4",
"outputId": "f9cd1ba7-4681-471d-f4f5-129a581ca42e",
"colab": {
"base_uri": "https://localhost:8080/"
}
2022-06-28 00:58:17 +00:00
},
2022-07-02 13:04:13 +00:00
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Collecting min-dalle==0.2.9\n",
" Downloading min-dalle-0.2.9.tar.gz (10 kB)\n",
"Requirement already satisfied: torch>=1.10.0 in /usr/local/lib/python3.7/dist-packages (from min-dalle==0.2.9) (1.11.0+cu113)\n",
"Requirement already satisfied: typing_extensions>=4.1.0 in /usr/local/lib/python3.7/dist-packages (from min-dalle==0.2.9) (4.1.1)\n",
"Building wheels for collected packages: min-dalle\n",
" Building wheel for min-dalle (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for min-dalle: filename=min_dalle-0.2.9-py3-none-any.whl size=10790 sha256=95981af929f2d667a5279e988f51d4bbbc8a774ba8b3350aa99bc9812ab11cba\n",
" Stored in directory: /root/.cache/pip/wheels/f5/6a/2d/c0856f094be77d1a6a2d356dd9557ff6a7a6bc012856f83f03\n",
"Successfully built min-dalle\n",
"Installing collected packages: min-dalle\n",
" Attempting uninstall: min-dalle\n",
" Found existing installation: min-dalle 0.2.8\n",
" Uninstalling min-dalle-0.2.8:\n",
" Successfully uninstalled min-dalle-0.2.8\n",
"Successfully installed min-dalle-0.2.9\n"
]
}
],
2022-06-28 00:58:17 +00:00
"source": [
2022-07-02 13:04:13 +00:00
"! pip install min-dalle>=0.2.9"
2022-06-28 00:58:17 +00:00
]
},
2022-06-29 13:43:42 +00:00
{
"cell_type": "markdown",
2022-06-30 15:25:24 +00:00
"metadata": {
"id": "kViq2dMbGDKt"
},
2022-06-29 13:43:42 +00:00
"source": [
2022-07-01 00:55:42 +00:00
"### Load Model"
2022-06-30 15:25:24 +00:00
]
2022-06-29 13:43:42 +00:00
},
{
"cell_type": "code",
2022-07-02 13:04:13 +00:00
"execution_count": 1,
2022-06-29 13:43:42 +00:00
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
2022-06-30 15:25:24 +00:00
},
"id": "8W-L2ICFGFup",
2022-07-02 13:04:13 +00:00
"outputId": "fad4b4c4-b66b-435e-aa81-af3e874ef7ce"
2022-06-29 13:43:42 +00:00
},
"outputs": [
{
2022-07-01 22:16:55 +00:00
"output_type": "stream",
2022-07-02 13:04:13 +00:00
"name": "stdout",
2022-06-29 13:43:42 +00:00
"text": [
2022-07-02 13:04:13 +00:00
"initializing MinDalle\n",
2022-07-01 21:34:23 +00:00
"intializing TextTokenizer\n",
2022-07-02 13:04:13 +00:00
"initializing DalleBartEncoder\n",
"initializing DalleBartDecoder\n",
2022-06-30 19:17:35 +00:00
"initializing VQGanDetokenizer\n"
2022-06-29 13:43:42 +00:00
]
}
2022-06-30 15:25:24 +00:00
],
"source": [
2022-07-01 23:44:24 +00:00
"from min_dalle import MinDalle\n",
2022-06-30 15:25:24 +00:00
"\n",
2022-07-01 23:44:24 +00:00
"model = MinDalle(is_mega=True, is_reusable=True)"
2022-06-29 13:43:42 +00:00
]
},
2022-06-28 00:58:17 +00:00
{
"cell_type": "markdown",
2022-06-28 15:01:31 +00:00
"metadata": {
2022-06-28 15:05:59 +00:00
"id": "c52TV1GbBNgS"
},
"source": [
2022-07-02 10:34:47 +00:00
"### Generate Images"
2022-06-28 15:05:59 +00:00
]
2022-06-28 00:58:17 +00:00
},
{
"cell_type": "code",
2022-07-02 13:04:13 +00:00
"execution_count": 6,
2022-06-28 00:58:17 +00:00
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
2022-07-02 13:04:13 +00:00
"height": 884
2022-06-28 15:05:59 +00:00
},
"id": "nQ0UG05dA4p2",
2022-07-02 13:04:13 +00:00
"outputId": "c75050e2-d128-4d3d-817c-c3c9ccd61746"
2022-06-28 00:58:17 +00:00
},
"outputs": [
{
2022-07-01 22:16:55 +00:00
"output_type": "stream",
2022-07-02 13:04:13 +00:00
"name": "stdout",
2022-06-28 00:58:17 +00:00
"text": [
"tokenizing text\n",
2022-07-02 13:04:13 +00:00
"['Ġtrail']\n",
"['Ġcam']\n",
"['Ġfootage']\n",
2022-07-01 01:23:15 +00:00
"['Ġof']\n",
2022-07-02 13:04:13 +00:00
"['Ġgoll', 'um']\n",
"['Ġeating']\n",
"['Ġwatermelon']\n",
"text tokens [0, 1737, 904, 8271, 111, 39831, 140, 7077, 16927, 2]\n",
2022-06-28 00:58:17 +00:00
"encoding text tokens\n",
"sampling image tokens\n",
"detokenizing image\n"
]
},
{
2022-07-02 13:04:13 +00:00
"output_type": "display_data",
2022-06-28 00:58:17 +00:00
"data": {
"text/plain": [
2022-07-02 13:04:13 +00:00
"<PIL.Image.Image image mode=RGB size=768x768 at 0x7F655DB42B10>"
],
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAwAAAAMACAIAAAAc45fZAAEAAElEQVR4nOz917okubUmCC4BYcLFFqFSURxRp7q7vp6uuZoXn6t+hZnp6i7RVUfx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pHpQ4w6WijIL5y6nLD3Cm+Jg50PxQJpRW6kZCyHDAUFMHCElJVef+Aeq8P8eZP5qgF5IiIBpAhYPGjgozESGhUooJhJytTGuZzb7bi8iu6xNko7C72YUhvP1v//Ti/PnqrK0XjQGyQMbZ4Bywcb4au5EoL09OEDiMnaDWvlUCUHS2qkytwlkDK11db/b7nYAsFot9P8QQAeT5+cvKuTev395c3IjIs7MTa13T1KR6eXFhnF+3555N1djtzdilcd02q5N146sQ+j7EulqkGLfbXb/vRLhq6mZRv/zklbGmbdu/+fWv//Gf/2Xshq/+7atf/M3nCNhUday8Id7tbnLKzloFPXt2BqpV3a7WayK2zly/ueyhu+62lj0r5zG+fP7y8voqV1k0d2MchhEV4hDZ2t12Z6xZtM0YxjimlJIxZK01hjRpJjVMioJCIY25FwPOV/WQch7fa4NxvIN/mua5Iz9o/N6fDO/oJeiRYsfdoBkNwAwOPjCB/KcnBwz0PoLvsin3+Z47iASPSj5I+Rx/9XQZePwt+iB44EGSBd+9l+NWyttinujE8eM43OFxmadHBdx7mn85oOeOKJQ9DhIyEKpMKuy/YqBjyZKssQxsyBBx+igEGTIjKgEIoJAY0YSANKGbovLJZSVHQ
2022-06-28 00:58:17 +00:00
},
2022-07-02 13:04:13 +00:00
"metadata": {}
2022-06-29 17:55:23 +00:00
},
{
2022-07-01 22:16:55 +00:00
"output_type": "stream",
2022-07-02 13:04:13 +00:00
"name": "stdout",
2022-06-29 17:55:23 +00:00
"text": [
2022-07-02 13:04:13 +00:00
"CPU times: user 35.2 s, sys: 103 ms, total: 35.3 s\n",
"Wall time: 34.9 s\n"
2022-06-29 17:55:23 +00:00
]
2022-06-28 00:58:17 +00:00
}
2022-06-28 15:05:59 +00:00
],
"source": [
2022-06-29 17:55:23 +00:00
"%%time\n",
"\n",
2022-07-02 13:04:13 +00:00
"text = \"trail cam footage of gollum eating watermelon\" #@param {type:\"string\"}\n",
"seed = 1 #@param {type:\"integer\"}\n",
"grid_size = 3 #@param {type:\"integer\"}\n",
2022-06-28 15:05:59 +00:00
"\n",
2022-07-02 13:04:13 +00:00
"display(model.generate_image(text, seed, grid_size))"
2022-06-28 00:58:17 +00:00
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
2022-06-28 15:05:59 +00:00
"collapsed_sections": [
"Zl_ZFisFApeh"
],
2022-06-30 15:25:24 +00:00
"name": "min-dalle",
2022-07-02 13:04:13 +00:00
"provenance": [],
"include_colab_link": true
2022-06-28 00:58:17 +00:00
},
"gpuClass": "standard",
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
2022-07-02 13:04:13 +00:00
}