Skip to content

Commit f01a647

Browse files
Upscale (#186)
* Adding upscaler functionality * Update help and readme * Update notebook with upscaler * Specs and test * Client side message size limits increased * Update README.md * Bump version
1 parent 2fab18d commit f01a647

6 files changed

Lines changed: 321 additions & 62 deletions

File tree

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,21 @@ You can manage API keys in your dreamstudio account [here](https://beta.dreamstu
2525

2626
Then to invoke:
2727

28-
`python3 -m stability_sdk.client -W 512 -H 512 "A stunning house."`
28+
`python3 -m stability_sdk generate -W 512 -H 512 "A stunning house."`
2929

3030
It will generate and put PNGs in your current directory.
3131

32+
To upscale:
33+
`python3 -m stability_sdk upscale -i "/path/to/image.png"`
34+
3235
## SDK Usage
3336

3437
See usage demo notebooks in ./nbs
3538

3639
## Command line usage
3740

3841
```
39-
usage: python -m stability_sdk [-h] [--height HEIGHT] [--width WIDTH] [--start_schedule START_SCHEDULE]
42+
usage: python -m stability_sdk generate [-h] [--height HEIGHT] [--width WIDTH] [--start_schedule START_SCHEDULE]
4043
[--end_schedule END_SCHEDULE] [--cfg_scale CFG_SCALE] [--sampler SAMPLER]
4144
[--steps STEPS] [--seed SEED] [--prefix PREFIX] [--engine ENGINE]
4245
[--num_samples NUM_SAMPLES] [--artifact_types ARTIFACT_TYPES]
@@ -80,6 +83,31 @@ options:
8083
--mask_image MASK_IMAGE, -m MASK_IMAGE
8184
Mask image
8285
```
86+
For upscale:
87+
```
88+
usage: client.py upscale
89+
[-h]
90+
--init_image INIT_IMAGE
91+
[--height HEIGHT] [--width WIDTH] [--prefix PREFIX] [--artifact_types ARTIFACT_TYPES]
92+
[--no-store] [--show] [--engine ENGINE]
93+
94+
options:
95+
-h, --help show this help message and exit
96+
--init_image INIT_IMAGE, -i INIT_IMAGE
97+
Init image
98+
--height HEIGHT, -H HEIGHT
99+
height of upscaled image in pixels
100+
--width WIDTH, -W WIDTH
101+
width of upscaled image in pixels
102+
--prefix PREFIX, -p PREFIX
103+
output prefixes for artifacts
104+
--artifact_types ARTIFACT_TYPES, -t ARTIFACT_TYPES
105+
filter artifacts by type (ARTIFACT_IMAGE, ARTIFACT_TEXT, ARTIFACT_CLASSIFICATIONS, etc)
106+
--no-store do not write out artifacts
107+
--show open artifacts using PIL
108+
--engine ENGINE, -e ENGINE
109+
engine to use for upscale
110+
```
83111

84112

85113
## Connecting to the API using languages other than Python

nbs/demo_colab.ipynb

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,33 @@
300300
" print('GUIDANCE: SLOWER:')\n",
301301
" display(img5)"
302302
]
303+
},
304+
{
305+
"cell_type": "code",
306+
"execution_count": null,
307+
"metadata": {},
308+
"outputs": [],
309+
"source": [
310+
"# Upscaling\n",
311+
"answers = stability_api.upscale(\n",
312+
" init_image=img3\n",
313+
")\n",
314+
"\n",
315+
"for resp in answers:\n",
316+
" for artifact in resp.artifacts:\n",
317+
" if artifact.finish_reason == generation.FILTER:\n",
318+
" warnings.warn(\n",
319+
" \"Your request activated the API's safety filters and could not be processed.\"\n",
320+
" \"Please submit a different image and try again.\")\n",
321+
" if artifact.type == generation.ARTIFACT_IMAGE:\n",
322+
" img3 = Image.open(io.BytesIO(artifact.binary))\n",
323+
" display(img3)"
324+
]
303325
}
304326
],
305327
"metadata": {
306328
"kernelspec": {
307-
"display_name": "Python 3.9.7 ('dmarx-je5LfYh2')",
329+
"display_name": "Python 3",
308330
"language": "python",
309331
"name": "python3"
310332
},
@@ -318,12 +340,12 @@
318340
"name": "python",
319341
"nbconvert_exporter": "python",
320342
"pygments_lexer": "ipython3",
321-
"version": "3.9.7"
343+
"version": "3.9.5"
322344
},
323345
"orig_nbformat": 4,
324346
"vscode": {
325347
"interpreter": {
326-
"hash": "57881a85d677a34ea29564e0084ef84f4058c4e30a2bb466eb0e0b908d0628df"
348+
"hash": "f9f85f796d01129d0dd105a088854619f454435301f6ffec2fea96ecbd9be4ac"
327349
}
328350
}
329351
},

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='stability-sdk',
10-
version='0.3.2',
10+
version='0.4.0',
1111
author='Wes Brown',
1212
author_email='wesbrown18@gmail.com',
1313
maintainer='David Marx',

0 commit comments

Comments
 (0)