chenchaoyun commited on
Commit ·
616dc82
1
Parent(s): a1be5bb
fix
Browse files- Dockerfile +2 -1
- api_routes.py +15 -15
- start_local.sh +45 -6
Dockerfile
CHANGED
|
@@ -72,4 +72,5 @@ RUN pip install --upgrade pip
|
|
| 72 |
# 安装所有依赖 - 现在可以一次性完成
|
| 73 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 74 |
EXPOSE 7860
|
| 75 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
| 72 |
# 安装所有依赖 - 现在可以一次性完成
|
| 73 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 74 |
EXPOSE 7860
|
| 75 |
+
CMD ["uvicorn", "app:app", "--workers", "2", "--loop", "asyncio", "--http", "httptools", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "600"]
|
| 76 |
+
|
api_routes.py
CHANGED
|
@@ -968,7 +968,7 @@ async def upload_file(
|
|
| 968 |
saved_path = os.path.join(IMAGES_DIR, saved_filename)
|
| 969 |
with open(saved_path, "wb") as f:
|
| 970 |
f.write(contents)
|
| 971 |
-
bos_uploaded = upload_file_to_bos(saved_path)
|
| 972 |
else:
|
| 973 |
t1 = time.perf_counter()
|
| 974 |
logger.info(
|
|
@@ -985,7 +985,7 @@ async def upload_file(
|
|
| 985 |
detail="保存修复后图像失败")
|
| 986 |
logger.info(
|
| 987 |
f"ID photo restored and saved: {saved_filename}, time: {time.perf_counter() - t1:.3f}s")
|
| 988 |
-
bos_uploaded = upload_file_to_bos(saved_path)
|
| 989 |
|
| 990 |
# 可选:向量化入库(与其他接口保持一致)
|
| 991 |
if CLIP_AVAILABLE:
|
|
@@ -2103,7 +2103,7 @@ async def restore_old_photo(
|
|
| 2103 |
if CLIP_AVAILABLE:
|
| 2104 |
asyncio.create_task(handle_image_vector_async(restored_path, restored_filename))
|
| 2105 |
|
| 2106 |
-
bos_uploaded = upload_file_to_bos(restored_path)
|
| 2107 |
await _record_output_file(
|
| 2108 |
file_path=restored_path,
|
| 2109 |
nickname=nickname,
|
|
@@ -2213,7 +2213,7 @@ async def colorize_photo(
|
|
| 2213 |
if CLIP_AVAILABLE:
|
| 2214 |
asyncio.create_task(handle_image_vector_async(colored_path, colored_filename))
|
| 2215 |
|
| 2216 |
-
bos_uploaded = upload_file_to_bos(colored_path)
|
| 2217 |
await _record_output_file(
|
| 2218 |
file_path=colored_path,
|
| 2219 |
nickname=nickname,
|
|
@@ -2542,7 +2542,7 @@ async def grayscale_photo(
|
|
| 2542 |
if CLIP_AVAILABLE:
|
| 2543 |
asyncio.create_task(handle_image_vector_async(grayscale_path, grayscale_filename))
|
| 2544 |
|
| 2545 |
-
bos_uploaded = upload_file_to_bos(grayscale_path)
|
| 2546 |
await _record_output_file(
|
| 2547 |
file_path=grayscale_path,
|
| 2548 |
nickname=nickname,
|
|
@@ -2659,12 +2659,12 @@ async def upscale_photo(
|
|
| 2659 |
if CLIP_AVAILABLE:
|
| 2660 |
asyncio.create_task(handle_image_vector_async(upscaled_path, upscaled_filename))
|
| 2661 |
|
| 2662 |
-
bos_uploaded = upload_file_to_bos(upscaled_path)
|
| 2663 |
await _record_output_file(
|
| 2664 |
file_path=upscaled_path,
|
| 2665 |
nickname=nickname,
|
| 2666 |
category="upscale",
|
| 2667 |
-
bos_uploaded=
|
| 2668 |
extra={
|
| 2669 |
"source": "upscale",
|
| 2670 |
"md5": actual_md5,
|
|
@@ -2834,8 +2834,8 @@ async def remove_background(
|
|
| 2834 |
if bg_color is not None:
|
| 2835 |
# 有背景色,保存为JPEG
|
| 2836 |
save_success = save_image_high_quality(processed_image, processed_path, quality=SAVE_QUALITY)
|
| 2837 |
-
if save_success:
|
| 2838 |
-
|
| 2839 |
else:
|
| 2840 |
# 透明背景,保存为指定格式
|
| 2841 |
if output_format == "webp":
|
|
@@ -2851,8 +2851,8 @@ async def remove_background(
|
|
| 2851 |
else:
|
| 2852 |
# 保存为PNG格式
|
| 2853 |
save_success = save_image_with_transparency(processed_image, processed_path)
|
| 2854 |
-
if save_success:
|
| 2855 |
-
|
| 2856 |
|
| 2857 |
if save_success:
|
| 2858 |
total_time = time.perf_counter() - t1
|
|
@@ -3012,8 +3012,8 @@ async def rvm_remove_background(
|
|
| 3012 |
if bg_color is not None:
|
| 3013 |
# 有背景色,保存为JPEG
|
| 3014 |
save_success = save_image_high_quality(processed_image, processed_path, quality=SAVE_QUALITY)
|
| 3015 |
-
if save_success:
|
| 3016 |
-
|
| 3017 |
else:
|
| 3018 |
# 透明背景,保存为指定格式
|
| 3019 |
if output_format == "webp":
|
|
@@ -3029,8 +3029,8 @@ async def rvm_remove_background(
|
|
| 3029 |
else:
|
| 3030 |
# 保存为PNG格式
|
| 3031 |
save_success = save_image_with_transparency(processed_image, processed_path)
|
| 3032 |
-
if save_success:
|
| 3033 |
-
|
| 3034 |
|
| 3035 |
if save_success:
|
| 3036 |
total_time = time.perf_counter() - t1
|
|
|
|
| 968 |
saved_path = os.path.join(IMAGES_DIR, saved_filename)
|
| 969 |
with open(saved_path, "wb") as f:
|
| 970 |
f.write(contents)
|
| 971 |
+
# bos_uploaded = upload_file_to_bos(saved_path)
|
| 972 |
else:
|
| 973 |
t1 = time.perf_counter()
|
| 974 |
logger.info(
|
|
|
|
| 985 |
detail="保存修复后图像失败")
|
| 986 |
logger.info(
|
| 987 |
f"ID photo restored and saved: {saved_filename}, time: {time.perf_counter() - t1:.3f}s")
|
| 988 |
+
# bos_uploaded = upload_file_to_bos(saved_path)
|
| 989 |
|
| 990 |
# 可选:向量化入库(与其他接口保持一致)
|
| 991 |
if CLIP_AVAILABLE:
|
|
|
|
| 2103 |
if CLIP_AVAILABLE:
|
| 2104 |
asyncio.create_task(handle_image_vector_async(restored_path, restored_filename))
|
| 2105 |
|
| 2106 |
+
# bos_uploaded = upload_file_to_bos(restored_path)
|
| 2107 |
await _record_output_file(
|
| 2108 |
file_path=restored_path,
|
| 2109 |
nickname=nickname,
|
|
|
|
| 2213 |
if CLIP_AVAILABLE:
|
| 2214 |
asyncio.create_task(handle_image_vector_async(colored_path, colored_filename))
|
| 2215 |
|
| 2216 |
+
# bos_uploaded = upload_file_to_bos(colored_path)
|
| 2217 |
await _record_output_file(
|
| 2218 |
file_path=colored_path,
|
| 2219 |
nickname=nickname,
|
|
|
|
| 2542 |
if CLIP_AVAILABLE:
|
| 2543 |
asyncio.create_task(handle_image_vector_async(grayscale_path, grayscale_filename))
|
| 2544 |
|
| 2545 |
+
# bos_uploaded = upload_file_to_bos(grayscale_path)
|
| 2546 |
await _record_output_file(
|
| 2547 |
file_path=grayscale_path,
|
| 2548 |
nickname=nickname,
|
|
|
|
| 2659 |
if CLIP_AVAILABLE:
|
| 2660 |
asyncio.create_task(handle_image_vector_async(upscaled_path, upscaled_filename))
|
| 2661 |
|
| 2662 |
+
# bos_uploaded = upload_file_to_bos(upscaled_path)
|
| 2663 |
await _record_output_file(
|
| 2664 |
file_path=upscaled_path,
|
| 2665 |
nickname=nickname,
|
| 2666 |
category="upscale",
|
| 2667 |
+
bos_uploaded=True,
|
| 2668 |
extra={
|
| 2669 |
"source": "upscale",
|
| 2670 |
"md5": actual_md5,
|
|
|
|
| 2834 |
if bg_color is not None:
|
| 2835 |
# 有背景色,保存为JPEG
|
| 2836 |
save_success = save_image_high_quality(processed_image, processed_path, quality=SAVE_QUALITY)
|
| 2837 |
+
# if save_success:
|
| 2838 |
+
# bos_uploaded = upload_file_to_bos(processed_path)
|
| 2839 |
else:
|
| 2840 |
# 透明背景,保存为指定格式
|
| 2841 |
if output_format == "webp":
|
|
|
|
| 2851 |
else:
|
| 2852 |
# 保存为PNG格式
|
| 2853 |
save_success = save_image_with_transparency(processed_image, processed_path)
|
| 2854 |
+
# if save_success:
|
| 2855 |
+
# bos_uploaded = upload_file_to_bos(processed_path)
|
| 2856 |
|
| 2857 |
if save_success:
|
| 2858 |
total_time = time.perf_counter() - t1
|
|
|
|
| 3012 |
if bg_color is not None:
|
| 3013 |
# 有背景色,保存为JPEG
|
| 3014 |
save_success = save_image_high_quality(processed_image, processed_path, quality=SAVE_QUALITY)
|
| 3015 |
+
# if save_success:
|
| 3016 |
+
# bos_uploaded = upload_file_to_bos(processed_path)
|
| 3017 |
else:
|
| 3018 |
# 透明背景,保存为指定格式
|
| 3019 |
if output_format == "webp":
|
|
|
|
| 3029 |
else:
|
| 3030 |
# 保存为PNG格式
|
| 3031 |
save_success = save_image_with_transparency(processed_image, processed_path)
|
| 3032 |
+
# if save_success:
|
| 3033 |
+
# bos_uploaded = upload_file_to_bos(processed_path)
|
| 3034 |
|
| 3035 |
if save_success:
|
| 3036 |
total_time = time.perf_counter() - t1
|
start_local.sh
CHANGED
|
@@ -1,15 +1,54 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
export TZ=Asia/Shanghai
|
| 3 |
-
export HOSTNAME=
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
export AUTO_INIT_DDCOLOR=false
|
| 6 |
export AUTO_INIT_REALESRGAN=false
|
| 7 |
export AUTO_INIT_ANIME_STYLE=false
|
| 8 |
export AUTO_INIT_CLIP=false
|
| 9 |
-
export AUTO_INIT_RVM=
|
| 10 |
-
export RVM_LOCAL_REPO=/opt/data/models/RobustVideoMatting
|
| 11 |
-
export RVM_WEIGHTS_PATH=/opt/data/models/torch/hub/checkpoints/rvm_resnet50.pth
|
| 12 |
-
export RVM_MODEL=resnet50
|
| 13 |
export AUTO_INIT_REMBG=false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
uvicorn app:app --workers 1 --loop asyncio --http httptools --host 0.0.0.0 --port 7860 --timeout-keep-alive 600
|
| 15 |
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
export TZ=Asia/Shanghai
|
| 3 |
+
export HOSTNAME=ME
|
| 4 |
+
|
| 5 |
+
export OUTPUT_DIR=/opt/data/output
|
| 6 |
+
export IMAGES_DIR=/opt/data/images
|
| 7 |
+
export MODELS_PATH=/opt/data/models
|
| 8 |
+
export DEEPFACE_HOME=/opt/data/models
|
| 9 |
+
export FAISS_INDEX_DIR=/opt/data/faiss
|
| 10 |
+
export CELEBRITY_SOURCE_DIR=/opt/data/chinese_celeb_dataset
|
| 11 |
+
|
| 12 |
+
export GENDER_CONFIDENCE=1
|
| 13 |
+
export UPSCALE_SIZE=2
|
| 14 |
+
export AGE_CONFIDENCE=0.9999
|
| 15 |
+
export DRAW_SCORE=true
|
| 16 |
+
export FACE_CONFIDENCE=0.7
|
| 17 |
+
|
| 18 |
+
export ENABLE_DDCOLOR=true
|
| 19 |
+
export ENABLE_GFPGAN=true
|
| 20 |
+
export ENABLE_REALESRGAN=true
|
| 21 |
+
export ENABLE_ANIME_STYLE=true
|
| 22 |
+
export ENABLE_RVM=true
|
| 23 |
+
export ENABLE_REMBG=true
|
| 24 |
+
export ENABLE_CLIP=false
|
| 25 |
+
|
| 26 |
+
export CLEANUP_INTERVAL_HOURS=1
|
| 27 |
+
export CLEANUP_AGE_HOURS=1
|
| 28 |
+
|
| 29 |
+
export BEAUTY_ADJUST_GAMMA=0.8
|
| 30 |
+
export BEAUTY_ADJUST_MIN=1.0
|
| 31 |
+
export BEAUTY_ADJUST_MAX=9.0
|
| 32 |
+
export ENABLE_ANIME_PRELOAD=true
|
| 33 |
+
export ENABLE_LOGGING=true
|
| 34 |
+
export BEAUTY_ADJUST_ENABLED=true
|
| 35 |
+
|
| 36 |
+
export RVM_LOCAL_REPO=/opt/data/models/RobustVideoMatting
|
| 37 |
+
export RVM_WEIGHTS_PATH=/opt/data/models/torch/hub/checkpoints/rvm_resnet50.pth
|
| 38 |
+
export RVM_MODEL=resnet50
|
| 39 |
+
|
| 40 |
+
export AUTO_INIT_GFPGAN=false
|
| 41 |
export AUTO_INIT_DDCOLOR=false
|
| 42 |
export AUTO_INIT_REALESRGAN=false
|
| 43 |
export AUTO_INIT_ANIME_STYLE=false
|
| 44 |
export AUTO_INIT_CLIP=false
|
| 45 |
+
export AUTO_INIT_RVM=false
|
|
|
|
|
|
|
|
|
|
| 46 |
export AUTO_INIT_REMBG=false
|
| 47 |
+
|
| 48 |
+
export ENABLE_WARMUP=true
|
| 49 |
+
export REALESRGAN_MODEL=realesr-general-x4v3
|
| 50 |
+
export CELEBRITY_FIND_THRESHOLD=0.87
|
| 51 |
+
export FEMALE_AGE_ADJUSTMENT=4
|
| 52 |
+
|
| 53 |
uvicorn app:app --workers 1 --loop asyncio --http httptools --host 0.0.0.0 --port 7860 --timeout-keep-alive 600
|
| 54 |
|