              if not inbound:
                  logger.debug("Adding model inputs %s: %s", self._input_names, self._inputs)
                  model = layer(self._inputs)
              else:
                  layer_inputs = [compiled_layers[inp] for inp in inbound]
                  logger.debug("Compiling layer '%s': layer inputs: %s", name, layer_inputs)
                  model = layer(layer_inputs)
              compiled_layers[name] = model
          retval = KerasModel(self._inputs, model, name="{}_inference".format(saved_model.name))
          logger.debug("Compiled inference model '%s': %s", retval.name, retval)
          return retval
 
</s> remove             compiled_layers[name] = model
        retval = KerasModel(self._inputs, model, name="{}_inference".format(saved_model.name))
 </s> add             compiled_layers[layer.name] = model
            retval = KerasModel(model_inputs, model, name="{}_inference".format(saved_model.name)) </s> remove                 logger.debug("Adding model inputs %s: %s", self._input_names, self._inputs)
                model = layer(self._inputs)
 </s> add                 model = model_inputs
                logger.debug("Adding model inputs %s: %s", layer.name, model) </s> remove                          name, layer, inbound)
 </s> add                          layer.name, layer, inbound) </s> remove             layer = layer_dict[name]
 </s> add             inbound = struct[layer.name] </s> remove     @classmethod
    def _get_required_layers(cls, filtered_structure):
        """ Parse through the filtered model structure in reverse order to get the required layers
        from the faceswap model for creating an inference model.
 </s> add             if not inbound:
                break

            inbound_info = self._get_nodes(inbound)

            if any(inb[0] == drop_input for inb in inbound_info):  # Switch inputs
                inbound_info = [(switch_input if inb[0] == drop_input else inb[0], inb[1])
                                for inb in inbound_info]
            struct[layer_info[0]] = inbound_info
            next_layers.extend(inbound_info)

            if not current_layers:
                current_layers = next_layers
                next_layers = []

        struct[switch_input] = []  # Add the input layer
        logger.debug("Model structure: %s", struct)
        return struct

    def _get_inputs(self, inputs):
        """ Obtain the inputs for the requested swap direction.
                layer_inputs = []
                for inp in inbound:
                    inbound_layer = compiled_layers[inp[0]]
                    if isinstance(inbound_layer, list) and len(inbound_layer) > 1:
                        # Multi output inputs
                        inbound_output_idx = inp[1]
                        logger.debug("Selecting output index %s from multi output inbound "
                                     "layer: %s", inbound_output_idx, inbound_layer)
                        layer_inputs.append(inbound_layer[inbound_output_idx])
                    else:
                        layer_inputs.append(inbound_layer)

                logger.debug("Compiling layer '%s': layer inputs: %s", layer.name, layer_inputs)
              if not inbound:
                  logger.debug("Adding model inputs %s: %s", self._input_names, self._inputs)
                  model = layer(self._inputs)
              else:
                layer_inputs = []
                for inp in inbound:
                    inbound_layer = compiled_layers[inp[0]]
                    if isinstance(inbound_layer, list) and len(inbound_layer) > 1:
                        # Multi output inputs
                        inbound_output_idx = inp[1]
                        logger.debug("Selecting output index %s from multi output inbound "
                                     "layer: %s", inbound_output_idx, inbound_layer)
                        layer_inputs.append(inbound_layer[inbound_output_idx])
                    else:
                        layer_inputs.append(inbound_layer)

                logger.debug("Compiling layer '%s': layer inputs: %s", layer.name, layer_inputs)
                layer_inputs = []
                for inp in inbound:
                    inbound_layer = compiled_layers[inp[0]]
                    if isinstance(inbound_layer, list) and len(inbound_layer) > 1:
                        # Multi output inputs
                        inbound_output_idx = inp[1]
                        logger.debug("Selecting output index %s from multi output inbound "
                                     "layer: %s", inbound_output_idx, inbound_layer)
                        layer_inputs.append(inbound_layer[inbound_output_idx])
                    else:
                        layer_inputs.append(inbound_layer)

                logger.debug("Compiling layer '%s': layer inputs: %s", layer.name, layer_inputs)
                  model = layer(layer_inputs)
              compiled_layers[name] = model
          retval = KerasModel(self._inputs, model, name="{}_inference".format(saved_model.name))
          logger.debug("Compiled inference model '%s': %s", retval.name, retval)
          return retval
keep keep keep keep replace replace keep keep keep keep keep
 plugins.train.model.base - More robust inference model generation 
plugins/train/model/_base.py