{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "57421672", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import requests\n", "import time\n", "import urllib.parse as urlparse" ] }, { "cell_type": "code", "execution_count": 2, "id": "436f88be", "metadata": {}, "outputs": [], "source": [ "BASE_URL = \"https://ps6bzj7vlp0okc-3754.proxy.runpod.net/\"" ] }, { "cell_type": "code", "execution_count": 3, "id": "efe7ba74", "metadata": {}, "outputs": [], "source": [ "def txt2img(prompt: str, name: str):\n", " while True:\n", " try:\n", " url = urlparse.urljoin(BASE_URL, \"txt2img\")\n", " payload = {\n", " \"prompt\": prompt,\n", " \"negative_prompt\": None,\n", " \"width\": \"1024\",\n", " \"height\": \"1024\",\n", " \"samples\": 1,\n", " \"num_inference_steps\": \"8\",\n", " \"seed\": 1337,\n", " \"guidance_scale\": 3,\n", " \"safety_checker\": \"no\",\n", " }\n", "\n", " headers = {\"Content-Type\": \"application/x-www-form-urlencoded\"}\n", "\n", " response = requests.post(url, headers=headers, data=payload)\n", " response_json = response.json()\n", " link = response_json[\"links\"][0]\n", "\n", " time.sleep(2)\n", "\n", " response = requests.get(link, stream=True)\n", " \n", " while b\"\n", "\n", "
\n", " | Prompt | \n", "Category | \n", "Challenge | \n", "Note | \n", "
---|---|---|---|---|
0 | \n", "bond | \n", "Abstract | \n", "Basic | \n", "Biology-inspired concepts with multiple meanings | \n", "
1 | \n", "element | \n", "Abstract | \n", "Basic | \n", "Biology-inspired concepts with multiple meanings | \n", "
2 | \n", "molecule | \n", "Abstract | \n", "Basic | \n", "Biology-inspired concepts with multiple meanings | \n", "
3 | \n", "life | \n", "Abstract | \n", "Basic | \n", "Biology-inspired concepts with multiple meanings | \n", "
4 | \n", "protein | \n", "Abstract | \n", "Basic | \n", "Biology-inspired concepts with multiple meanings | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
1627 | \n", "a wooden post with a yellow '3' painted on top | \n", "Outdoor Scenes | \n", "Writing & Symbols | \n", "\n", " |
1628 | \n", "a wooden post in front of a patch of tall grass | \n", "Outdoor Scenes | \n", "Writing & Symbols | \n", "\n", " |
1629 | \n", "a wooden post with a blue '5' painted on top | \n", "Outdoor Scenes | \n", "Writing & Symbols | \n", "\n", " |
1630 | \n", "a series of musical notes on a black t-shirt | \n", "Artifacts | \n", "Writing & Symbols | \n", "\n", " |
1631 | \n", "a series of musical notes on a computer screen | \n", "Artifacts | \n", "Writing & Symbols | \n", "\n", " |
1632 rows × 4 columns
\n", "" ], "text/plain": [ " Prompt Category \\\n", "0 bond Abstract \n", "1 element Abstract \n", "2 molecule Abstract \n", "3 life Abstract \n", "4 protein Abstract \n", "... ... ... \n", "1627 a wooden post with a yellow '3' painted on top Outdoor Scenes \n", "1628 a wooden post in front of a patch of tall grass Outdoor Scenes \n", "1629 a wooden post with a blue '5' painted on top Outdoor Scenes \n", "1630 a series of musical notes on a black t-shirt Artifacts \n", "1631 a series of musical notes on a computer screen Artifacts \n", "\n", " Challenge Note \n", "0 Basic Biology-inspired concepts with multiple meanings \n", "1 Basic Biology-inspired concepts with multiple meanings \n", "2 Basic Biology-inspired concepts with multiple meanings \n", "3 Basic Biology-inspired concepts with multiple meanings \n", "4 Basic Biology-inspired concepts with multiple meanings \n", "... ... ... \n", "1627 Writing & Symbols \n", "1628 Writing & Symbols \n", "1629 Writing & Symbols \n", "1630 Writing & Symbols \n", "1631 Writing & Symbols \n", "\n", "[1632 rows x 4 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "code", "execution_count": null, "id": "de59ebb7", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1611: a black t-shirt with the peace sign on it, artifacts,\n", "1612: a store front with 'grassy meadow' written on it, outdoor scenes,\n", "1613: a store front with 'awesomepurchase' written on it, outdoor scenes,\n", "1614: a laptop screen showing an internet search, artifacts,\n", "1615: a laptop screen showing a bunch of photographs, artifacts,\n", "1616: a laptop screen showing a document being edited, artifacts,\n", "1617: a book with the words 'don't panic!' written on it, artifacts,\n" ] } ], "source": [ "for index, row in df.iterrows():\n", " if index <= 1617:\n", " continue\n", " index = f\"{index:04}\"\n", " prompt = f\"{row['Prompt'].lower()}, {row['Category'].lower()}, {row['Note'].lower()}\".strip()\n", " print(f\"{index}: {prompt}\")\n", " txt2img(prompt, index)" ] }, { "cell_type": "code", "execution_count": null, "id": "46638846", "metadata": {}, "outputs": [], "source": [] } ], "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.10.6" } }, "nbformat": 4, "nbformat_minor": 5 }