修复AOS抠图轮询状态判断错误导致误判失败
This commit is contained in:
parent
2987bd793e
commit
49e8731e7f
@ -309,6 +309,12 @@ async function processWithAosSegmentation(
|
||||
|
||||
const state = Number(pollPayload.data.state);
|
||||
const imageUrl = pollPayload.data.image as string | undefined;
|
||||
const stateDetail = String(pollPayload.data.state_detail || "");
|
||||
const errMessage = String(pollPayload.data.err_message || pollPayload.data.err_info || "");
|
||||
|
||||
if (pollCount === 0 || pollCount % 5 === 0) {
|
||||
console.log(`[AOS RMBG] poll=${pollCount + 1} state=${state} detail=${stateDetail}`);
|
||||
}
|
||||
|
||||
if (state === 1 && imageUrl) {
|
||||
const imageResponse = await withTimeout(
|
||||
@ -335,10 +341,11 @@ async function processWithAosSegmentation(
|
||||
};
|
||||
}
|
||||
|
||||
if (state === 2 || state === 3 || state === -1) {
|
||||
// AOS: state=2(Preparing) 属于处理中,不能当失败;只有负数状态视为失败
|
||||
if (state < 0) {
|
||||
return {
|
||||
success: false,
|
||||
error: `AOS任务失败: ${pollPayload?.message || "状态异常"}`,
|
||||
error: `AOS任务失败: ${errMessage || stateDetail || pollPayload?.message || "状态异常"}`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user