forked from jina-ai/discoart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
31 lines (27 loc) · 945 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import time
import logging
from typing import Any
from pqueue import Maestro, Prompt, Result
import discoart
class DiscoMaestro(Maestro):
def handle_item(self, generator: Any, prompt: Prompt) -> tuple[Any, Result]:
"finagle settings, generate it depending on settings, make a video if appropriate"
start_time = time.time()
image = discoart.create(
text_prompts=prompt.prompt,
n_batches=1,
diffusion_sampling_mode="plms",
width_height=[512, 512],
cutn_batches=2,
**prompt.param_dict,
)
logging.info(image)
image.save(f"output/{prompt.prompt_id}.png")
return generator, Result(
elapsed=round(time.time() - start_time),
filepath=f"output/{prompt.prompt_id}.png",
loss=-1,
seed=result[0].tags["seed"],
)
if __name__ == "__main__":
DiscoMaestro().main()