PERF 修图节点改为生/修图节点
This commit is contained in:
parent
ed5ceae99c
commit
d7c49f25c2
|
|
@ -85,8 +85,8 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
"Jinja2RenderTemplate": "Jinja2格式Prompt模板渲染",
|
"Jinja2RenderTemplate": "Jinja2格式Prompt模板渲染",
|
||||||
"JMGestureCorrect": "人物侧身图片转为正面图-即梦",
|
"JMGestureCorrect": "人物侧身图片转为正面图-即梦",
|
||||||
"ModalClothesMask": "模特指定衣服替换为指定颜色",
|
"ModalClothesMask": "模特指定衣服替换为指定颜色",
|
||||||
"ModalEditCustom": "自定义Prompt修改图片",
|
"ModalEditCustom": "Prompt生/修图",
|
||||||
"ModalMidJourneyGenerateImage": "Prompt修图",
|
"ModalMidJourneyGenerateImage": "Prompt生/修图",
|
||||||
"ModalMidJourneyDescribeImage": "反推生图提示词",
|
"ModalMidJourneyDescribeImage": "反推生图提示词",
|
||||||
"JMCustom": "Prompt生视频",
|
"JMCustom": "Prompt生视频",
|
||||||
"VideoMerge":"顺序合并视频"
|
"VideoMerge":"顺序合并视频"
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class ModalClothesMask:
|
||||||
RETURN_NAMES = ("image",)
|
RETURN_NAMES = ("image",)
|
||||||
FUNCTION = "process"
|
FUNCTION = "process"
|
||||||
OUTPUT_NODE = False
|
OUTPUT_NODE = False
|
||||||
CATEGORY = "不忘科技-自定义节点🚩/图片/Gemini图像编辑"
|
CATEGORY = "不忘科技-自定义节点🚩/图片/Gemini"
|
||||||
|
|
||||||
def process(self, image: torch.Tensor, mask_color: str, clothes_type: str, endpoint: str):
|
def process(self, image: torch.Tensor, mask_color: str, clothes_type: str, endpoint: str):
|
||||||
try:
|
try:
|
||||||
|
|
@ -133,21 +133,23 @@ class ModalEditCustom:
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"image": ("IMAGE",),
|
|
||||||
"prompt": ("STRING", {"default": "将背景去除,输出原尺寸图片", "multiline": True}),
|
"prompt": ("STRING", {"default": "将背景去除,输出原尺寸图片", "multiline": True}),
|
||||||
"temperature": ("FLOAT", {"default": 0.1, "min": 0, "max": 2}),
|
"temperature": ("FLOAT", {"default": 0.1, "min": 0, "max": 2}),
|
||||||
"topP": ("FLOAT", {"default": 0.7, "min": 0, "max": 1}),
|
"topP": ("FLOAT", {"default": 0.7, "min": 0, "max": 1}),
|
||||||
"endpoint": ("STRING", {"default": "bowongai-dev--bowong-ai-video-gemini-fastapi-webapp.modal.run"}),
|
"endpoint": ("STRING", {"default": "bowongai-dev--bowong-ai-video-gemini-fastapi-webapp.modal.run"}),
|
||||||
},
|
},
|
||||||
|
"optional": {
|
||||||
|
"image": ("IMAGE",),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("IMAGE",)
|
RETURN_TYPES = ("IMAGE",)
|
||||||
RETURN_NAMES = ("image",)
|
RETURN_NAMES = ("image",)
|
||||||
FUNCTION = "process"
|
FUNCTION = "process"
|
||||||
OUTPUT_NODE = False
|
OUTPUT_NODE = False
|
||||||
CATEGORY = "不忘科技-自定义节点🚩/图片/Gemini图像编辑"
|
CATEGORY = "不忘科技-自定义节点🚩/图片/Gemini"
|
||||||
|
|
||||||
def process(self, image: torch.Tensor, prompt: str, temperature: float, topP: float, endpoint: str):
|
def process(self, prompt: str, temperature: float, topP: float, endpoint: str, **kwargs):
|
||||||
try:
|
try:
|
||||||
timeout = 60
|
timeout = 60
|
||||||
logger.info("获取token")
|
logger.info("获取token")
|
||||||
|
|
@ -155,6 +157,13 @@ class ModalEditCustom:
|
||||||
headers={'Authorization': 'Bearer bowong7777'}, timeout=timeout).json()[
|
headers={'Authorization': 'Bearer bowong7777'}, timeout=timeout).json()[
|
||||||
"access_token"]
|
"access_token"]
|
||||||
format = "PNG"
|
format = "PNG"
|
||||||
|
if "image" in kwargs and kwargs["image"] is not None:
|
||||||
|
image = kwargs["image"]
|
||||||
|
files = {"origin_image": (
|
||||||
|
'image.' + format.lower(), tensor_to_image_bytes(image, format),
|
||||||
|
f'image/{format.lower()}')}
|
||||||
|
else:
|
||||||
|
files = None
|
||||||
logger.info("请求图像编辑")
|
logger.info("请求图像编辑")
|
||||||
job_resp = send_request("post", f"https://{endpoint}/google/image/edit_custom",
|
job_resp = send_request("post", f"https://{endpoint}/google/image/edit_custom",
|
||||||
headers={'x-google-api-key': api_key},
|
headers={'x-google-api-key': api_key},
|
||||||
|
|
@ -163,9 +172,7 @@ class ModalEditCustom:
|
||||||
"temperature": temperature,
|
"temperature": temperature,
|
||||||
"topP": topP
|
"topP": topP
|
||||||
},
|
},
|
||||||
files={"origin_image": (
|
files=files,
|
||||||
'image.' + format.lower(), tensor_to_image_bytes(image, format),
|
|
||||||
f'image/{format.lower()}')},
|
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
job_resp.raise_for_status()
|
job_resp.raise_for_status()
|
||||||
job_resp = job_resp.json()
|
job_resp = job_resp.json()
|
||||||
|
|
@ -202,10 +209,12 @@ class ModalMidJourneyGenerateImage:
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"prompt": ("STRING", {"default": "一幅宏大壮美的山川画卷", "multiline": True}),
|
"prompt": ("STRING", {"default": "一幅宏大壮美的山川画卷", "multiline": True}),
|
||||||
"image": ("IMAGE",),
|
|
||||||
"endpoint": ("STRING", {"default": "bowongai-dev--text-video-agent-fastapi-app.modal.run"}),
|
"endpoint": ("STRING", {"default": "bowongai-dev--text-video-agent-fastapi-app.modal.run"}),
|
||||||
"timeout": ("INT", {"default": 120, "min": 10, "max": 600}),
|
"timeout": ("INT", {"default": 120, "min": 10, "max": 600}),
|
||||||
},
|
},
|
||||||
|
"optional": {
|
||||||
|
"image": ("IMAGE",),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("IMAGE",)
|
RETURN_TYPES = ("IMAGE",)
|
||||||
|
|
@ -214,16 +223,21 @@ class ModalMidJourneyGenerateImage:
|
||||||
OUTPUT_NODE = False
|
OUTPUT_NODE = False
|
||||||
CATEGORY = "不忘科技-自定义节点🚩/图片/Midjourney"
|
CATEGORY = "不忘科技-自定义节点🚩/图片/Midjourney"
|
||||||
|
|
||||||
def process(self, prompt: str, image:torch.Tensor, endpoint: str, timeout: int):
|
def process(self, prompt: str, endpoint: str, timeout: int, **kwargs):
|
||||||
try:
|
try:
|
||||||
logger.info("请求异步接口")
|
logger.info("请求异步接口")
|
||||||
interval = 2
|
interval = 2
|
||||||
format = "PNG"
|
format = "PNG"
|
||||||
job_resp = send_request("post", f"https://{endpoint}/api/mj/async/generate/image?prompt={prompt}",
|
if "image" in kwargs and kwargs["image"] is not None:
|
||||||
headers={'Authorization': 'Bearer bowong7777'},
|
image = kwargs["image"]
|
||||||
files = {"img_file": (
|
files = {"img_file": (
|
||||||
'image.' + format.lower(), tensor_to_image_bytes(image, format),
|
'image.' + format.lower(), tensor_to_image_bytes(image, format),
|
||||||
f'image/{format.lower()}')},
|
f'image/{format.lower()}')}
|
||||||
|
else:
|
||||||
|
files = None
|
||||||
|
job_resp = send_request("post", f"https://{endpoint}/api/mj/async/generate/image?prompt={prompt}",
|
||||||
|
headers={'Authorization': 'Bearer bowong7777'},
|
||||||
|
files=files,
|
||||||
timeout=150)
|
timeout=150)
|
||||||
job_resp.raise_for_status()
|
job_resp.raise_for_status()
|
||||||
job_resp = job_resp.json()
|
job_resp = job_resp.json()
|
||||||
|
|
@ -253,6 +267,7 @@ class ModalMidJourneyGenerateImage:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
class ModalMidJourneyDescribeImage:
|
class ModalMidJourneyDescribeImage:
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue