{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "pycharm": { "name": "#%%\n" }, "is_executing": true }, "outputs": [], "source": [ "import requests\n", "from PIL import Image\n", "import time\n", "from io import BytesIO\n", "\n", "prompt = \"a photograph of an astronaut riding a horse\"\n", "\n", "start = time.time()\n", "generate_response = requests.post(\"http://10.226.99.20:7979/stable_diffusion\", json={\"prompt\": prompt})\n", "end = time.time()\n", "\n", "im = Image.open(BytesIO(generate_response.content))\n", "im.show()\n", "print('----------------------')\n", "print(f'time cost : {end - start:.4f}s')\n" ] }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }