ruff check
This commit is contained in:
@@ -134,7 +134,7 @@ class ConditioningMathNode(io.ComfyNode):
|
||||
|
||||
for k, val in F.items():
|
||||
variables[k] = val if val is not None else 0.0
|
||||
|
||||
|
||||
# Execute Expression (Main Tensor)
|
||||
rtensor = None
|
||||
tree = None
|
||||
|
||||
@@ -1038,7 +1038,7 @@ class MathExprParser ( Parser ):
|
||||
self.stmt()
|
||||
pass
|
||||
|
||||
|
||||
|
||||
self.state = 69
|
||||
self._errHandler.sync(self)
|
||||
_alt = self._interp.adaptivePredict(self._input,1,self._ctx)
|
||||
@@ -1075,7 +1075,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_funcDef
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -1363,7 +1363,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_stmt
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -2238,7 +2238,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_ternaryExpr
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -2317,7 +2317,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_compExpr
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -2633,7 +2633,7 @@ class MathExprParser ( Parser ):
|
||||
self.addExpr(0)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
self.state = 211
|
||||
self._errHandler.sync(self)
|
||||
_alt = self._interp.adaptivePredict(self._input,14,self._ctx)
|
||||
@@ -2658,7 +2658,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_addExpr
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -2802,7 +2802,7 @@ class MathExprParser ( Parser ):
|
||||
self.mulExpr(0)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
self.state = 225
|
||||
self._errHandler.sync(self)
|
||||
_alt = self._interp.adaptivePredict(self._input,16,self._ctx)
|
||||
@@ -2827,7 +2827,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_mulExpr
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -3014,7 +3014,7 @@ class MathExprParser ( Parser ):
|
||||
self.shiftExpr(0)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
self.state = 242
|
||||
self._errHandler.sync(self)
|
||||
_alt = self._interp.adaptivePredict(self._input,18,self._ctx)
|
||||
@@ -3039,7 +3039,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_shiftExpr
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -3183,7 +3183,7 @@ class MathExprParser ( Parser ):
|
||||
self.powExpr()
|
||||
pass
|
||||
|
||||
|
||||
|
||||
self.state = 256
|
||||
self._errHandler.sync(self)
|
||||
_alt = self._interp.adaptivePredict(self._input,20,self._ctx)
|
||||
@@ -3208,7 +3208,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_powExpr
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -3317,7 +3317,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_unaryExpr
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -3456,7 +3456,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_indexExpr
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -3600,7 +3600,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_atom
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -4371,7 +4371,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_func0
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -4439,7 +4439,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_func1
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -7621,7 +7621,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_func2
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -9660,7 +9660,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_func3
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -10556,7 +10556,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_func4
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -10783,7 +10783,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_func5
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -10880,7 +10880,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_funcN
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -11409,7 +11409,7 @@ class MathExprParser ( Parser ):
|
||||
def getRuleIndex(self):
|
||||
return MathExprParser.RULE_funcNoise
|
||||
|
||||
|
||||
|
||||
def copyFrom(self, ctx:ParserRuleContext):
|
||||
super().copyFrom(ctx)
|
||||
|
||||
@@ -12634,63 +12634,63 @@ class MathExprParser ( Parser ):
|
||||
def compExpr_sempred(self, localctx:CompExprContext, predIndex:int):
|
||||
if predIndex == 0:
|
||||
return self.precpred(self._ctx, 7)
|
||||
|
||||
|
||||
|
||||
if predIndex == 1:
|
||||
return self.precpred(self._ctx, 6)
|
||||
|
||||
|
||||
|
||||
if predIndex == 2:
|
||||
return self.precpred(self._ctx, 5)
|
||||
|
||||
|
||||
|
||||
if predIndex == 3:
|
||||
return self.precpred(self._ctx, 4)
|
||||
|
||||
|
||||
|
||||
if predIndex == 4:
|
||||
return self.precpred(self._ctx, 3)
|
||||
|
||||
|
||||
|
||||
if predIndex == 5:
|
||||
return self.precpred(self._ctx, 2)
|
||||
|
||||
|
||||
|
||||
def addExpr_sempred(self, localctx:AddExprContext, predIndex:int):
|
||||
if predIndex == 6:
|
||||
return self.precpred(self._ctx, 3)
|
||||
|
||||
|
||||
|
||||
if predIndex == 7:
|
||||
return self.precpred(self._ctx, 2)
|
||||
|
||||
|
||||
|
||||
def mulExpr_sempred(self, localctx:MulExprContext, predIndex:int):
|
||||
if predIndex == 8:
|
||||
return self.precpred(self._ctx, 4)
|
||||
|
||||
|
||||
|
||||
if predIndex == 9:
|
||||
return self.precpred(self._ctx, 3)
|
||||
|
||||
|
||||
|
||||
if predIndex == 10:
|
||||
return self.precpred(self._ctx, 2)
|
||||
|
||||
|
||||
|
||||
def shiftExpr_sempred(self, localctx:ShiftExprContext, predIndex:int):
|
||||
if predIndex == 11:
|
||||
return self.precpred(self._ctx, 3)
|
||||
|
||||
|
||||
|
||||
if predIndex == 12:
|
||||
return self.precpred(self._ctx, 2)
|
||||
|
||||
|
||||
|
||||
def indexExpr_sempred(self, localctx:IndexExprContext, predIndex:int):
|
||||
if predIndex == 13:
|
||||
return self.precpred(self._ctx, 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3170,7 +3170,7 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
return self._apply_spatial_op(tsr, erode_op, original_shape)
|
||||
|
||||
def visitMorphOpenFunc(self, ctx):
|
||||
tsr_val = yield ctx.expr(0)
|
||||
yield ctx.expr(0)
|
||||
kernel_size = yield ctx.expr(1) if len(ctx.expr()) > 1 else 3
|
||||
|
||||
eroded = yield from self.visitErodeFunc(ctx)
|
||||
@@ -3193,7 +3193,7 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
return self._apply_spatial_op(tsr, dilate_op, original_shape)
|
||||
|
||||
def visitMorphCloseFunc(self, ctx):
|
||||
tsr_val = yield ctx.expr(0)
|
||||
yield ctx.expr(0)
|
||||
kernel_size = yield ctx.expr(1) if len(ctx.expr()) > 1 else 3
|
||||
|
||||
dilated = yield from self.visitDilateFunc(ctx)
|
||||
@@ -3384,7 +3384,7 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
items = []
|
||||
for i in range(len(exprs) - 1):
|
||||
items.append((yield exprs[i]))
|
||||
|
||||
|
||||
dim_val = yield exprs[-1]
|
||||
if any(isinstance(x, str) for x in items):
|
||||
return "".join(str(items))
|
||||
@@ -3404,16 +3404,16 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
def as_int(ctx,val):
|
||||
if self._is_tensor(val):
|
||||
return val.to(torch.int32).contiguous()
|
||||
|
||||
|
||||
if self._is_list(val):
|
||||
return [as_int(ctx,x) for x in val]
|
||||
|
||||
|
||||
if isinstance(val, str):
|
||||
return int(float(val))
|
||||
|
||||
|
||||
if val is None:
|
||||
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: Cannot convert None to a number")
|
||||
|
||||
|
||||
return int(float(val))
|
||||
return as_int(ctx,val)
|
||||
|
||||
@@ -3422,15 +3422,15 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
def as_float(ctx,val):
|
||||
if self._is_tensor(val):
|
||||
return val.to(torch.float).contiguous()
|
||||
|
||||
|
||||
if self._is_list(val):
|
||||
return [as_float(ctx,x) for x in val]
|
||||
|
||||
|
||||
if isinstance(val, str):
|
||||
return float(val)
|
||||
|
||||
|
||||
if val is None:
|
||||
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: Cannot convert None to a number")
|
||||
|
||||
|
||||
return float(val)
|
||||
return as_float(ctx,val)
|
||||
@@ -65,10 +65,6 @@ def preprocess_image(img, device):
|
||||
# Scale to [0, 255] as RAFT transforms usually expect this
|
||||
img = img * 255.0
|
||||
|
||||
# Use official transform if possible
|
||||
weights = Raft_Large_Weights.DEFAULT
|
||||
transform = weights.transforms()
|
||||
|
||||
# The transform expects [0, 255] and returns normalized [-1, 1]
|
||||
# It takes (img1, img2) but we can use it for one or just follow its logic
|
||||
# Actually, let's just follow the logic: 2 * (img / 255.0) - 1.0
|
||||
|
||||
@@ -165,15 +165,12 @@ class NoiseUtils:
|
||||
Uses interpolated noise for smooth results.
|
||||
coords_input: tuple of coordinate tensors
|
||||
"""
|
||||
ndim = len(coords_input)
|
||||
result = torch.zeros_like(coords_input[0])
|
||||
amplitude = 1.0
|
||||
frequency = 1.0
|
||||
max_amplitude = 0.0
|
||||
|
||||
for octave in range(4):
|
||||
# Scale coordinates by frequency and base scale
|
||||
scaled_coords = tuple((c / scale) * frequency for c in coords_input)
|
||||
|
||||
# Use Perlin-like interpolation for smooth plasma
|
||||
noise_octave = NoiseUtils.perlin_noise_nd(
|
||||
|
||||
Reference in New Issue
Block a user