Release V3.8 source, illustrated manual and Spectrum workflow
This commit is contained in:
+53
-53
@@ -1,47 +1,47 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from ComfyUI_H3_Continuum_Join.reference import (
|
||||
REFERENCE_SIZE_MATCH_OUTPUT,
|
||||
ReferenceAssets,
|
||||
ReferenceConditioningError,
|
||||
prepare_reference_assets,
|
||||
validate_reference_prompts,
|
||||
REFERENCE_SIZE_MATCH_OUTPUT,
|
||||
ReferenceAssets,
|
||||
ReferenceConditioningError,
|
||||
prepare_reference_assets,
|
||||
validate_reference_prompts,
|
||||
)
|
||||
from ComfyUI_H3_Continuum_Join.reference_audio import validate_reference_audio_prompts
|
||||
from ComfyUI_H3_Continuum_Join.v3 import nodes as v3_nodes
|
||||
|
||||
|
||||
def test_reference_size_is_appended_after_v31_widgets():
|
||||
from pathlib import Path
|
||||
|
||||
source = (Path(__file__).resolve().parents[1] / "v3" / "nodes.py").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
production = source.split("class H3ContinuumSamplerProduction", 1)[1]
|
||||
required = production.split('"optional": {', 1)[0]
|
||||
assert required.index('"run_name"') < required.index('"reference_size"')
|
||||
|
||||
|
||||
def _assets(count: int = 2) -> ReferenceAssets:
|
||||
images = tuple(torch.zeros((1, 32, 32, 3)) for _ in range(count))
|
||||
hashes = tuple(str(index) * 64 for index in range(1, count + 1))
|
||||
return ReferenceAssets(
|
||||
images=images,
|
||||
latents=tuple(None for _ in range(count)),
|
||||
image_hashes=hashes,
|
||||
combined_hash="a" * 64,
|
||||
size_mode=REFERENCE_SIZE_MATCH_OUTPUT,
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
def test_reference_size_is_appended_after_v31_widgets():
|
||||
from pathlib import Path
|
||||
|
||||
source = (Path(__file__).resolve().parents[1] / "v3" / "nodes.py").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
production = source.split("class H3ContinuumSamplerProduction", 1)[1]
|
||||
required = production.split('"optional": {', 1)[0]
|
||||
assert required.index('"run_name"') < required.index('"reference_size"')
|
||||
|
||||
|
||||
def _assets(count: int = 2) -> ReferenceAssets:
|
||||
images = tuple(torch.zeros((1, 32, 32, 3)) for _ in range(count))
|
||||
hashes = tuple(str(index) * 64 for index in range(1, count + 1))
|
||||
return ReferenceAssets(
|
||||
images=images,
|
||||
latents=tuple(None for _ in range(count)),
|
||||
image_hashes=hashes,
|
||||
combined_hash="a" * 64,
|
||||
size_mode=REFERENCE_SIZE_MATCH_OUTPUT,
|
||||
)
|
||||
|
||||
|
||||
def test_reference_contract_contains_metadata_only():
|
||||
contract = _assets().contract
|
||||
assert contract["count"] == 2
|
||||
assert contract["size_mode"] == REFERENCE_SIZE_MATCH_OUTPUT
|
||||
assert contract["image_hashes"] == ["1" * 64, "2" * 64]
|
||||
contract = _assets().contract
|
||||
assert contract["count"] == 2
|
||||
assert contract["size_mode"] == REFERENCE_SIZE_MATCH_OUTPUT
|
||||
assert contract["image_hashes"] == ["1" * 64, "2" * 64]
|
||||
assert not any(torch.is_tensor(value) for value in contract.values())
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ def test_v323_third_reference_adds_only_the_image_3_extension():
|
||||
"sha256": "3" * 64,
|
||||
"preprocess_version": 1,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def test_unavailable_picture_tags_warn_without_stopping_like_core():
|
||||
assert validate_reference_prompts(["Use <Picture 1> and <Picture 2>."], 2) == ""
|
||||
message = validate_reference_prompts(["Use <Picture 2>."], 1)
|
||||
@@ -86,21 +86,21 @@ def test_unavailable_picture_tags_warn_without_stopping_like_core():
|
||||
message = validate_reference_prompts(["Use <Picture 3>."], 2)
|
||||
assert "unavailable <Picture 3>" in message
|
||||
assert "generation will continue" in message
|
||||
|
||||
|
||||
def test_missing_picture_tag_is_a_warning_not_an_error():
|
||||
|
||||
|
||||
def test_missing_picture_tag_is_a_warning_not_an_error():
|
||||
warning = validate_reference_prompts(["The same person walks forward."], 1)
|
||||
assert "H3C-P103" in warning
|
||||
assert "no <Picture N> tag" in warning
|
||||
|
||||
|
||||
assert "no <Picture N> tag" in warning
|
||||
|
||||
|
||||
def test_reference_socket_rejects_image_batches():
|
||||
with pytest.raises(ReferenceConditioningError, match="batch size B=1"):
|
||||
prepare_reference_assets(
|
||||
reference_image_1=torch.zeros((2, 32, 32, 3)),
|
||||
reference_image_2=None,
|
||||
output_width=32,
|
||||
output_height=32,
|
||||
with pytest.raises(ReferenceConditioningError, match="batch size B=1"):
|
||||
prepare_reference_assets(
|
||||
reference_image_1=torch.zeros((2, 32, 32, 3)),
|
||||
reference_image_2=None,
|
||||
output_width=32,
|
||||
output_height=32,
|
||||
size_mode=REFERENCE_SIZE_MATCH_OUTPUT,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user