amisima commited on
Commit
a0ada57
·
verified ·
1 Parent(s): 6065b01

Upload h3_efficiency.py

Browse files
Files changed (1) hide show
  1. h3_efficiency.py +8 -5
h3_efficiency.py CHANGED
@@ -68,14 +68,17 @@ def efficient_blocks(original_blocks_type):
68
  mode = validate_resize_mode(self.get_block_state(state).reference_resize_mode)
69
  components, state = super().__call__(components, state)
70
  if mode == "match":
71
- block = self.get_block_state(state)
72
- canvas = (block.width, block.height)
73
- block.normalized_references = [
 
 
 
74
  MiniMaxH3ImageReference(image=resize_reference(original.image, canvas, mode))
75
  if original.kind == "image" else normalized
76
- for original, normalized in zip(block.references, block.normalized_references)
77
  ]
78
- self.set_block_state(state, block)
79
  return components, state
80
 
81
  class EfficientBlocks(original_blocks_type):
 
68
  mode = validate_resize_mode(self.get_block_state(state).reference_resize_mode)
69
  components, state = super().__call__(components, state)
70
  if mode == "match":
71
+ # get_block_state() only projects declared inputs. Normalized
72
+ # references are an OUTPUT, available on the full PipelineState.
73
+ # Read the resolved canvas there too, then replace only this
74
+ # output; all upstream audio/video/frame results stay intact.
75
+ canvas = (state.get("width"), state.get("height"))
76
+ normalized_references = [
77
  MiniMaxH3ImageReference(image=resize_reference(original.image, canvas, mode))
78
  if original.kind == "image" else normalized
79
+ for original, normalized in zip(state.get("references"), state.get("normalized_references"))
80
  ]
81
+ state.set("normalized_references", normalized_references)
82
  return components, state
83
 
84
  class EfficientBlocks(original_blocks_type):