chawin.chen
commited on
Commit
·
753f708
1
Parent(s):
28ee766
init
Browse files- Dockerfile +1 -1
- config.py +16 -15
Dockerfile
CHANGED
|
@@ -72,4 +72,4 @@ 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", "--host", "0.0.0.0", "--port", "7860"]
|
config.py
CHANGED
|
@@ -408,26 +408,27 @@ except ImportError:
|
|
| 408 |
# 检查GFPGAN是否启用和可用
|
| 409 |
if ENABLE_GFPGAN:
|
| 410 |
try:
|
| 411 |
-
# 检查GFPGAN相关文件是否存在
|
| 412 |
-
gfpgan_files_exist = True
|
| 413 |
required_files = [
|
| 414 |
-
"gfpgan_restorer.py",
|
| 415 |
-
|
| 416 |
-
|
| 417 |
]
|
| 418 |
|
| 419 |
-
for
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
else:
|
| 429 |
-
|
| 430 |
-
print("Warning: GFPGAN files missing, functionality disabled")
|
| 431 |
except ImportError as e:
|
| 432 |
print(f"Warning: GFPGAN enabled but not available: {e}")
|
| 433 |
GFPGAN_AVAILABLE = False
|
|
|
|
| 408 |
# 检查GFPGAN是否启用和可用
|
| 409 |
if ENABLE_GFPGAN:
|
| 410 |
try:
|
|
|
|
|
|
|
| 411 |
required_files = [
|
| 412 |
+
os.path.join(os.path.dirname(__file__), "gfpgan_restorer.py"),
|
| 413 |
+
os.path.join(MODELS_PATH, "gfpgan/weights/detection_Resnet50_Final.pth"),
|
| 414 |
+
os.path.join(MODELS_PATH, "gfpgan/weights/parsing_parsenet.pth"),
|
| 415 |
]
|
| 416 |
|
| 417 |
+
missing_files = [path for path in required_files if not os.path.exists(path)]
|
| 418 |
+
if missing_files:
|
| 419 |
+
for file_path in missing_files:
|
| 420 |
+
logger.info("GFPGAN 所需文件暂未找到,将等待模型同步: %s", file_path)
|
| 421 |
|
| 422 |
+
from gfpgan_restorer import GFPGANRestorer # noqa: F401
|
| 423 |
+
GFPGAN_AVAILABLE = True
|
| 424 |
+
|
| 425 |
+
if missing_files:
|
| 426 |
+
logger.warning(
|
| 427 |
+
"GFPGAN 文件尚未全部就绪,将在 HuggingFace/BOS 同步完成后继续初始化: %s",
|
| 428 |
+
", ".join(missing_files),
|
| 429 |
+
)
|
| 430 |
else:
|
| 431 |
+
logger.info("GFPGAN photo restoration feature prerequisites detected")
|
|
|
|
| 432 |
except ImportError as e:
|
| 433 |
print(f"Warning: GFPGAN enabled but not available: {e}")
|
| 434 |
GFPGAN_AVAILABLE = False
|