diff --git a/change_app.py b/change_app.py index 79fe68a..dfbe0a8 100644 --- a/change_app.py +++ b/change_app.py @@ -513,10 +513,10 @@ def image_to_base64(file_path, with_head = True): def upload_to_oss(image_path, object_name=None): # 配置信息(替换为你的实际信息) - access_key_id = 'LTAI5tB9t2RH6f1drSLvVLLZ' - access_key_secret = '91uzPI1RAFHN7n3Y6TJDGFP8w0dG1R' + access_key_id = 'LTAI5tGp1sLzedqxihcNC1eb' + access_key_secret = 'IFZE1b8YYreCP6zfA6GaZ9uBT678qO' endpoint = 'oss-cn-beijing.aliyuncs.com' # 替换为你的Endpoint - bucket_name = 'llyz' + bucket_name = 'xiangsilian' # 创建Bucket实例 auth = oss2.Auth(access_key_id, access_key_secret) @@ -615,7 +615,7 @@ def process_change_banana(human_filename, cloth_filename, output_format): jpg_path_name = f'{APP_ROOT}/static/imgs/{jpg_name}' image.save(jpg_path_name, quality=90) upload_to_oss(jpg_path_name, jpg_name) - https_url = f'https://llyz.oss-cn-beijing.aliyuncs.com/{jpg_name}' + https_url = f'https://xiangsilian.oss-cn-beijing.aliyuncs.com/{jpg_name}' if img_data: if 'base64' in output_format: @@ -658,7 +658,7 @@ def process_change_cloth(human_filename, cloth_filename, output_format, img_url, out_human_jpg_path_name = f'{APP_ROOT}/static/imgs/{out_human_jpg_name}' out_human_image.save(out_human_jpg_path_name, quality=90) upload_to_oss(out_human_jpg_path_name, out_human_jpg_name) # 第二个参数可选,指定OSS上的路径 - out_human_https_url = f'https://llyz.oss-cn-beijing.aliyuncs.com/{out_human_jpg_name}' + out_human_https_url = f'https://xiangsilian.oss-cn-beijing.aliyuncs.com/{out_human_jpg_name}' print(f"生成的第一步图片 HTTPS URL: {out_human_https_url}") image = Image.open(f'{APP_ROOT}/../output/{out_put_name}') @@ -668,7 +668,7 @@ def process_change_cloth(human_filename, cloth_filename, output_format, img_url, upload_to_oss(jpg_path_name, jpg_name) # 第二个参数可选,指定OSS上的路径 - https_url = f'https://llyz.oss-cn-beijing.aliyuncs.com/{jpg_name}' + https_url = f'https://xiangsilian.oss-cn-beijing.aliyuncs.com/{jpg_name}' print(f"生成的HTTPS URL: {https_url}") out_befor_kuzi_url = https_url @@ -686,7 +686,7 @@ def process_change_cloth(human_filename, cloth_filename, output_format, img_url, image.save(jpg_path_name, quality=90) upload_to_oss(jpg_path_name, jpg_name) # 第二个参数可选,指定OSS上的路径 - https_url = f'https://llyz.oss-cn-beijing.aliyuncs.com/{jpg_name}' + https_url = f'https://xiangsilian.oss-cn-beijing.aliyuncs.com/{jpg_name}' print(f"生成的加上换裤子的 HTTPS URL: {https_url}") @@ -755,6 +755,8 @@ def do_change_cloth(): """从 URL 下载图片""" data = request.json + print(f"do_change_cloth input data:{data}") + human_url = data.get("human_url") human_filename = save_image_from_url(human_url) @@ -892,6 +894,7 @@ def change_cloth(): def change_cloth_base64(): # 获取参数 data = request.get_json() + print(f"change_cloth_base64 input data:{data}") if not data: return jsonify({"ret":-1, "state":-1, 'msg': 'No JSON data provided'}), 400 diff --git a/config.py b/config.py index 7e66284..088a703 100644 --- a/config.py +++ b/config.py @@ -4,7 +4,7 @@ import logging QUEUE_NAME = 'task_queue' # 配置 -REDIS_HOST = '192.168.101.118' +REDIS_HOST = '127.0.0.1'#'192.168.101.118' REDIS_PORT = 6379 REDIS_DB = 0 DEFAULT_TIMEOUT = (60*20) diff --git a/http_app.py b/http_app.py index 4989280..c81ffed 100644 --- a/http_app.py +++ b/http_app.py @@ -255,10 +255,10 @@ def image_to_base64(file_path, mime_type=None): def upload_to_oss(image_path, object_name=None): # 配置信息(替换为你的实际信息) - access_key_id = 'LTAI5tB9t2RH6f1drSLvVLLZ' - access_key_secret = '91uzPI1RAFHN7n3Y6TJDGFP8w0dG1R' + access_key_id = 'LTAI5tGp1sLzedqxihcNC1eb' + access_key_secret = 'IFZE1b8YYreCP6zfA6GaZ9uBT678qO' endpoint = 'oss-cn-beijing.aliyuncs.com' # 替换为你的Endpoint - bucket_name = 'llyz' + bucket_name = 'xiangsilian' # 创建Bucket实例 auth = oss2.Auth(access_key_id, access_key_secret) @@ -300,7 +300,7 @@ def process_change_cloth(human_filename, cloth_filename, output_format, img_url, upload_to_oss(jpg_path_name, jpg_name) # 第二个参数可选,指定OSS上的路径 - https_url = f'https://llyz.oss-cn-beijing.aliyuncs.com/{jpg_name}' + https_url = f'https://xiangsilian.oss-cn-beijing.aliyuncs.com/{jpg_name}' print(f"生成的HTTPS URL: {https_url}") if 'base64' in output_format: @@ -394,6 +394,7 @@ def save_image_from_url(image_url): def change_cloth(): """从 URL 下载图片""" data = request.json + print(f"change_cloth data: {data}") is_generated = data.get("is_generated") # if not is_generated: @@ -406,6 +407,7 @@ def change_cloth(): if not human_url: return jsonify({"error": "Missing 'human_url' parameter"}), 400 + human_filename = save_image_from_url(human_url) if not human_filename: return jsonify({"error": "Failed to download or save human image"}), 500 diff --git a/oss_test.py b/oss_test.py index a250506..701b995 100644 --- a/oss_test.py +++ b/oss_test.py @@ -2,10 +2,10 @@ import oss2 def upload_to_oss(image_path, object_name=None): # 配置信息(替换为你的实际信息) - access_key_id = 'LTAI5tB9t2RH6f1drSLvVLLZ' - access_key_secret = '91uzPI1RAFHN7n3Y6TJDGFP8w0dG1R' + access_key_id = 'LTAI5tGp1sLzedqxihcNC1eb' + access_key_secret = 'IFZE1b8YYreCP6zfA6GaZ9uBT678qO' endpoint = 'oss-cn-beijing.aliyuncs.com' # 替换为你的Endpoint - bucket_name = 'llyz' + bucket_name = 'xiangsilian' # 创建Bucket实例 auth = oss2.Auth(access_key_id, access_key_secret) @@ -34,5 +34,5 @@ def upload_to_oss(image_path, object_name=None): # 使用示例 image_path = '/home/xsl/code/ComfyUI/change_cloth/girl8010.jpg' # 本地图片路径 upload_to_oss(image_path, 'girl8011.jpg') # 第二个参数可选,指定OSS上的路径 -https_url = f'https://llyz.oss-cn-beijing.aliyuncs.com/girl8011.jpg' +https_url = f'https://xiangsilian.oss-cn-beijing.aliyuncs.com/girl8011.jpg' print(f"生成的HTTPS URL: {https_url}") diff --git a/static/img.html b/static/img.html new file mode 100644 index 0000000..370e13a --- /dev/null +++ b/static/img.html @@ -0,0 +1,186 @@ + + +
+ + +