This commit is contained in:
jeremygan2021
2026-02-17 12:14:27 +08:00
parent 4659802f7a
commit a4475e743d
3 changed files with 52 additions and 10 deletions

View File

@@ -70,7 +70,8 @@ HISTORY_FILE = "history.json"
# Dashscope (Qwen-VL) 配置
dashscope.api_key = 'sk-ce2404f55f744a1987d5ece61c6bac58'
QWEN_MODEL = 'qwen-vl-max'
QWEN_MODEL = 'qwen-vl-max' # Default model
AVAILABLE_QWEN_MODELS = ["qwen-vl-max", "qwen-vl-plus"]
# API Tags (用于文档分类)
TAG_GENERAL = "General Segmentation (通用分割)"
@@ -1019,7 +1020,8 @@ async def segment_face(
processor=processor,
image=image,
prompt=final_prompt,
output_base_dir=RESULT_IMAGE_DIR
output_base_dir=RESULT_IMAGE_DIR,
qwen_model=QWEN_MODEL
)
except Exception as e:
import traceback
@@ -1222,9 +1224,23 @@ async def get_config(request: Request):
"device": device,
"cleanup_enabled": os.getenv("AUTO_CLEANUP_ENABLED"),
"file_lifetime": os.getenv("FILE_LIFETIME_SECONDS"),
"cleanup_interval": os.getenv("CLEANUP_INTERVAL_SECONDS")
"cleanup_interval": os.getenv("CLEANUP_INTERVAL_SECONDS"),
"current_qwen_model": QWEN_MODEL,
"available_qwen_models": AVAILABLE_QWEN_MODELS
}
@app.post("/admin/api/config/model", dependencies=[Depends(verify_admin)])
async def set_model(model: str = Form(...)):
"""
Set the Qwen model
"""
global QWEN_MODEL
if model not in AVAILABLE_QWEN_MODELS:
raise HTTPException(status_code=400, detail="Invalid model")
QWEN_MODEL = model
return {"status": "success", "message": f"Model switched to {model}", "current_model": QWEN_MODEL}
# ==========================================
# 10. Main Entry Point (启动入口)
# ==========================================