save code
This commit is contained in:
+11
-11
@@ -56,7 +56,7 @@ def takeoff_cloth_first(human_name):
|
||||
if queue["queue_running"] or queue["queue_pending"]:
|
||||
return None, "cur gpu is busy"
|
||||
|
||||
with open('/home/szlc/code/ComfyUI/change_cloth/change_new.json', 'r', encoding='utf-8') as file:
|
||||
with open('/home/xsl/code/ComfyUI/change_cloth/change_new.json', 'r', encoding='utf-8') as file:
|
||||
prompt_text = file.read()
|
||||
|
||||
prompt = json.loads(prompt_text)
|
||||
@@ -122,15 +122,15 @@ def change(human_name, cloth_name, c_width, c_height, cloth_url, is_generated):
|
||||
return None, f"takeoff_cloth_first error {human_name}"
|
||||
else:
|
||||
human_name = takeoff_file_name
|
||||
takeoff_file_path_name = os.path.join('/home/szlc/code/ComfyUI/output', takeoff_file_name)
|
||||
takeoff_file_path_name_input = os.path.join('/home/szlc/code/ComfyUI/input', takeoff_file_name)
|
||||
takeoff_file_path_name = os.path.join('/home/xsl/code/ComfyUI/output', takeoff_file_name)
|
||||
takeoff_file_path_name_input = os.path.join('/home/xsl/code/ComfyUI/input', takeoff_file_name)
|
||||
shutil.copy(takeoff_file_path_name, takeoff_file_path_name_input)
|
||||
|
||||
queue = requests.get("http://localhost:8188/queue").json()
|
||||
if queue["queue_running"] or queue["queue_pending"]:
|
||||
return None, "cur gpu is busy"
|
||||
|
||||
with open('/home/szlc/code/ComfyUI/change_cloth/change_new.json', 'r', encoding='utf-8') as file:
|
||||
with open('/home/xsl/code/ComfyUI/change_cloth/change_new.json', 'r', encoding='utf-8') as file:
|
||||
prompt_text = file.read()
|
||||
|
||||
prompt = json.loads(prompt_text)
|
||||
@@ -207,13 +207,13 @@ def save_base64_image(base64_str, prefix):
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
unique_id = str(uuid.uuid4())[:8]
|
||||
filename = f"{prefix}_{timestamp}_{unique_id}{file_ext}"
|
||||
filepath = os.path.join('/home/szlc/code/ComfyUI/change_cloth/static/imgs', filename)
|
||||
filepath = os.path.join('/home/xsl/code/ComfyUI/change_cloth/static/imgs', filename)
|
||||
|
||||
# 解码并保存图片
|
||||
with open(filepath, 'wb') as f:
|
||||
f.write(base64.b64decode(data))
|
||||
|
||||
input_filepath = os.path.join('/home/szlc/code/ComfyUI/input', filename)
|
||||
input_filepath = os.path.join('/home/xsl/code/ComfyUI/input', filename)
|
||||
# 解码并保存图片
|
||||
with open(input_filepath, 'wb') as f:
|
||||
f.write(base64.b64decode(data))
|
||||
@@ -286,16 +286,16 @@ def upload_to_oss(image_path, object_name=None):
|
||||
|
||||
|
||||
def process_change_cloth(human_filename, cloth_filename, output_format, img_url, is_generated):
|
||||
w,h = get_image_dimensions(f'/home/szlc/code/ComfyUI/input/{human_filename}')
|
||||
w,h = get_image_dimensions(f'/home/xsl/code/ComfyUI/input/{human_filename}')
|
||||
|
||||
out_put_name, msg = change(human_filename, cloth_filename, w, h, img_url, is_generated)
|
||||
if out_put_name == None:
|
||||
print(f'Failed to change cloth {msg}')
|
||||
return jsonify({"ret":-1, 'msg': f'Failed to change cloth {msg}'}), 200
|
||||
|
||||
image = Image.open(f'/home/szlc/code/ComfyUI/output/{out_put_name}')
|
||||
image = Image.open(f'/home/xsl/code/ComfyUI/output/{out_put_name}')
|
||||
jpg_name = out_put_name.replace(".png", ".jpg")
|
||||
jpg_path_name = f'/home/szlc/code/ComfyUI/change_cloth/static/imgs/{jpg_name}'
|
||||
jpg_path_name = f'/home/xsl/code/ComfyUI/change_cloth/static/imgs/{jpg_name}'
|
||||
image.save(jpg_path_name, quality=95)
|
||||
|
||||
|
||||
@@ -376,13 +376,13 @@ def save_image_from_url(image_url):
|
||||
# 获取原始图片格式
|
||||
ext = get_file_extension(image_url)
|
||||
filename = f"{uuid.uuid4()}{ext}"
|
||||
filepath = os.path.join('/home/szlc/code/ComfyUI/change_cloth/static/imgs', filename)
|
||||
filepath = os.path.join('/home/xsl/code/ComfyUI/change_cloth/static/imgs', filename)
|
||||
|
||||
with open(filepath, "wb") as f:
|
||||
for chunk in response.iter_content(1024):
|
||||
f.write(chunk)
|
||||
|
||||
input_filepath = os.path.join('/home/szlc/code/ComfyUI/input', filename)
|
||||
input_filepath = os.path.join('/home/xsl/code/ComfyUI/input', filename)
|
||||
shutil.copy(filepath, input_filepath)
|
||||
|
||||
return filename
|
||||
|
||||
Reference in New Issue
Block a user