commit 3eb875d123aaf522ddab5974639d44691cf61833 Author: Benjamyn Love Date: Fri Dec 9 12:06:29 2022 +1100 first commit diff --git a/api requirements.txt b/api requirements.txt new file mode 100644 index 0000000..5439789 --- /dev/null +++ b/api requirements.txt @@ -0,0 +1,39 @@ +stable-diffusion python module + +docs - http://10.6.9.69:7860/docs + +testing api - http://10.6.9.69:7860/sdapi/v1 + +Needs to implement a class called DiffuseAPI + +The class needs be initialised with the following variables + - url - String + - nsfw_enabled - Boolean + - styles - List + - steps - Integer + +The class will need the following functions + - generate_image + - takes in a prompt and a negative_prompt (negative prompt will default to "") + - returns the base64 of the returned image or returns the error + + - set_seed + - takes in an integer and updates the seed in the payload with the provided seed + - set_steps + - takes in an integer and updates the steps in the payload with the provided steps + - set_cfg_scale + - takes in an integer and updates the cfg_scale in the payload with the provided cfg_scale + - set_styles + - takes in a list of strings and updates the styles in the payload with the provided styles + - set_orientation + - take in one of three options [portrait, landscape, square] and set the width and height in the payload accordingly + - get_orientation + - return the current orientation and heigh + width + - set_nsfw_filter + - takes in a bool and updates the nsfw filter accordingly + - get_nsfw_filter + - returns the current state of the nsfw filter + + - upscale_image + - takes in the image (in b64) and sends it to the upscale endpoint + - returns the upscaled image \ No newline at end of file diff --git a/testing.ipynb b/testing.ipynb new file mode 100644 index 0000000..f488cc2 --- /dev/null +++ b/testing.ipynb @@ -0,0 +1,109 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [], + "source": [ + "import requests\n", + "from IPython import display\n", + "from base64 import b64decode\n" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [], + "source": [ + "payload = {\n", + " \"prompt\": \"view from behind web developer sitting in a chair, sfw\",\n", + " \"styles\": [\"default\"],\n", + " \"steps\": 28,\n", + " \"seed\": -1,\n", + " \"n_iter\": 1,\n", + " \"height\": 1024,\n", + " \"negative_prompts\": \"nsfw, not safe for work, nudity, multiple keyboards\",\n", + " \"cfg_scale\": 12\n", + "}\n", + "\n", + "settings = {\n", + " \"filter_nsfw\": False,\n", + " \"samples_save\": True,\n", + "}\n", + "\n", + "override_payload = {\n", + " \"override_settings\": settings\n", + "}\n", + "\n", + "payload.update(override_payload)\n", + "\n", + "# url = \"https://art.jurydoak.com/sdapi/v1\"\n", + "url = \"http://localhost:7860/sdapi/v1\"" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x = requests.post(f\"{url}/txt2img\", json=payload)\n", + "img_html = []\n", + "for i in x.json()['images']:\n", + " img_html.append(f'')\n", + "\n", + "display.HTML(\"\\n\".join(img_html))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.10.8 64-bit", + "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.10.8" + }, + "orig_nbformat": 4, + "vscode": { + "interpreter": { + "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}