diff --git a/aihub/deep-learning/dalle-flow/demo.ipynb b/aihub/deep-learning/dalle-flow/demo.ipynb new file mode 100644 index 00000000..c910009b --- /dev/null +++ b/aihub/deep-learning/dalle-flow/demo.ipynb @@ -0,0 +1,237 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 7, + "id": "74b1a73c-e487-4f3a-9c92-5c0ebf9c1426", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Looking in indexes: https://mirrors.tencent.com/pypi/simple/, https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple\n", + "Requirement already satisfied: docarray[common]>=0.13.5 in /usr/local/lib/python3.8/dist-packages (0.16.5)\n", + "Requirement already satisfied: jina in /usr/local/lib/python3.8/dist-packages (3.9.2)\n", + "Requirement already satisfied: rich>=12.0.0 in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (12.5.1)\n", + "Requirement already satisfied: numpy in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (1.22.1)\n", + "Requirement already satisfied: requests in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (2.27.1)\n", + "Requirement already satisfied: jina-hubble-sdk>=0.11.0 in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (0.17.1)\n", + "Requirement already satisfied: protobuf>=3.13.0 in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (4.21.6)\n", + "Requirement already satisfied: lz4 in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (4.0.2)\n", + "Requirement already satisfied: matplotlib in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (3.6.0)\n", + "Requirement already satisfied: Pillow in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (9.1.0)\n", + "Requirement already satisfied: fastapi in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (0.85.0)\n", + "Requirement already satisfied: uvicorn in /usr/local/lib/python3.8/dist-packages (from docarray[common]>=0.13.5) (0.18.3)\n", + "Requirement already satisfied: aiofiles in /usr/local/lib/python3.8/dist-packages (from jina) (22.1.0)\n", + "Requirement already satisfied: pyyaml>=5.3.1 in /usr/local/lib/python3.8/dist-packages (from jina) (5.4.1)\n", + "Requirement already satisfied: uvloop in /usr/local/lib/python3.8/dist-packages (from jina) (0.16.0)\n", + "Requirement already satisfied: python-multipart in /usr/local/lib/python3.8/dist-packages (from jina) (0.0.5)\n", + "Requirement already satisfied: aiostream in /usr/local/lib/python3.8/dist-packages (from jina) (0.4.5)\n", + "Requirement already satisfied: grpcio<1.48.1,>=1.46.0 in /usr/local/lib/python3.8/dist-packages (from jina) (1.47.0)\n", + "Requirement already satisfied: cryptography in /usr/local/lib/python3.8/dist-packages (from jina) (3.4.8)\n", + "Requirement already satisfied: pathspec in /usr/local/lib/python3.8/dist-packages (from jina) (0.9.0)\n", + "Requirement already satisfied: filelock in /usr/local/lib/python3.8/dist-packages (from jina) (3.8.0)\n", + "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.8/dist-packages (from jina) (21.3)\n", + "Requirement already satisfied: aiohttp in /usr/local/lib/python3.8/dist-packages (from jina) (3.8.1)\n", + "Requirement already satisfied: prometheus-client in /usr/local/lib/python3.8/dist-packages (from jina) (0.8.0)\n", + "Requirement already satisfied: pydantic in /usr/local/lib/python3.8/dist-packages (from jina) (1.9.2)\n", + "Requirement already satisfied: jcloud>=0.0.35 in /usr/local/lib/python3.8/dist-packages (from jina) (0.0.35)\n", + "Requirement already satisfied: grpcio-reflection<1.48.1,>=1.46.0 in /usr/local/lib/python3.8/dist-packages (from jina) (1.47.0)\n", + "Requirement already satisfied: docker in /usr/local/lib/python3.8/dist-packages (from jina) (6.0.0)\n", + "Requirement already satisfied: websockets in /usr/local/lib/python3.8/dist-packages (from jina) (10.1)\n", + "Requirement already satisfied: grpcio-health-checking<1.48.1,>=1.46.0 in /usr/local/lib/python3.8/dist-packages (from jina) (1.47.0)\n", + "Requirement already satisfied: starlette==0.20.4 in /usr/local/lib/python3.8/dist-packages (from fastapi->docarray[common]>=0.13.5) (0.20.4)\n", + "Requirement already satisfied: typing-extensions>=3.10.0 in /usr/local/lib/python3.8/dist-packages (from starlette==0.20.4->fastapi->docarray[common]>=0.13.5) (4.0.1)\n", + "Requirement already satisfied: anyio<5,>=3.4.0 in /usr/local/lib/python3.8/dist-packages (from starlette==0.20.4->fastapi->docarray[common]>=0.13.5) (3.5.0)\n", + "Requirement already satisfied: six>=1.5.2 in /usr/local/lib/python3.8/dist-packages (from grpcio<1.48.1,>=1.46.0->jina) (1.16.0)\n", + "Requirement already satisfied: python-dotenv in /usr/local/lib/python3.8/dist-packages (from jcloud>=0.0.35->jina) (0.21.0)\n", + "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.8/dist-packages (from aiohttp->jina) (5.2.0)\n", + "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.8/dist-packages (from aiohttp->jina) (1.2.0)\n", + "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.8/dist-packages (from aiohttp->jina) (1.7.2)\n", + "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.8/dist-packages (from aiohttp->jina) (21.4.0)\n", + "Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /usr/local/lib/python3.8/dist-packages (from aiohttp->jina) (2.0.10)\n", + "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.8/dist-packages (from aiohttp->jina) (1.3.0)\n", + "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.8/dist-packages (from aiohttp->jina) (4.0.2)\n", + "Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.8/dist-packages (from jina-hubble-sdk>=0.11.0->docarray[common]>=0.13.5) (4.12.0)\n", + "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.8/dist-packages (from packaging>=20.0->jina) (3.0.6)\n", + "Requirement already satisfied: pygments<3.0.0,>=2.6.0 in /usr/local/lib/python3.8/dist-packages (from rich>=12.0.0->docarray[common]>=0.13.5) (2.11.2)\n", + "Requirement already satisfied: commonmark<0.10.0,>=0.9.0 in /usr/local/lib/python3.8/dist-packages (from rich>=12.0.0->docarray[common]>=0.13.5) (0.9.1)\n", + "Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.8/dist-packages (from cryptography->jina) (1.15.0)\n", + "Requirement already satisfied: urllib3>=1.26.0 in /usr/local/lib/python3.8/dist-packages (from docker->jina) (1.26.12)\n", + "Requirement already satisfied: websocket-client>=0.32.0 in /usr/local/lib/python3.8/dist-packages (from docker->jina) (1.2.3)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/dist-packages (from requests->docarray[common]>=0.13.5) (2021.10.8)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.8/dist-packages (from requests->docarray[common]>=0.13.5) (3.3)\n", + "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.8/dist-packages (from matplotlib->docarray[common]>=0.13.5) (0.11.0)\n", + "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.8/dist-packages (from matplotlib->docarray[common]>=0.13.5) (2.8.2)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.8/dist-packages (from matplotlib->docarray[common]>=0.13.5) (1.0.5)\n", + "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.8/dist-packages (from matplotlib->docarray[common]>=0.13.5) (1.4.4)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.8/dist-packages (from matplotlib->docarray[common]>=0.13.5) (4.37.2)\n", + "Requirement already satisfied: h11>=0.8 in /usr/local/lib/python3.8/dist-packages (from uvicorn->docarray[common]>=0.13.5) (0.13.0)\n", + "Requirement already satisfied: click>=7.0 in /usr/local/lib/python3.8/dist-packages (from uvicorn->docarray[common]>=0.13.5) (8.0.3)\n", + "Requirement already satisfied: watchfiles>=0.13 in /usr/local/lib/python3.8/dist-packages (from uvicorn->docarray[common]>=0.13.5) (0.17.0)\n", + "Requirement already satisfied: httptools>=0.4.0 in /usr/local/lib/python3.8/dist-packages (from uvicorn->docarray[common]>=0.13.5) (0.5.0)\n", + "Requirement already satisfied: pycparser in /usr/local/lib/python3.8/dist-packages (from cffi>=1.12->cryptography->jina) (2.21)\n", + "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.8/dist-packages (from importlib-metadata->jina-hubble-sdk>=0.11.0->docarray[common]>=0.13.5) (3.8.1)\n", + "Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.8/dist-packages (from anyio<5,>=3.4.0->starlette==0.20.4->fastapi->docarray[common]>=0.13.5) (1.2.0)\n", + "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\n", + "\u001b[33mWARNING: You are using pip version 21.3.1; however, version 22.2.2 is available.\n", + "You should consider upgrading via the '/usr/bin/python -m pip install --upgrade pip' command.\u001b[0m\n" + ] + } + ], + "source": [ + "!pip install \"docarray[common]>=0.13.5\" jina" + ] + }, + { + "cell_type": "markdown", + "id": "e57713e5-c6ed-4dc9-959c-f812ae5d686b", + "metadata": {}, + "source": [ + "server_url是官方提供的服务,我们也可以按照文档,将模型部署到自己的服务器(需要有GPU)。" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd1ab908-d358-417f-a7d5-6a3b5bc7577b", + "metadata": {}, + "outputs": [], + "source": [ + "# !docker run -p 51005:51005 -it -v $HOME/.cache:/home/dalle/.cache --gpus all jinaai/dalle-flow" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "9a0b8fec-bef1-46f8-8bd7-6ea229b1fe76", + "metadata": {}, + "outputs": [], + "source": [ + "server_url = 'grpc://dalle-flow.jina.ai:51005'" + ] + }, + { + "cell_type": "markdown", + "id": "3de80bcb-33b2-45be-add3-b29c6d8add8e", + "metadata": {}, + "source": [ + "将文本提交到服务器,获得候选图片。" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "332f199f-498d-4dfa-871a-2b5e4732de27", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n",
+       "
\n" + ], + "text/plain": [ + "\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
ERROR  GRPCClient@1981 gRPC error: StatusCode.UNAVAILABLE failed to connect to all addresses    [09/21/22 21:52:07]\n",
+       "       The ongoing request is terminated as the server is not available or closed already.                         \n",
+       "
\n" + ], + "text/plain": [ + "\u001b[1;31mERROR \u001b[0m GRPCClient@\u001b[1;36m1981\u001b[0m gRPC error: StatusCode.UNAVAILABLE failed to connect to all addresses \u001b[2m[09/21/22 21:52:07]\u001b[0m\n", + " The ongoing request is terminated as the server is not available or closed already. \u001b[2m \u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Exception in thread Thread-17:\n", + "Traceback (most recent call last):\n", + " File \"/usr/lib/python3.8/threading.py\", line 932, in _bootstrap_inner\n", + " self.run()\n", + " File \"/usr/local/lib/python3.8/dist-packages/jina/helper.py\", line 1299, in run\n", + " self.result = asyncio.run(func(*args, **kwargs))\n", + " File \"/usr/lib/python3.8/asyncio/runners.py\", line 44, in run\n", + " return loop.run_until_complete(main)\n", + " File \"/usr/lib/python3.8/asyncio/base_events.py\", line 616, in run_until_complete\n", + " return future.result()\n", + " File \"/usr/local/lib/python3.8/dist-packages/jina/clients/mixin.py\", line 256, in _get_results\n", + " async for resp in c._get_results(*args, **kwargs):\n", + " File \"/usr/local/lib/python3.8/dist-packages/jina/clients/base/grpc.py\", line 119, in _get_results\n", + " raise ConnectionError(my_details) from None\n", + "ConnectionError: failed to connect to all addresses\n" + ] + }, + { + "ename": "BadClient", + "evalue": "something wrong when running the eventloop, result can not be retrieved", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "File \u001b[0;32m/usr/local/lib/python3.8/dist-packages/jina/helper.py:1314\u001b[0m, in \u001b[0;36mrun_async\u001b[0;34m(func, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1313\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1314\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mthread\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mresult\u001b[49m\n\u001b[1;32m 1315\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mAttributeError\u001b[39;00m:\n", + "\u001b[0;31mAttributeError\u001b[0m: '_RunThread' object has no attribute 'result'", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[0;31mBadClient\u001b[0m Traceback (most recent call last)", + "Input \u001b[0;32mIn [13]\u001b[0m, in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m prompt \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124ma teddy bear on a skateboard in Times Square\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mdocarray\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Document\n\u001b[0;32m----> 4\u001b[0m da \u001b[38;5;241m=\u001b[39m \u001b[43mDocument\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtext\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mprompt\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpost\u001b[49m\u001b[43m(\u001b[49m\u001b[43mserver_url\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mnum_images\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m}\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mmatches\n", + "File \u001b[0;32m/usr/local/lib/python3.8/dist-packages/docarray/document/mixins/sugar.py:92\u001b[0m, in \u001b[0;36mSingletonSugarMixin.post\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 89\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mdocarray\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m DocumentArray\n\u001b[1;32m 91\u001b[0m _tmp \u001b[38;5;241m=\u001b[39m DocumentArray(\u001b[38;5;28mself\u001b[39m)\n\u001b[0;32m---> 92\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_tmp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpost\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m[\u001b[38;5;241m0\u001b[39m]\n", + "File \u001b[0;32m/usr/local/lib/python3.8/dist-packages/docarray/array/mixins/post.py:109\u001b[0m, in \u001b[0;36mPostMixin.post\u001b[0;34m(self, host, show_progress, batch_size, parameters, **kwargs)\u001b[0m\n\u001b[1;32m 106\u001b[0m host \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparsed_host\u001b[38;5;241m.\u001b[39mport\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 108\u001b[0m c \u001b[38;5;241m=\u001b[39m Client(host\u001b[38;5;241m=\u001b[39mhost)\n\u001b[0;32m--> 109\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mc\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpost\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 110\u001b[0m \u001b[43m \u001b[49m\u001b[43mparsed_host\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mon\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 111\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 112\u001b[0m \u001b[43m \u001b[49m\u001b[43mshow_progress\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mshow_progress\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 113\u001b[0m \u001b[43m \u001b[49m\u001b[43mrequest_size\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbatch_size\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 114\u001b[0m \u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparameters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 115\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 116\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 117\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 118\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124munsupported scheme: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mscheme\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n", + "File \u001b[0;32m/usr/local/lib/python3.8/dist-packages/jina/clients/mixin.py:265\u001b[0m, in \u001b[0;36mPostMixin.post\u001b[0;34m(self, on, inputs, on_done, on_error, on_always, parameters, target_executor, request_size, show_progress, continue_on_error, return_responses, **kwargs)\u001b[0m\n\u001b[1;32m 262\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m return_results:\n\u001b[1;32m 263\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m result\n\u001b[0;32m--> 265\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mrun_async\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 266\u001b[0m \u001b[43m \u001b[49m\u001b[43m_get_results\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 267\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 268\u001b[0m \u001b[43m \u001b[49m\u001b[43mon_done\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mon_done\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 269\u001b[0m \u001b[43m \u001b[49m\u001b[43mon_error\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mon_error\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 270\u001b[0m \u001b[43m \u001b[49m\u001b[43mon_always\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mon_always\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 271\u001b[0m \u001b[43m \u001b[49m\u001b[43mexec_endpoint\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mon\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 272\u001b[0m \u001b[43m \u001b[49m\u001b[43mtarget_executor\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtarget_executor\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 273\u001b[0m \u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparameters\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 274\u001b[0m \u001b[43m \u001b[49m\u001b[43mrequest_size\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrequest_size\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 275\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 276\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m/usr/local/lib/python3.8/dist-packages/jina/helper.py:1318\u001b[0m, in \u001b[0;36mrun_async\u001b[0;34m(func, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1315\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mAttributeError\u001b[39;00m:\n\u001b[1;32m 1316\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mjina\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mexcepts\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m BadClient\n\u001b[0;32m-> 1318\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m BadClient(\n\u001b[1;32m 1319\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msomething wrong when running the eventloop, result can not be retrieved\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 1320\u001b[0m )\n\u001b[1;32m 1321\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 1323\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\n\u001b[1;32m 1324\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124myou have an eventloop running but not using Jupyter/ipython, \u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 1325\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mthis may mean you are using Jina with other integration? if so, then you \u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 1326\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmay want to use Client/Flow(asyncio=True). If not, then \u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 1327\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mplease report this issue here: https://github.com/jina-ai/jina\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 1328\u001b[0m )\n", + "\u001b[0;31mBadClient\u001b[0m: something wrong when running the eventloop, result can not be retrieved" + ] + } + ], + "source": [ + "prompt = 'a teddy bear on a skateboard in Times Square'\n", + "from docarray import Document\n", + "\n", + "da = Document(text=prompt).post(server_url, parameters={'num_images': 2}).matches" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b8841998-59bb-4cac-a91f-57aad2dff5da", + "metadata": {}, + "outputs": [], + "source": [ + "da.plot_image_sprites(fig_size=(10,10), show_index=True)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}