36 37 if len(arg) != 1: 38 raise ValueError("ScaleDims scale args must be in the format of <dim>,<scale>(e.g. 4,1.5) but got multiple segments") 39 extracted_arg = arg[0] 40 assert isinstance(extracted_arg, PromptSegment) 41 42 if "," not in extracted_arg.text: 43 raise ValueError("ScaleDims scale args must be in the format of <dim>,<scale>(e.g. 4,1.5) but got a segment with no comma: " + extracted_arg.text)
36 37 if len(arg) != 1: 38 raise ValueError("SetDims value args must be in the format of <dim>,<value>(e.g. 4,1.5) but got multiple segments") 39 extracted_arg = arg[0] 40 assert isinstance(extracted_arg, PromptSegment) 41 42 if "," not in extracted_arg.text: 43 raise ValueError("SetDims value args must be in the format of <dim>,<value>(e.g. 4,1.5) but got a segment with no comma: " + extracted_arg.text)
27 def __init__(self, version="openai/clip-vit-large-patch14", device="cpu", max_length=77, 28 freeze=True, layer="last", layer_idx=None, textmodel_json_config=None, 29 textmodel_path=None, dtype=None): # clip-vit-base-patch32 30 super().__init__() 31 assert layer in self.LAYERS 32 self.num_layers = 12 33 if textmodel_path is not None: 34 # Our transformer
58 self.logit_scale = torch.nn.Parameter(torch.tensor(4.6055)) 59 60 self.layer_norm_hidden_state = True 61 if layer == "hidden": 62 assert layer_idx is not None 63 assert abs(layer_idx) <= self.num_layers 64 self.clip_layer(layer_idx) 65 self.layer_default = (self.layer, self.layer_idx)
59 60 self.layer_norm_hidden_state = True 61 if layer == "hidden": 62 assert layer_idx is not None 63 assert abs(layer_idx) <= self.num_layers 64 self.clip_layer(layer_idx) 65 self.layer_default = (self.layer, self.layer_idx) 66
16 data = json.dumps(p).encode('utf-8') 17 req = urllib.request.Request("http://{}/prompt".format(server_address), data=data) 18 19 try: 20 response = urllib.request.urlopen(req) 21 return json.loads(response.read()) 22 except urllib.error.HTTPError as e: 23 print(f"HTTP Error {e.code}: {e.reason}")
37 38 def get_image(filename, subfolder, folder_type): 39 data = {"filename": filename, "subfolder": subfolder, "type": folder_type} 40 url_values = urllib.parse.urlencode(data) 41 with urllib.request.urlopen("http://{}/view?{}".format(server_address, url_values)) as response: 42 return response.read() 43 44 def get_history(prompt_id):
41 with urllib.request.urlopen("http://{}/view?{}".format(server_address, url_values)) as response: 42 return response.read() 43 44 def get_history(prompt_id): 45 with urllib.request.urlopen("http://{}/history/{}".format(server_address, prompt_id)) as response: 46 return json.loads(response.read()) 47 48 def get_images(ws, prompt):