1.6.1
This commit is contained in:
@@ -75,9 +75,7 @@ def registerSocketEvents(sdppp, sio):
|
||||
return
|
||||
document = payload['document']
|
||||
|
||||
backendInstance = sdppp.backend_instances[document['instance_id']]
|
||||
|
||||
return await ProtocolPhotoshop.get_image(backendInstance,
|
||||
return await ProtocolPhotoshop.get_image(document['instance_id'],
|
||||
document_identify=document['identify'],
|
||||
layer_identify=payload['layer_identify'],
|
||||
boundaries=payload['boundaries'],
|
||||
@@ -89,10 +87,8 @@ def registerSocketEvents(sdppp, sio):
|
||||
if not sdppp.has_ps_instance():
|
||||
return
|
||||
document = payload['document']
|
||||
print(sdppp.backend_instances.keys())
|
||||
backendInstance = sdppp.backend_instances[document['instance_id']]
|
||||
|
||||
await ProtocolPhotoshop.send_images(backendInstance,
|
||||
await ProtocolPhotoshop.send_images(document['instance_id'],
|
||||
document_identify=document['identify'],
|
||||
layer_identifies=payload['layer_identifies'],
|
||||
boundaries=payload['boundaries'],
|
||||
|
||||
@@ -158,6 +158,11 @@ def define_comfyui_nodes(sdpppServer):
|
||||
FUNCTION = "action"
|
||||
CATEGORY = "SD-PPP"
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(self, **kwargs):
|
||||
sdppp_arg = kwargs['sdppp']
|
||||
return sdppp_is_changed(sdppp, sdppp_arg, '')
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
@@ -172,8 +177,8 @@ def define_comfyui_nodes(sdpppServer):
|
||||
document = json.loads(document_name)
|
||||
result = call_async_func_in_server_thread(
|
||||
ProtocolPhotoshop.get_document_info(
|
||||
sdpppServer.backend_instances[document['instance_id']],
|
||||
document['identify']
|
||||
instance_id=document['instance_id'],
|
||||
document_identify=document['identify']
|
||||
)
|
||||
)
|
||||
|
||||
@@ -212,8 +217,8 @@ def define_comfyui_nodes(sdpppServer):
|
||||
|
||||
result = call_async_func_in_server_thread(
|
||||
ProtocolPhotoshop.get_layer_info(
|
||||
sdpppServer.backend_instances[document['instance_id']],
|
||||
document['identify'],
|
||||
instance_id=document['instance_id'],
|
||||
document_identify=document['identify'],
|
||||
layer_identify=layer_or_group
|
||||
)
|
||||
)
|
||||
@@ -257,7 +262,7 @@ def define_comfyui_nodes(sdpppServer):
|
||||
|
||||
result = call_async_func_in_server_thread(
|
||||
ProtocolPhotoshop.get_layers_in_group(
|
||||
backend_instance=sdpppServer.backend_instances[document['instance_id']],
|
||||
instance_id=document['instance_id'],
|
||||
document_identify=document['identify'],
|
||||
select=select[0],
|
||||
layer_identifies=layer_identifies
|
||||
@@ -303,7 +308,7 @@ def define_comfyui_nodes(sdpppServer):
|
||||
|
||||
result = call_async_func_in_server_thread(
|
||||
ProtocolPhotoshop.get_linked_layers(
|
||||
backend_instance=sdpppServer.backend_instances[document['instance_id']],
|
||||
instance_id=document['instance_id'],
|
||||
document_identify=document['identify'],
|
||||
select=select[0],
|
||||
layer_identifies=layer_identifies
|
||||
@@ -349,7 +354,7 @@ def define_comfyui_nodes(sdpppServer):
|
||||
|
||||
result = call_async_func_in_server_thread(
|
||||
ProtocolPhotoshop.get_selection(
|
||||
backend_instance=sdpppServer.backend_instances[document['instance_id']],
|
||||
instance_id=document['instance_id'],
|
||||
document_identify=document['identify'],
|
||||
boundary=convert_mask_to_boundary(bound),
|
||||
)
|
||||
@@ -437,7 +442,7 @@ def define_comfyui_nodes(sdpppServer):
|
||||
|
||||
text = call_async_func_in_server_thread(
|
||||
ProtocolPhotoshop.get_text(
|
||||
backend_instance=sdpppServer.backend_instances[document['instance_id']],
|
||||
instance_id=document['instance_id'],
|
||||
document_identify=document['identify'],
|
||||
layer_identify=item_layer
|
||||
)
|
||||
|
||||
@@ -96,7 +96,7 @@ def define_comfyui_nodes_legacy(sdppp):
|
||||
start = time.time()
|
||||
result = call_async_func_in_server_thread(
|
||||
ProtocolPhotoshop.get_image(
|
||||
backend_instance=sdppp.backend_instances[document['instance_id']],
|
||||
instance_id=document['instance_id'],
|
||||
document_identify=document['identify'],
|
||||
layer_identify=item_layer,
|
||||
boundary=convert_mask_to_boundary(item_bound)
|
||||
@@ -231,7 +231,7 @@ def define_comfyui_nodes_legacy(sdppp):
|
||||
})
|
||||
|
||||
call_async_func_in_server_thread(ProtocolPhotoshop.send_images(
|
||||
backend_instance=sdppp.backend_instances[document['instance_id']],
|
||||
instance_id=document['instance_id'],
|
||||
document_identify=document['identify'],
|
||||
image_blobs=[p['image_blob'] for p in params],
|
||||
layer_identifies=[p['layer_identify'] for p in params],
|
||||
|
||||
@@ -10,8 +10,15 @@ async def protocol_call(backend_instance, protocol_name, data):
|
||||
return result
|
||||
|
||||
class ProtocolPhotoshop:
|
||||
sdpppServer = None
|
||||
|
||||
@classmethod
|
||||
async def get_image(cls, backend_instance, document_identify, layer_identify, boundary):
|
||||
def set_sdppp_server(cls, sdpppServer):
|
||||
cls.sdpppServer = sdpppServer
|
||||
|
||||
@classmethod
|
||||
async def get_image(cls, instance_id, document_identify, layer_identify, boundary):
|
||||
backend_instance = cls.sdpppServer.backend_instances[instance_id]
|
||||
result = await protocol_call(backend_instance, 's_get_image', data={
|
||||
'document_identify': document_identify,
|
||||
'layer_identify': layer_identify,
|
||||
@@ -20,7 +27,8 @@ class ProtocolPhotoshop:
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
async def send_images(cls, backend_instance, document_identify, layer_identifies, boundaries, image_urls=[], image_blobs=[]):
|
||||
async def send_images(cls, instance_id, document_identify, layer_identifies, boundaries, image_urls=[], image_blobs=[]):
|
||||
backend_instance = cls.sdpppServer.backend_instances[instance_id]
|
||||
result = await protocol_call(backend_instance, 's_send_images', data={
|
||||
'document_identify': document_identify,
|
||||
'layer_identifies': layer_identifies,
|
||||
@@ -31,7 +39,8 @@ class ProtocolPhotoshop:
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
async def get_text(cls, backend_instance, document_identify, layer_identify):
|
||||
async def get_text(cls, instance_id, document_identify, layer_identify):
|
||||
backend_instance = cls.sdpppServer.backend_instances[instance_id]
|
||||
result = await protocol_call(backend_instance, 's_get_text', data={
|
||||
'document_identify': document_identify,
|
||||
'layer_identify': layer_identify
|
||||
@@ -39,7 +48,8 @@ class ProtocolPhotoshop:
|
||||
return result['text']
|
||||
|
||||
@classmethod
|
||||
async def get_selection(cls, backend_instance, document_identify, boundary):
|
||||
async def get_selection(cls, instance_id, document_identify, boundary):
|
||||
backend_instance = cls.sdpppServer.backend_instances[instance_id]
|
||||
result = await protocol_call(backend_instance, 's_get_selection', data={
|
||||
'document_identify': document_identify,
|
||||
'boundary': boundary
|
||||
@@ -47,14 +57,16 @@ class ProtocolPhotoshop:
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
async def get_document_info(cls, backend_instance, document_identify):
|
||||
async def get_document_info(cls, instance_id, document_identify):
|
||||
backend_instance = cls.sdpppServer.backend_instances[instance_id]
|
||||
result = await protocol_call(backend_instance, 's_get_document_info', data={
|
||||
'document_identify': document_identify
|
||||
})
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
async def get_layer_info(cls, backend_instance, document_identify, layer_identify="", layer_name=""):
|
||||
async def get_layer_info(cls, instance_id, document_identify, layer_identify="", layer_name=""):
|
||||
backend_instance = cls.sdpppServer.backend_instances[instance_id]
|
||||
result = await protocol_call(backend_instance, 's_get_layer_info', data={
|
||||
'document_identify': document_identify,
|
||||
'layer_identify': layer_identify,
|
||||
@@ -63,7 +75,8 @@ class ProtocolPhotoshop:
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
async def get_layers_in_group(cls, backend_instance, document_identify, layer_identifies, select):
|
||||
async def get_layers_in_group(cls, instance_id, document_identify, layer_identifies, select):
|
||||
backend_instance = cls.sdpppServer.backend_instances[instance_id]
|
||||
result = await protocol_call(backend_instance, 's_get_layers_in_group', data={
|
||||
'document_identify': document_identify,
|
||||
'select': select,
|
||||
@@ -72,7 +85,8 @@ class ProtocolPhotoshop:
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
async def get_linked_layers(cls, backend_instance, document_identify, layer_identifies, select):
|
||||
async def get_linked_layers(cls, instance_id, document_identify, layer_identifies, select):
|
||||
backend_instance = cls.sdpppServer.backend_instances[instance_id]
|
||||
result = await protocol_call(backend_instance, 's_get_linked_layers', data={
|
||||
'document_identify': document_identify,
|
||||
'select': select,
|
||||
|
||||
+13
-7
@@ -2,6 +2,8 @@ import socketio
|
||||
import os.path as path
|
||||
from .instances import BackendInstance, PageInstance
|
||||
from .apis import registerSocketEvents, registerComfyHTTPEndpoints, registerSDHTTPEndpoints
|
||||
import re
|
||||
import threading
|
||||
|
||||
# Define projectRoot as parent directory of current file
|
||||
projectRoot = path.dirname(path.dirname(__file__))
|
||||
@@ -67,7 +69,10 @@ class SDPPP:
|
||||
qs = environ['QUERY_STRING']
|
||||
|
||||
qsobj = dict(x.split('=') for x in qs.split('&'))
|
||||
if 'api_level' not in qsobj or qsobj['api_level'] != "411":
|
||||
api_level = None
|
||||
with open(path.join(projectRoot, 'sdppp_python', 'version.txt'), 'r') as f:
|
||||
api_level = f.read()
|
||||
if api_level is not None and ('api_level' not in qsobj or qsobj['api_level'] != api_level):
|
||||
raise socketio.exceptions.ConnectionRefusedError('version mismatch, please reinstall PS plugin')
|
||||
|
||||
@sio.event
|
||||
@@ -106,11 +111,12 @@ class SDPPP:
|
||||
registerSocketEvents(self, self.sio)
|
||||
|
||||
def has_ps_instance(self, throw_error = False):
|
||||
for instance in self.backend_instances.values():
|
||||
if instance.type == 'photoshop':
|
||||
return True
|
||||
if throw_error:
|
||||
raise ValueError('no Photoshop instance found')
|
||||
return False
|
||||
return True
|
||||
# for instance in self.backend_instances.values():
|
||||
# if instance.type == 'photoshop':
|
||||
# return True
|
||||
# if throw_error:
|
||||
# raise ValueError('no Photoshop instance found')
|
||||
# return False
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
412
|
||||
Reference in New Issue
Block a user