lllyasviel/style2paints · error · RuntimeError

No input variables found for layer %s.

Error message

No input variables found for layer %s.

What it means

Identical guard to smoother.py: the Style2PaintsV4.5 @layer decorator requires self.terminals to be non-empty before running an op, because terminals hold the current graph outputs that become the new layer's input. An empty terminals stack means the network graph was never seeded, so the op cannot be applied.

Source

Thrown at V4.5/s2p_v45_server/Style2PaintsV45_source.py:51


def norm_feature(x, core):
    cs0 = tf.shape(core)[1]
    cs1 = tf.shape(core)[2]
    small = tf.image.resize_area(x, (cs0, cs1))
    avged = tf.nn.avg_pool(tf.pad(small, [[0, 0], [2, 2], [2, 2], [0, 0]], 'REFLECT'), [1, 5, 5, 1], [1, 1, 1, 1],
                           'VALID')
    return tf.image.resize_bicubic(avged, tf.shape(x)[1:3])


def blur(x):
    def layer(op):
        def layer_decorated(self, *args, **kwargs):
            # Automatically set a name if not provided.
            name = kwargs.setdefault('name', self.get_unique_name(op.__name__))
            # Figure out the layer inputs.
            if len(self.terminals) == 0:
                raise RuntimeError('No input variables found for layer %s.' % name)
            elif len(self.terminals) == 1:
                layer_input = self.terminals[0]
            else:
                layer_input = list(self.terminals)
            # Perform the operation and get the output.
            layer_output = op(self, layer_input, *args, **kwargs)
            # Add to layer LUT.
            self.layers[name] = layer_output
            # This output is now the input for the next layer.
            self.feed(layer_output)
            # Return self for chained calls.
            return self

        return layer_decorated

    class Smoother(object):
        def __init__(self, inputs, filter_size, sigma):
            self.inputs = inputs

View on GitHub (pinned to a0d164d6a8)

Solutions

  1. Call net.feed(...) or the setup()/input step before any other layer call
  2. Check that no earlier exception in the build path silently left terminals empty
  3. Feed the correct starting tensor when building auxiliary subgraphs

Example fix

# before
net = Style2PaintsV45()
net.conv(...)  # RuntimeError: no input

# after
net = Style2PaintsV45()
net.setup(...)  # or net.feed(input_tensor)
net.conv(...)
Defensive patterns

Strategy: try-catch

Validate before calling

if len(net.terminals) == 0:
    net.setup()  # or net.feed(input_tensor) before any layer call

Try / catch

try:
    net.conv(3, 64)
except RuntimeError as e:
    if 'No input variables found' in str(e):
        net.setup()
        net.conv(3, 64)
    else:
        raise

Prevention

When it happens

Trigger: Invoking any decorated layer method on a newly created Style2PaintsV45 Network before feed() or an input-producing op has populated terminals — e.g. starting the build sequence with conv/upsample instead of the input/setup step.

Common situations: Reordering code so a layer call precedes the feed/setup call; an exception earlier in setup() leaving the graph unseeded; copying partial build code that omitted the input definition.

Related errors


AI-assisted analysis of lllyasviel/style2paints@a0d164d6a8 (2026-09-02). Data as JSON: /api/errors/89bf49ea3cde03ec. Report an issue: GitHub.