experiment: remote-t5

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-08-15 10:56:34 -04:00
parent ac05301f9a
commit f3eb7c00fa
3 changed files with 48 additions and 1 deletions
+1 -1
View File
@@ -411,7 +411,7 @@ def load_diffuser_force(model_type, checkpoint_info, diffusers_load_config, op='
shared.log.error(f'Load {op}: path="{checkpoint_info.path}" {e}')
if debug_load:
errors.display(e, 'Load')
return None, True
return None
return sd_model
+40
View File
@@ -0,0 +1,40 @@
from typing import List, Optional, Union
import os
import time
import json
import torch
import requests
from modules import devices, errors
def get_t5_prompt_embeds(
prompt: Union[str, List[str]] = None,
num_images_per_prompt: int = 1, # pylint: disable=unused-argument
max_sequence_length: int = 512, # pylint: disable=unused-argument
device: Optional[torch.device] = None,
dtype: Optional[torch.dtype] = None,
):
device = device or devices.device
dtype = dtype or devices.dtype
url = os.environ.get('SD_REMOTE_T5', None)
if url is None:
errors.log.error('Remote-TE: url is not set')
return None
try:
t0 = time.time()
response = requests.post(
url=url,
headers={ "Content-Type": "application/json" },
json=prompt,
timeout=300,
)
t1 = time.time()
shape = json.loads(response.headers["shape"])
buffer = bytearray(response.content)
tensor = torch.frombuffer(buffer, dtype=dtype).reshape(shape)
errors.log.debug(f'Remote-TE: url="{url}" prompt="{prompt}" shape={shape} time={t1-t0:.3f}')
return tensor.to(device=device, dtype=dtype)
except Exception as e:
errors.log.error(f'Remote-TE: {e}')
errors.display(e, 'remote-te')
return None