min-dalle-test/replicate/predict.py

23 lines
583 B
Python
Raw Normal View History

2022-06-29 19:53:25 +00:00
import tempfile
from cog import BasePredictor, Path, Input
from min_dalle import MinDalle
2022-06-29 19:53:25 +00:00
class Predictor(BasePredictor):
def setup(self):
self.model = MinDalle(is_mega=True)
2022-06-29 19:53:25 +00:00
def predict(
self,
text: str = Input(
description="Text for generating images.",
),
seed: int = Input(
description="Specify the seed.",
),
) -> Path:
image = self.model.generate_image(text, seed)
out_path = Path(tempfile.mkdtemp()) / "output.png"
image.save(str(out_path))
return out_path