Skip to content

Commit 34c358d

Browse files
authored
use typing.list in prompt_parser.py for wider python version support
1 parent f8e41a9 commit 34c358d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎modules/prompt_parser.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22
from collections import namedtuple
3-
3+
from typing import List
44
import lark
55

66
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][ in background:0.25] [shoddy:masterful:0.5]"
@@ -175,14 +175,14 @@ def get_multicond_prompt_list(prompts):
175175

176176
class ComposableScheduledPromptConditioning:
177177
def __init__(self, schedules, weight=1.0):
178-
self.schedules: list[ScheduledPromptConditioning] = schedules
178+
self.schedules: List[ScheduledPromptConditioning] = schedules
179179
self.weight: float = weight
180180

181181

182182
class MulticondLearnedConditioning:
183183
def __init__(self, shape, batch):
184184
self.shape: tuple = shape # the shape field is needed to send this object to DDIM/PLMS
185-
self.batch: list[list[ComposableScheduledPromptConditioning]] = batch
185+
self.batch: List[List[ComposableScheduledPromptConditioning]] = batch
186186

187187

188188
def get_multicond_learned_conditioning(model, prompts, steps) -> MulticondLearnedConditioning:
@@ -203,7 +203,7 @@ def get_multicond_learned_conditioning(model, prompts, steps) -> MulticondLearne
203203
return MulticondLearnedConditioning(shape=(len(prompts),), batch=res)
204204

205205

206-
def reconstruct_cond_batch(c: list[list[ScheduledPromptConditioning]], current_step):
206+
def reconstruct_cond_batch(c: List[List[ScheduledPromptConditioning]], current_step):
207207
param = c[0][0].cond
208208
res = torch.zeros((len(c),) + param.shape, device=param.device, dtype=param.dtype)
209209
for i, cond_schedule in enumerate(c):

0 commit comments

Comments
 (0)