兼容人物识别失败

This commit is contained in:
北枳 2025-08-13 23:11:12 +08:00
parent 310ea1c49f
commit 7c16179288
7 changed files with 35 additions and 30 deletions

View File

@ -352,7 +352,7 @@ export function MediaViewer({
<GlassIconButton
icon={Edit3}
tooltip="Edit sketch"
onClick={() => handleEditClick('4', 'final')}
onClick={() => handleEditClick('3', 'final')}
/>
</motion.div>
)}
@ -766,7 +766,7 @@ export function MediaViewer({
<GlassIconButton
icon={Edit3}
tooltip="Edit sketch"
onClick={() => handleEditClick('2')}
onClick={() => handleEditClick('1')}
/>
</motion.div>
)}

View File

@ -1,6 +1,6 @@
import React, { useState, useRef, useEffect, forwardRef } from "react";
import { motion } from "framer-motion";
import { Sparkles, X, Plus, RefreshCw } from 'lucide-react';
import { Sparkles, X, Plus, RefreshCw, Loader2 } from 'lucide-react';
import MainEditor from "./main-editor/MainEditor";
import { cn } from "@/public/lib/utils";
import { TextToShotAdapter } from "@/app/service/adapter/textToShot";
@ -76,8 +76,8 @@ export const CharacterEditor = forwardRef<any, CharacterEditorProps>(({
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
>
<Sparkles className="w-3.5 h-3.5" />
<span>{isOptimizing ? "优化中..." : "智能优化"}</span>
{isOptimizing ? <Loader2 className="w-3.5 h-3.5 animate-spin" /> : <Sparkles className="w-3.5 h-3.5" />}
<span>{isOptimizing ? "Optimizing..." : "Optimization"}</span>
</motion.button>
</div>
);

View File

@ -34,7 +34,7 @@ interface EditModalProps {
const tabs = [
{ id: '0', label: 'Script', icon: FileText },
{ id: '1', label: 'Character', icon: Users },
{ id: '2', label: 'Scene', icon: Image },
// { id: '2', label: 'Scene', icon: Image },
{ id: '3', label: 'Video', icon: Video },
{ id: '4', label: 'Music', icon: Music },
// { id: '5', label: '剪辑', icon: Scissors },

View File

@ -109,6 +109,7 @@ export const PersonDetectionScene: React.FC<Props> = ({
// 处理外部失败状态
useEffect(() => {
if (isScanFailed && scanStatus === 'scanning') {
console.log('roleRecognitionResponse---isScanFailed', isScanFailed);
setScanStatus('failed');
}
}, [isScanFailed, scanStatus]);
@ -268,12 +269,12 @@ export const PersonDetectionScene: React.FC<Props> = ({
>
<div className="flex items-center gap-2">
{!isShowError ? (
<span className="text-cyan-400 text-sm font-medium tracking-wider">
<span className="text-cyan-400 text-sm font-medium tracking-wider whitespace-nowrap">
Intelligenting portrait recognition
</span>
) : (
<span className="text-red-400 text-sm font-medium tracking-wider">
{scanStatus === 'timeout' ? '识别超时,请重试' : '识别失败,请重试'}
<span className="text-red-400 text-sm font-medium tracking-wider whitespace-nowrap">
{scanStatus === 'timeout' ? 'Timeout, please try again' : 'Failed, please try again'}
</span>
)}
</div>
@ -379,7 +380,7 @@ export const PersonDetectionScene: React.FC<Props> = ({
<AnimatePresence>
{detections.length === 0 && triggerSuccess && (
<div className="absolute inset-0 flex items-center justify-center bg-black/40 backdrop-blur-sm">
<span className="text-white text-sm"></span>
<span className="text-white text-sm">No portrait detected</span>
</div>
)}
{detections.map((person, index) => {

View File

@ -52,11 +52,11 @@ export function ReplaceCharacterPanel({
return (
<ReplacePanel
title="替换新形象"
title="Replace the new role"
shots={shots}
item={role}
showAddToLibrary={showAddToLibrary}
addToLibraryText="新形象同步添加至角色库"
addToLibraryText="Add new role to library"
onClose={onClose}
onConfirm={onConfirm}
isLoading={isLoading}

View File

@ -20,7 +20,7 @@ export function ReplacePanel({
shots,
item,
showAddToLibrary = false,
addToLibraryText = "同步添加至库",
addToLibraryText = "Add to library",
onClose,
onConfirm,
}: ReplacePanelProps) {
@ -122,9 +122,9 @@ export function ReplacePanel({
{/* 提示信息 */}
<div className="flex items-center justify-between">
<div className="flex items-center gap-2 text-sm text-red-400">
<div className="flex items-center gap-2 text-red-400">
<CircleAlert className="w-4 h-4" />
<span className="text-blue-500">{shots.length}</span>
This role appears in <span className="text-blue-500 font-bold">{shots.length}</span> shots, replacing it will affect the following shots.
</div>
{/* <div className="flex items-center gap-2">
<input
@ -177,7 +177,7 @@ export function ReplacePanel({
className="w-full h-full object-cover"
/>
<div className="absolute inset-0 bg-black/50 flex items-center justify-center">
<div className="text-white text-sm">...</div>
<div className="text-white text-sm">Generating...</div>
</div>
</>
)}
@ -235,13 +235,13 @@ export function ReplacePanel({
onClick={onClose}
className="px-4 py-2 rounded-lg bg-white/10 text-white hover:bg-white/20 transition-colors"
>
Cancel
</button>
<button
onClick={handleConfirm}
className="px-4 py-2 rounded-lg bg-blue-500 text-white hover:bg-blue-600 transition-colors"
>
Replace
</button>
</div>
</div>

View File

@ -70,6 +70,7 @@ export function ShotTabContent({
}
setScanState('scanning');
const containerElement = document.getElementById('person-detection-video') as HTMLVideoElement;
try {
const roleRecognitionResponse = await filterRole(containerElement);
console.log('roleRecognitionResponse', roleRecognitionResponse);
if (roleRecognitionResponse && roleRecognitionResponse.recognition_result.code === 200) {
@ -80,10 +81,13 @@ export function ShotTabContent({
name: person.person_id,
position: { top: person.top, left: person.left, width: person.width, height: person.height }
})));
setScanState('detected');
} else {
setIsScanFailed(true);
}
setScanState('detected');
} catch (error) {
setIsScanFailed(true);
}
};
// 处理扫描超时