OpenAPI ImageRequestParameter node uses a Chrome user-agent to facilitate external URLs better

This commit is contained in:
doctorpangloss 2024-05-13 15:03:34 -07:00
parent 188eff3376
commit d11aed87ba
2 changed files with 14 additions and 1 deletions

View File

@ -271,6 +271,9 @@ KNOWN_CONTROLNETS = [
HuggingFile("lllyasviel/sd_control_collection", "thibaud_xl_openpose.safetensors"),
HuggingFile("lllyasviel/sd_control_collection", "thibaud_xl_openpose_256lora.safetensors"),
HuggingFile("jschoormans/controlnet-densepose-sdxl", "diffusion_pytorch_model.safetensors", save_with_filename="controlnet-densepose-sdxl.safetensors", convert_to_16_bit=True, size=2502139104),
HuggingFile("stabilityai/stable-cascade", "controlnet/canny.safetensors", save_with_filename="stable_cascade_canny.safetensors"),
HuggingFile("stabilityai/stable-cascade", "controlnet/inpainting.safetensors", save_with_filename="stable_cascade_inpainting.safetensors"),
HuggingFile("stabilityai/stable-cascade", "controlnet/super_resolution.safetensors", save_with_filename="stable_cascade_super_resolution.safetensors"),
]
KNOWN_DIFF_CONTROLNETS = [

View File

@ -647,7 +647,17 @@ class ImageRequestParameter(CustomNode):
def execute(self, uri: str = "", *args, **kwargs) -> ValidatedNodeResult:
output_images = []
with fsspec.open(uri, mode="rb") as f:
f: OpenFile
kwargs_for_fsspec = {}
if uri.startswith('http'):
kwargs_for_fsspec.update({
"headers": {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.64 Safari/537.36'
}
})
# todo: additional security is needed here to prevent users from accessing local paths
# however this generally needs to be done with user accounts on all OSes
with fsspec.open(uri, mode="rb", **kwargs_for_fsspec) as f:
# from LoadImage
img = Image.open(f)
for i in ImageSequence.Iterator(img):