min-dalle-test/min_dalle.ipynb

175 lines
166 KiB
Plaintext
Raw Normal View History

2022-06-28 00:58:17 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
2022-07-01 22:16:55 +00:00
"colab_type": "text",
"id": "view-in-github"
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-01 21:34:23 +00:00
"execution_count": null,
2022-06-28 00:58:17 +00:00
"metadata": {
"cellView": "code",
2022-07-01 21:34:23 +00:00
"id": "ix_xt4X1_6F4"
2022-06-28 00:58:17 +00:00
},
2022-07-01 21:34:23 +00:00
"outputs": [],
2022-06-28 00:58:17 +00:00
"source": [
2022-07-01 21:34:23 +00:00
"! pip install min-dalle"
2022-06-28 00:58:17 +00:00
]
},
{
"cell_type": "markdown",
2022-06-30 15:25:24 +00:00
"metadata": {
"id": "kViq2dMbGDKt"
},
"source": [
"### Load Model"
2022-06-30 15:25:24 +00:00
]
},
{
"cell_type": "code",
2022-07-01 21:36:21 +00:00
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
2022-06-30 15:25:24 +00:00
},
"id": "8W-L2ICFGFup",
2022-07-01 21:34:23 +00:00
"outputId": "ed475d82-77e2-437e-acde-6a3e058a3885"
},
"outputs": [
{
2022-07-01 21:34:23 +00:00
"name": "stdout",
2022-07-01 22:16:55 +00:00
"output_type": "stream",
"text": [
"initializing MinDalleTorch\n",
2022-07-01 21:34:23 +00:00
"downloading tokenizer params\n",
"intializing TextTokenizer\n",
"downloading encoder params\n",
"initializing DalleBartEncoderTorch\n",
2022-07-01 21:34:23 +00:00
"downloading decoder params\n",
"initializing DalleBartDecoderTorch\n",
2022-07-01 21:34:23 +00:00
"downloading detokenizer params\n",
"initializing VQGanDetokenizer\n"
]
}
2022-06-30 15:25:24 +00:00
],
"source": [
"from min_dalle import MinDalle\n",
2022-06-30 15:25:24 +00:00
"\n",
"model = MinDalle(is_mega=True, is_reusable=True)"
]
},
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-01 21:36:21 +00:00
"execution_count": null,
2022-06-28 00:58:17 +00:00
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
2022-07-01 01:23:15 +00:00
"height": 511
2022-06-28 15:05:59 +00:00
},
"id": "nQ0UG05dA4p2",
2022-07-01 21:34:23 +00:00
"outputId": "de43cd92-253c-431e-c8c2-26ccd2631925"
2022-06-28 00:58:17 +00:00
},
"outputs": [
{
2022-07-01 21:34:23 +00:00
"name": "stdout",
2022-07-01 22:16:55 +00:00
"output_type": "stream",
2022-06-28 00:58:17 +00:00
"text": [
"tokenizing text\n",
2022-07-01 01:23:15 +00:00
"['Ġcctv']\n",
"['Ġof']\n",
"['Ġyoda']\n",
"['Ġrob', 'bing']\n",
"['Ġa']\n",
"['Ġliquor']\n",
"['Ġstore']\n",
"text tokens [0, 17685, 111, 24509, 976, 11811, 58, 13142, 1110, 2]\n",
2022-06-28 00:58:17 +00:00
"encoding text tokens\n",
"sampling image tokens\n",
"detokenizing image\n"
]
},
{
"data": {
2022-07-01 22:16:55 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAEAAElEQVR4nHT9x+9t25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KtAACgAzEUTFlFW5GkeBkFHgjBsy+v4+3hrevb0YGYxttuu/OfO65co3G33m2i33b1r3283h4KLbRTOd7uKV1Ee2aY9OBx1u/3BcAZMEy3Pi/LTnz1b3C7S3T7eR5v16vry9ofvfri6uguTbfx7DELcVFd3y10SmYaGGTFMXQBhju10Ush54BABLQZWcQUAlDdcN6x1tMwzkSW1ZjDJpWnrSqpWtKLCjol1XauaqmzK7X5dlCVgOhwMLvVh3TQG0zSGNcKqDwHABUJKKF5Wue94nm3+7JOfTQ8mp6eHjx6eahrhrdoup6NeR2f4YDpjjIECKVQYp1WLXb8zGg63d/Ob6zvg6PWTN4Href5ws0kWd+u723WWiS+/+vry8hXAFuOjn/z8i/PzcyHlbrOt8qrOqqbiALBfx0VWSpAdv9/v0KcPslev3jZtG4f1/Ga1T3eb9W6xWPz43cv5ImsEazkv23q13kNRdHtBJ/AoJkVRzW9X33//PQAkSXR0Oj46PsS65lhmXZZtXbdVZZkGUgqUlEpIIaTkSgoFAhEpobmbXwlo9elUfCA1Hce77Y7qu3DvurZl2hWvyqKosjBwTUJ6gasPOr6tM0PD986OsQIukIYY1XTP8S3TKua5Z1mB6yEsCVaWpvc7naePH4MC2+1iRQ9uV0+Th71VYJru4eGBZrht3WLKLGag3siyNMc1l
2022-06-28 00:58:17 +00:00
"text/plain": [
2022-07-01 21:34:23 +00:00
"<PIL.Image.Image image mode=RGB size=256x256 at 0x7F9624F58810>"
2022-07-01 22:16:55 +00:00
]
2022-06-28 00:58:17 +00:00
},
2022-07-01 22:16:55 +00:00
"metadata": {},
"output_type": "display_data"
2022-06-29 17:55:23 +00:00
},
{
2022-07-01 21:34:23 +00:00
"name": "stdout",
2022-07-01 22:16:55 +00:00
"output_type": "stream",
2022-06-29 17:55:23 +00:00
"text": [
2022-07-01 21:34:23 +00:00
"CPU times: user 7.39 s, sys: 4.41 ms, total: 7.39 s\n",
"Wall time: 7.35 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-01 01:23:15 +00:00
"text = \"cctv of yoda robbing a liquor store\" #@param {type:\"string\"}\n",
2022-07-01 18:19:35 +00:00
"seed = 0 #@param {type:\"integer\"}\n",
2022-06-28 15:05:59 +00:00
"\n",
2022-07-01 01:23:15 +00:00
"display(model.generate_image(text, seed))"
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-07-01 22:16:55 +00:00
"include_colab_link": true,
2022-06-30 15:25:24 +00:00
"name": "min-dalle",
2022-07-01 22:16:55 +00:00
"provenance": []
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-01 22:16:55 +00:00
}