Skip to content

Commit

Permalink
Update with working Replicate example
Browse files Browse the repository at this point in the history
  • Loading branch information
NivekT committed Aug 29, 2023
1 parent 0d639a5 commit 2964081
Showing 1 changed file with 24 additions and 66 deletions.
90 changes: 24 additions & 66 deletions examples/notebooks/ReplicateExperiment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"source": [
"import os\n",
"\n",
"os.environ[\"DEBUG\"] = \"1\" # Set this to \"\" to call Replicate's API, otherwise a mock function is used\n",
"os.environ[\"REPLICATE_API_TOKEN\"] = \"\""
"os.environ[\"DEBUG\"] = \"\" # Set this to \"\" to call Replicate's API, otherwise a mock function is used\n",
"os.environ[\"REPLICATE_API_TOKEN\"] = \"r8_AlGz9ofN7OAwmiIcCqhxa6b4Duqgk4T3IyaaI\""
]
},
{
Expand Down Expand Up @@ -91,131 +91,89 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"id": "347590cf",
"metadata": {},
"outputs": [],
"source": [
"sd1 = \"stability-ai/stable-diffusion:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478\"\n",
"models = [sd1] # You can specify multiple models here\n",
"input_kwargs = {\"prompt\": [\"a 19th century portrait of a wombat gentleman\", \"a 22nd century portrait of a wombat gentleman\"]}\n",
"input_kwargs = {\"prompt\": [\"a 19th century portrait of a wombat gentleman\", \"a 22nd century portrait of a robotic dog\"]}\n",
"model_specific_kwargs = {sd1: {}}\n",
"\n",
"experiment = ReplicateExperiment(models, input_kwargs, model_specific_kwargs)"
]
},
{
"cell_type": "markdown",
"id": "f3fa5450",
"metadata": {},
"source": [
"We can then run the experiment to get results."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "1a261583",
"metadata": {},
"outputs": [],
"source": [
"experiment.run()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "fc4c4fd2",
"execution_count": 7,
"id": "ca01ff10",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>input</th>\n",
" <th>response</th>\n",
" <th>latency</th>\n",
" <th>images</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>{'prompt': 'a 19th century portrait of a wombat gentleman'}</td>\n",
" <td>[https://mock.com/1.jpeg, https://mock.com/2.jpeg, https://mock.com/3.jpeg]</td>\n",
" <td>0.000008</td>\n",
" <td>5.001268</td>\n",
" <td><img src=\"https://pbxt.replicate.delivery/3xcGYj0qhCZyD5TiJ9W1zcjbCh4OkjggUYBf9M6c2zyY9avIA/out-0.png\" width=\"100\"/></td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>{'prompt': 'a 22nd century portrait of a wombat gentleman'}</td>\n",
" <td>[https://mock.com/1.jpeg, https://mock.com/2.jpeg, https://mock.com/3.jpeg]</td>\n",
" <td>0.000003</td>\n",
" <td>{'prompt': 'a 22nd century portrait of a robotic dog'}</td>\n",
" <td>5.024777</td>\n",
" <td><img src=\"https://pbxt.replicate.delivery/gmUW2zllT0baHVnQ0cwsCyAEuDgETzm9MvTRId6IiXpteavIA/out-0.png\" width=\"100\"/></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
"</table>"
],
"text/plain": [
" input \\\n",
"0 {'prompt': 'a 19th century portrait of a wombat gentleman'} \n",
"1 {'prompt': 'a 22nd century portrait of a wombat gentleman'} \n",
"\n",
" response \\\n",
"0 [https://mock.com/1.jpeg, https://mock.com/2.jpeg, https://mock.com/3.jpeg] \n",
"1 [https://mock.com/1.jpeg, https://mock.com/2.jpeg, https://mock.com/3.jpeg] \n",
"\n",
" latency \n",
"0 0.000008 \n",
"1 0.000003 "
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"experiment.run()\n",
"experiment.visualize()"
]
},
{
"cell_type": "markdown",
"id": "266c13eb",
"id": "f3fa5450",
"metadata": {},
"source": [
"## Evaluate the model response"
"We can then run the experiment to get results."
]
},
{
"cell_type": "markdown",
"id": "bebb8023",
"id": "266c13eb",
"metadata": {},
"source": [
"This will be updated with structural similarity evaluation. Please don't hesitate to open an issue if you have any suggestions. Stay tuned."
"## Evaluate the model response"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "78c0c9f6",
"cell_type": "markdown",
"id": "bebb8023",
"metadata": {},
"outputs": [],
"source": []
"source": [
"This will be updated with structural similarity evaluation. For now, you can reference the example in the Stable Diffusion notebook example. Please don't hesitate to open an issue if you have any suggestions. Stay tuned."
]
}
],
"metadata": {
Expand Down

0 comments on commit 2964081

Please sign in to comment.