Skip to content

Commit eab33e8

Browse files
committed
Add better example with stable diffusion
Signed-off-by: Ben Firshman <[email protected]>
1 parent 5862c04 commit eab33e8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22

33
This is a Python client for Replicate. It lets you run models from your Python code or Jupyter notebook, and do various other things on Replicate.
44

5+
Grab your token from [replicate.com/account](https://replicate.com/account) and authenticate by setting a it as an environment variable:
6+
7+
```
8+
export REPLICATE_API_TOKEN=[token]
9+
```
10+
511
You can run a model and get its output:
612

713
```python
14+
$ python
815
>>> import replicate
16+
>>> model = replicate.models.get("stability-ai/stable-diffusion")
17+
>>> model.predict(prompt="a 19th century portrait of a wombat gentleman")
18+
['https://replicate.com/api/models/stability-ai/stable-diffusion/files/50fcac81-865d-499e-81ac-49de0cb79264/out-0.png']
19+
```
920

10-
>>> model = replicate.models.get("replicate/hello-world")
11-
>>> model.predict(text="python")
12-
"hello python"
21+
Some models, like [replicate/resnet](/replicate/resnet), receive images as inputs. To pass a file as an input, use a file handle or URL
1322

23+
```python
1424
>>> model = replicate.models.get("replicate/resnet")
1525
>>> model.predict(image=open("mystery.jpg", "rb"))
1626
[['n02123597', 'Siamese_cat', 0.8829364776611328],

0 commit comments

Comments
 (0)