Spaces:
Running on Zero
Running on Zero
Upload h3_efficiency.py
Browse files- 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 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
| 74 |
MiniMaxH3ImageReference(image=resize_reference(original.image, canvas, mode))
|
| 75 |
if original.kind == "image" else normalized
|
| 76 |
-
for original, normalized in zip(
|
| 77 |
]
|
| 78 |
-
|
| 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):
|