2022-06-28 00:58:17 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {
|
2022-06-29 02:12:36 +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": [
|
|
|
|
"### Setup"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-06-28 16:16:44 +00:00
|
|
|
"execution_count": null,
|
2022-06-28 00:58:17 +00:00
|
|
|
"metadata": {
|
2022-06-28 16:16:44 +00:00
|
|
|
"id": "ix_xt4X1_6F4",
|
2022-06-29 02:12:36 +00:00
|
|
|
"cellView": "code"
|
2022-06-28 00:58:17 +00:00
|
|
|
},
|
2022-06-28 16:16:44 +00:00
|
|
|
"outputs": [],
|
2022-06-28 00:58:17 +00:00
|
|
|
"source": [
|
|
|
|
"! git clone https://github.com/kuprel/min-dalle\n",
|
2022-06-29 02:12:36 +00:00
|
|
|
"! mkdir -p /content/min-dalle/pretrained/vqgan/\n",
|
|
|
|
"! curl https://huggingface.co/dalle-mini/vqgan_imagenet_f16_16384/resolve/main/flax_model.msgpack -L --output /content/min-dalle/pretrained/vqgan/flax_model.msgpack\n",
|
2022-06-28 15:01:31 +00:00
|
|
|
"! pip install torch flax==0.4.2 wandb\n",
|
2022-06-28 13:19:52 +00:00
|
|
|
"! wandb login --anonymously\n",
|
2022-06-29 02:12:36 +00:00
|
|
|
"! wandb artifact get --root=/content/min-dalle/pretrained/dalle_bart_mini dalle-mini/dalle-mini/mini-1:v0\n"
|
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": [
|
|
|
|
"### Generate an Image"
|
|
|
|
]
|
2022-06-28 00:58:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2022-06-29 10:25:52 +00:00
|
|
|
"execution_count": null,
|
2022-06-28 00:58:17 +00:00
|
|
|
"metadata": {
|
|
|
|
"colab": {
|
|
|
|
"base_uri": "https://localhost:8080/",
|
2022-06-29 02:12:36 +00:00
|
|
|
"height": 443
|
2022-06-28 15:05:59 +00:00
|
|
|
},
|
|
|
|
"id": "nQ0UG05dA4p2",
|
2022-06-29 02:12:36 +00:00
|
|
|
"outputId": "1dc67911-7ac1-40e9-92e5-24fbdb8bb8ba"
|
2022-06-28 00:58:17 +00:00
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
2022-06-28 16:16:44 +00:00
|
|
|
"output_type": "stream",
|
2022-06-29 02:12:36 +00:00
|
|
|
"name": "stdout",
|
2022-06-28 00:58:17 +00:00
|
|
|
"text": [
|
|
|
|
"parsing metadata from ./pretrained/dalle_bart_mini\n",
|
|
|
|
"tokenizing text\n",
|
2022-06-29 02:12:36 +00:00
|
|
|
"['Ġartificial']\n",
|
|
|
|
"['Ġintelligence']\n",
|
|
|
|
"text tokens [0, 6316, 7815, 2]\n",
|
|
|
|
"loading torch encoder\n",
|
2022-06-28 00:58:17 +00:00
|
|
|
"encoding text tokens\n",
|
2022-06-29 02:12:36 +00:00
|
|
|
"loading torch decoder\n",
|
2022-06-28 00:58:17 +00:00
|
|
|
"sampling image tokens\n",
|
|
|
|
"detokenizing image\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
2022-06-29 02:12:36 +00:00
|
|
|
"output_type": "display_data",
|
2022-06-28 00:58:17 +00:00
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2022-06-29 02:12:36 +00:00
|
|
|
"<PIL.Image.Image image mode=RGB size=256x256 at 0x7FA4DCA899D0>"
|
|
|
|
],
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAEAAElEQVR4nDz9Z9y22VUXDP/X2nsf7WxXL3e/p7dkkkmbJKQBCYT6IAEVEURQxPdR8VF8/Vmx/NRHEXn1QRRUpAcIQVp6zGQyKTOZ3u977t6ufp39aHvvtd4P1/Ccn45Px/llH2uv9W+LegADhiECxus/IoCgDgQDhQIEVQIpRYAjhBjGKcQaUhEiJhgQkyICpCrKRGJZoTEQk8kMGRVSC2ajAtVoVAVGXUFK0MAkIAN2xABIAJAlNSQtWxEkAZl1mYCFLFhE1DIhNi5xIhB2bJ0gCqwxJoZATD4Ycql1rvWeiUFGNGaOgqAVZHkn1mpNaMFBDUhDE5M8n9dSZEZAUdJOx6bSTod7ddto0k0SVlGB73QKa3hyOKqmcvzeOzqIF199MWoNLlxR+LIyeZobXlvfKCfVwfbFTj9Lk6Kl9Oy997741cfb0bhzdnM+b0BJb1BMD6oPfv/379+4+cwffqp/vDepA9IV1899WSf9laLoBmrzBbu3U2FUIQSECt0B5iX6DpQPllfj5Mrs8HreX1nbOHH1xYv5cl5NI5o5shwgQJAvrB3f8MFa0GCg072ruzduZKkjlTLYLKV6Vi6ur7bToXitYnf99B2pTA73DohZ0SAxeZbu7+wZVo02Ec1trPy8DWwT6zIzr+bOSmZMPZ6fOHV6dLg3Gc1iCFknq+Zl6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NYpO6F565yVbadjpe6kxZF0b98cc+tlMYW3cWuonvnN37j+z7whj/8+d/Y3bpZGJstde99+5v+6o9/8HDf377iKuDi1ek9p
|
2022-06-28 00:58:17 +00:00
|
|
|
},
|
2022-06-29 02:12:36 +00:00
|
|
|
"metadata": {}
|
2022-06-28 00:58:17 +00:00
|
|
|
}
|
2022-06-28 15:05:59 +00:00
|
|
|
],
|
|
|
|
"source": [
|
2022-06-29 02:12:36 +00:00
|
|
|
"text = \"artificial intelligence\" #@param {type:\"string\"}\n",
|
|
|
|
"seed = 0#@param {type:\"integer\"}\n",
|
|
|
|
"torch = True #@param {type:\"boolean\"}\n",
|
2022-06-28 15:05:59 +00:00
|
|
|
"\n",
|
|
|
|
"import os\n",
|
|
|
|
"os.chdir('/content/min-dalle')\n",
|
|
|
|
"from min_dalle.generate_image import generate_image_from_text\n",
|
2022-06-29 02:12:36 +00:00
|
|
|
"image = generate_image_from_text(text, seed=seed, is_torch=torch)\n",
|
2022-06-28 15:05:59 +00:00
|
|
|
"display(image)"
|
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-28 16:16:44 +00:00
|
|
|
"name": "min-dalle",
|
2022-06-29 02:12:36 +00:00
|
|
|
"provenance": [],
|
|
|
|
"machine_shape": "hm",
|
2022-06-29 10:25:52 +00:00
|
|
|
"authorship_tag": "ABX9TyN7lVJ8zUP53XhtQzD7LrQp",
|
2022-06-29 02:12:36 +00:00
|
|
|
"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-06-29 02:12:36 +00:00
|
|
|
}
|