Skip to content

Commit

Permalink
chore: updated REST API colab to refrence prod preview url
Browse files Browse the repository at this point in the history
  • Loading branch information
todd-elvers committed Sep 22, 2023
1 parent 3bb15ae commit 81418cd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions nbs/Fine_Tuning_REST_API_External_Test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"#@title Add your API key\n",
"import getpass\n",
"\n",
"#@markdown > Execute this step and paste your API key in the box that appears. <br/> <br/> Visit https://next.platform-stability.pages.dev/account/keys to get your API key! <br/> <em>Note: If you are not on the fine-tuning whitelist you will receive an error during training.</em>\n",
"#@markdown > Execute this step and paste your API key in the box that appears. <br/> <br/> Visit https://platform.stability.ai/account/keys to get your API key! <br/> <em>Note: If you are not on the fine-tuning whitelist you will receive an error during training.</em>\n",
"\n",
"API_KEY = getpass.getpass('Paste your Stability API Key here and press Enter: ')\n",
"API_HOST = \"https://staging-api.stability.ai\"\n",
"API_HOST = \"https://preview-api.stability.ai\"\n",
"\n",
"engine_id = \"stable-diffusion-xl-1024-v1-0\""
]
Expand All @@ -41,7 +41,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "5LM5SUUOhH8z"
},
"outputs": [],
Expand Down Expand Up @@ -208,13 +207,15 @@
" payload[\"training_set_id\"] = training_set_id\n",
" print(f\"\\tCreated training set {training_set_id}\")\n",
"\n",
" # Add images to the training set\n",
" for image in images:\n",
" print(f\"\\t\\tAdding {os.path.basename(image)}\")\n",
" self.add_image_to_training_set(\n",
" training_set_id=training_set_id,\n",
" image=image\n",
" )\n",
"\n",
" # Create the fine-tune\n",
" print(f\"\\tCreating a fine-tune from the training set\")\n",
" response = requests.post(\n",
" f\"{self.api_host}/v1/fine-tunes\",\n",
Expand Down Expand Up @@ -324,7 +325,8 @@
"\n",
" return [TrainingSetBase(**tsb) for tsb in response.json()]\n",
"\n",
" def add_image_to_training_set(self, training_set_id: str, image: str) -> None:\n",
" def add_image_to_training_set(self, training_set_id: str, image: str) -> str:\n",
" \"\"\" Adds an image to a training set, returning the id of the image added. \"\"\"\n",
" with open(image, 'rb') as image_file:\n",
" response = requests.post(\n",
" f\"{self.api_host}/v1/training-sets/{training_set_id}/images\",\n",
Expand All @@ -334,6 +336,8 @@
"\n",
" raise_on_non200(response)\n",
"\n",
" return response.json().get('id')\n",
"\n",
" def remove_image_from_training_set(self, training_set_id: str, image_id: str) -> None:\n",
" response = requests.delete(\n",
" f\"{self.api_host}/v1/training-sets/{training_set_id}/images/{image_id}\",\n",
Expand Down

0 comments on commit 81418cd

Please sign in to comment.