add try-except to replicate
This commit is contained in:
parent
9a4a839b3b
commit
b17bea11b6
2
cog.yaml
vendored
2
cog.yaml
vendored
|
@ -1,5 +1,5 @@
|
||||||
build:
|
build:
|
||||||
cuda: "11.5.1"
|
cuda: "11.4"
|
||||||
gpu: true
|
gpu: true
|
||||||
python_version: "3.10"
|
python_version: "3.10"
|
||||||
system_packages:
|
system_packages:
|
||||||
|
|
|
@ -31,21 +31,27 @@ class ReplicatePredictor(BasePredictor):
|
||||||
default=4
|
default=4
|
||||||
),
|
),
|
||||||
) -> Iterator[Path]:
|
) -> Iterator[Path]:
|
||||||
seed = -1
|
try:
|
||||||
log2_mid_count = 3 if intermediate_outputs else 0
|
seed = -1
|
||||||
image_stream = self.model.generate_image_stream(
|
log2_mid_count = 3 if intermediate_outputs else 0
|
||||||
text,
|
image_stream = self.model.generate_image_stream(
|
||||||
seed,
|
text,
|
||||||
grid_size=grid_size,
|
seed,
|
||||||
log2_mid_count=log2_mid_count,
|
grid_size=grid_size,
|
||||||
log2_supercondition_factor=log2_supercondition_factor,
|
log2_mid_count=log2_mid_count,
|
||||||
is_verbose=True
|
log2_supercondition_factor=log2_supercondition_factor,
|
||||||
)
|
is_verbose=True
|
||||||
|
)
|
||||||
|
|
||||||
iter = 0
|
iter = 0
|
||||||
path = Path(tempfile.mkdtemp())
|
path = Path(tempfile.mkdtemp())
|
||||||
for image in image_stream:
|
for image in image_stream:
|
||||||
iter += 1
|
iter += 1
|
||||||
image_path = path / 'min-dalle-iter-{}.jpg'.format(iter)
|
image_path = path / 'min-dalle-iter-{}.jpg'.format(iter)
|
||||||
image.save(str(image_path))
|
image.save(str(image_path))
|
||||||
yield image_path
|
yield image_path
|
||||||
|
except:
|
||||||
|
print("An error occured, deleting model")
|
||||||
|
del self.model
|
||||||
|
self.setup()
|
||||||
|
raise Exception("There was an error, please try again")
|
Loading…
Reference in New Issue
Block a user