Skip to content

Commit b17bea1

Browse files
committed
add try-except to replicate
1 parent 9a4a839 commit b17bea1

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

cog.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build:
2-
cuda: "11.5.1"
2+
cuda: "11.4"
33
gpu: true
44
python_version: "3.10"
55
system_packages:

replicate_predictor.py

+23-17
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,27 @@ def predict(
3131
default=4
3232
),
3333
) -> Iterator[Path]:
34-
seed = -1
35-
log2_mid_count = 3 if intermediate_outputs else 0
36-
image_stream = self.model.generate_image_stream(
37-
text,
38-
seed,
39-
grid_size=grid_size,
40-
log2_mid_count=log2_mid_count,
41-
log2_supercondition_factor=log2_supercondition_factor,
42-
is_verbose=True
43-
)
34+
try:
35+
seed = -1
36+
log2_mid_count = 3 if intermediate_outputs else 0
37+
image_stream = self.model.generate_image_stream(
38+
text,
39+
seed,
40+
grid_size=grid_size,
41+
log2_mid_count=log2_mid_count,
42+
log2_supercondition_factor=log2_supercondition_factor,
43+
is_verbose=True
44+
)
4445

45-
iter = 0
46-
path = Path(tempfile.mkdtemp())
47-
for image in image_stream:
48-
iter += 1
49-
image_path = path / 'min-dalle-iter-{}.jpg'.format(iter)
50-
image.save(str(image_path))
51-
yield image_path
46+
iter = 0
47+
path = Path(tempfile.mkdtemp())
48+
for image in image_stream:
49+
iter += 1
50+
image_path = path / 'min-dalle-iter-{}.jpg'.format(iter)
51+
image.save(str(image_path))
52+
yield image_path
53+
except:
54+
print("An error occured, deleting model")
55+
del self.model
56+
self.setup()
57+
raise Exception("There was an error, please try again")

0 commit comments

Comments
 (0)