tom12112 commited on
Commit
4d2ad30
·
verified ·
1 Parent(s): 3372d56

Upload api_only.py

Browse files
Files changed (1) hide show
  1. iopaint/api_only.py +13 -3
iopaint/api_only.py CHANGED
@@ -45,6 +45,9 @@ logger.info(f"Allowed origins: {allowed_origins}")
45
  # 初始化FastAPI
46
  app = FastAPI(title="IOPaint API")
47
 
 
 
 
48
  # 配置API,添加所有缺失的必填字段
49
  config = ApiConfig(
50
  host=host,
@@ -57,14 +60,14 @@ config = ApiConfig(
57
  low_mem=os.environ.get("IOPAINT_LOW_MEM", "true").lower() == "true",
58
  no_half=os.environ.get("IOPAINT_NO_HALF", "false").lower() == "true",
59
  cpu_offload=os.environ.get("IOPAINT_CPU_OFFLOAD", "false").lower() == "true",
60
- disable_nsfw=os.environ.get("IOPAINT_DISABLE_NSFW", "false").lower() == "true",
61
- # 添加缺失的必填字段
62
  enable_interactive_seg=False,
63
  interactive_seg_model=InteractiveSegModel.sam2_1_tiny,
64
  interactive_seg_device=Device.cpu,
65
  enable_remove_bg=False,
66
  remove_bg_device=Device.cpu,
67
- remove_bg_model=RemoveBGModel.briaai_rmbg_1_4,
68
  enable_anime_seg=False,
69
  enable_realesrgan=False,
70
  realesrgan_device=Device.cpu,
@@ -73,6 +76,13 @@ config = ApiConfig(
73
  gfpgan_device=Device.cpu,
74
  enable_restoreformer=False,
75
  restoreformer_device=Device.cpu,
 
 
 
 
 
 
 
76
  )
77
 
78
  # 配置CORS
 
45
  # 初始化FastAPI
46
  app = FastAPI(title="IOPaint API")
47
 
48
+ # 读取disable_nsfw环境变量,确保两个字段使用相同的值
49
+ disable_nsfw_value = os.environ.get("IOPAINT_DISABLE_NSFW", "false").lower() == "true"
50
+
51
  # 配置API,添加所有缺失的必填字段
52
  config = ApiConfig(
53
  host=host,
 
60
  low_mem=os.environ.get("IOPAINT_LOW_MEM", "true").lower() == "true",
61
  no_half=os.environ.get("IOPAINT_NO_HALF", "false").lower() == "true",
62
  cpu_offload=os.environ.get("IOPAINT_CPU_OFFLOAD", "false").lower() == "true",
63
+ disable_nsfw=disable_nsfw_value,
64
+ # 添加之前缺失的必填字段
65
  enable_interactive_seg=False,
66
  interactive_seg_model=InteractiveSegModel.sam2_1_tiny,
67
  interactive_seg_device=Device.cpu,
68
  enable_remove_bg=False,
69
  remove_bg_device=Device.cpu,
70
+ remove_bg_model="briaai/RMBG-1.4", # 修正为字符串类型而不是枚举
71
  enable_anime_seg=False,
72
  enable_realesrgan=False,
73
  realesrgan_device=Device.cpu,
 
76
  gfpgan_device=Device.cpu,
77
  enable_restoreformer=False,
78
  restoreformer_device=Device.cpu,
79
+ # 添加新发现缺失的必填字段
80
+ inbrowser=False,
81
+ disable_nsfw_checker=disable_nsfw_value, # 使用相同的值
82
+ local_files_only=False,
83
+ cpu_textencoder=False,
84
+ mask_dir=None,
85
+ quality=100,
86
  )
87
 
88
  # 配置CORS