ACCC1380's picture
download
raw
1.2 kB
import os
import torch
from PIL import Image
import folder_paths
from comfy.cli_args import args as cli_args
if not torch.cuda.is_available():
cli_args.cpu = True
from comfy_extras.nodes_bounding_boxes import CreateBoundingBoxes # noqa: E402
def run(background=None):
return CreateBoundingBoxes.execute(width=64, height=64, background=background).ui
def test_echoes_the_first_background_image_as_a_temp_preview(tmp_path, monkeypatch):
monkeypatch.setattr(folder_paths, "get_temp_directory", lambda: str(tmp_path))
first = torch.zeros(1, 48, 80, 3)
second = torch.ones(1, 48, 80, 3)
ui = run(background=torch.cat([first, second]))
[entry] = ui["background_images"]
assert entry["type"] == "temp"
path = os.path.join(str(tmp_path), entry["subfolder"], entry["filename"])
with Image.open(path) as saved:
assert saved.size == (80, 48)
assert saved.getpixel((0, 0)) == (0, 0, 0)
def test_omits_the_background_preview_without_a_background(tmp_path, monkeypatch):
monkeypatch.setattr(folder_paths, "get_temp_directory", lambda: str(tmp_path))
ui = run()
assert "background_images" not in ui
assert ui["dims"] == [64, 64]

Xet Storage Details

Size:
1.2 kB
·
Xet hash:
5f54e0e8e2e194a1c55044e9765ff6100d0916bb7f80a802fdcc367c7a77d219

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.