You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run a model and get its output while it's running:
39
43
40
44
```python
41
45
model = replicate.models.get("pixray/text2image")
42
-
for image in model.predict(prompts="san francisco sunset"):
46
+
version = model.versions.get("5c347a4bfa1d4523a58ae614c2194e15f2ae682b57e3797a5bb468920aa70ebf")
47
+
for image in version.predict(prompts="san francisco sunset"):
43
48
display(image)
44
49
```
45
50
46
51
You can start a model and run it in the background:
47
52
48
53
```python
49
54
>>> model = replicate.models.get("kvfrans/clipdraw")
55
+
>>> version = model.versions.get("5797a99edc939ea0e9242d5e8c9cb3bc7d125b1eac21bda852e5cb79ede2cd9b")
50
56
>>> prediction = replicate.predictions.create(
51
-
...version=model.versions.list()[0],
57
+
...version=version,
52
58
...input={"prompt":"Watercolor painting of an underwater submarine"})
53
59
54
60
>>> prediction
@@ -83,8 +89,9 @@ You can cancel a running prediction:
83
89
84
90
```python
85
91
>>> model = replicate.models.get("kvfrans/clipdraw")
92
+
>>> version = model.versions.get("5797a99edc939ea0e9242d5e8c9cb3bc7d125b1eac21bda852e5cb79ede2cd9b")
86
93
>>> prediction = replicate.predictions.create(
87
-
...version=model.versions.list()[0],
94
+
...version=version,
88
95
...input={"prompt":"Watercolor painting of an underwater submarine"})
89
96
90
97
>>> prediction.status
@@ -97,17 +104,6 @@ You can cancel a running prediction:
97
104
'canceled'
98
105
```
99
106
100
-
By default, `model.predict()` uses the latest version. If you're running a model in production, you should pin to a particular version to ensure its API or behavior doesn't change.
101
-
102
-
If you want to pin to a particular version, you can get a version with its ID, then call the `predict()` method on that version:
103
-
104
-
```
105
-
>>> model = replicate.models.get("replicate/hello-world")
106
-
>>> version = model.versions.get("5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa")
0 commit comments