diff --git a/florence2_hires.py b/florence2_hires.py index 9d5248c..667fdbf 100644 --- a/florence2_hires.py +++ b/florence2_hires.py @@ -538,8 +538,13 @@ def run_florence2_step( # 7. Megapixel resize (NHWC -> NCHW for common_upscale -> NHWC back) import comfy.utils - target_w, target_h = compute_target_dims( - crop_w, crop_h, float(step_config.get("target_megapixels", 1.0)) + requested_mp = float(step_config.get("target_megapixels", 1.0)) + target_w, target_h = compute_target_dims(crop_w, crop_h, requested_mp) + actual_mp = (target_w * target_h) / (1024 * 1024) + print( + f"[Florence2HiResFix] src=({source_image.shape[2]}x{source_image.shape[1]}) " + f"crop=({crop_w}x{crop_h}) requested_MP={requested_mp:.3f} " + f"-> internal_pass=({target_w}x{target_h})={actual_mp:.3f}MP" ) cropped_nchw = cropped_img.movedim(-1, 1) resized_nchw = comfy.utils.common_upscale( diff --git a/web/conf_builder/conf-builder-config-management.js b/web/conf_builder/conf-builder-config-management.js index 730166e..6ad0848 100644 --- a/web/conf_builder/conf-builder-config-management.js +++ b/web/conf_builder/conf-builder-config-management.js @@ -5964,13 +5964,17 @@ export function renderUpscalingSection(node, container, modelLists) { // --- HiRes fields (multi-value: ratios, denoise) --- if (showHires) { - const ratiosInput = document.createElement("input"); - ratiosInput.type = "text"; - ratiosInput.className = "cb-input"; - ratiosInput.value = ucfg.upscale_ratios || "1.5"; - ratiosInput.placeholder = "1.2, 1.5, 2.0"; - ratiosInput.onchange = () => { ucfg.upscale_ratios = ratiosInput.value; node.saveState(); }; - grid.appendChild(createInputGroup("Upscale Ratios", ratiosInput)); + // Upscale Ratios is irrelevant for florence2_hires (it inpaints a region, + // not the whole image; Target MP controls the internal pass size instead). + if (!showFlorence2) { + const ratiosInput = document.createElement("input"); + ratiosInput.type = "text"; + ratiosInput.className = "cb-input"; + ratiosInput.value = ucfg.upscale_ratios || "1.5"; + ratiosInput.placeholder = "1.2, 1.5, 2.0"; + ratiosInput.onchange = () => { ucfg.upscale_ratios = ratiosInput.value; node.saveState(); }; + grid.appendChild(createInputGroup("Upscale Ratios", ratiosInput)); + } // NOTE: renderUpscalingSection is a session-level section (no configArray param). // Cannot use isLTXConfigArray() here — left as node.state.model_type guard intentionally. @@ -5995,13 +5999,17 @@ export function renderUpscalingSection(node, container, modelLists) { grid.appendChild(createInputGroup("HiRes Steps (0=same)", stepsInput)); // --- HiRes Tiled Sampling (tile the latent for KSampler to prevent OOM on large upscales) --- - const tiledSamplingCb = document.createElement("input"); - tiledSamplingCb.type = "checkbox"; - tiledSamplingCb.checked = ucfg.hires_tiled_sampling || false; - tiledSamplingCb.onchange = () => { ucfg.hires_tiled_sampling = tiledSamplingCb.checked; node.saveState(); renderPipelines(); }; - grid.appendChild(createInputGroup("HiRes Tiled Sampling", tiledSamplingCb)); + // Hidden for florence2_hires — tiled sampling doesn't apply to its + // crop-then-paste pipeline (crops are too small to need tiling). + if (!showFlorence2) { + const tiledSamplingCb = document.createElement("input"); + tiledSamplingCb.type = "checkbox"; + tiledSamplingCb.checked = ucfg.hires_tiled_sampling || false; + tiledSamplingCb.onchange = () => { ucfg.hires_tiled_sampling = tiledSamplingCb.checked; node.saveState(); renderPipelines(); }; + grid.appendChild(createInputGroup("HiRes Tiled Sampling", tiledSamplingCb)); + } - if (ucfg.hires_tiled_sampling) { + if (ucfg.hires_tiled_sampling && !showFlorence2) { const htWidthInput = document.createElement("input"); htWidthInput.type = "number"; htWidthInput.className = "cb-input";