diff --git a/app.py b/app.py index 9b822c3..18c98b6 100644 --- a/app.py +++ b/app.py @@ -31,7 +31,7 @@ def gen_image(): @app.route('/gen_group_pic', methods=['POST']) -def init_gen_group_pic(): +def gen_group_pic(): if request.is_json: data = request.get_json() coordinates_list = data['coordinates_list'] @@ -50,7 +50,7 @@ def init_gen_group_pic(): coordinates_list[i] = coordinates_list[i]['coordinates'] openpose_image_path = opg.save_bodypose_mulit(canvas_size[0], canvas_size[1], coordinates_list, pid) - # gen_group_pic(openpose_image_path, base_image, pid, opg.server_address) + gen_group_pic_prompt(openpose_image_path, base_image, pid, opg.server_address) return jsonify({"status": "success", "message": "Data received"}), 201 else: @@ -63,7 +63,7 @@ def gen_fencer_prompt(openpose_image_path, pid, comfyUI_address): prompt_json = f.read() prompt = json.loads(prompt_json) - openpose_image_name = opg.upload_image_circular_queue(openpose_image_path, 20, pid) + openpose_image_name = opg.upload_image_circular_queue(openpose_image_path, 20, pid, comfyUI_address) opg.upload_image("ref_black.png", "ref_black.png") prompt["3"]["inputs"]["seed"] = random.randint(0, 10000000000) @@ -72,17 +72,17 @@ def gen_fencer_prompt(openpose_image_path, pid, comfyUI_address): opg.queue_prompt(prompt, comfyUI_address) -def gen_group_pic(openpose_image_path, base_image, pid, comfyUI_address): - with open("groupAPI.json", "r") as f: +def gen_group_pic_prompt(openpose_image_path, base_image, pid, comfyUI_address): + with open("group_pic.json", "r") as f: prompt_json = f.read() prompt = json.loads(prompt_json) - openpose_image_name = opg.upload_image_circular_queue(openpose_image_path, 30, pid) - base_image_name = opg.upload_image_circular_queue(base_image, 30, pid) + openpose_image_name = opg.upload_image_circular_queue(openpose_image_path, 30, pid, comfyUI_address) + base_image_name = opg.upload_image_circular_queue(base_image, 30, pid, comfyUI_address) prompt["3"]["inputs"]["seed"] = random.randint(0, 10000000000) - prompt["17"]["inputs"]['image'] = openpose_image_name - prompt["17"]["inputs"]['image'] = base_image_name + prompt["10"]["inputs"]['image'] = openpose_image_name + prompt["14"]["inputs"]['image'] = base_image_name opg.queue_prompt(prompt, comfyUI_address) diff --git a/openpose_gen.py b/openpose_gen.py index ec380b2..abd8d5f 100644 --- a/openpose_gen.py +++ b/openpose_gen.py @@ -14,6 +14,8 @@ import sys import hashlib sys.path.append('./') +server_address = "localhost:8188" + def is_normalized(keypoints: List[skel.Keypoint]) -> bool: for keypoint in keypoints: if not (0 <= keypoint.x <= 1 and 0 <= keypoint.y <= 1): @@ -119,8 +121,6 @@ def save_bodypose_mulit(width: int, height: int, coordinates_list: list, pid: st return image_path -server_address = "localhost:8188" - def queue_prompt(prompt, server_address): p = {"prompt": prompt} data = json.dumps(p).encode('utf-8') diff --git a/requirement.txt b/requirement.txt index 72e1634..cd940db 100644 --- a/requirement.txt +++ b/requirement.txt @@ -1,18 +1,24 @@ blinker==1.8.2 +certifi==2024.8.30 cffi==1.17.1 +charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 filelock==3.16.1 Flask==3.0.3 gevent==24.2.1 greenlet==3.1.1 +idna==3.10 itsdangerous==2.2.0 Jinja2==3.1.4 MarkupSafe==2.1.5 numpy==2.1.1 opencv-python==4.10.0.84 pycparser==2.22 +requests==2.32.3 +requests-toolbelt==1.0.0 setuptools==75.1.0 +urllib3==2.2.3 uuid==1.30 websocket==0.2.1 Werkzeug==3.0.4 diff --git a/test.png b/test.png index 0a1526a..3651912 100644 Binary files a/test.png and b/test.png differ