mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-26 14:08:30 +03:00
add cache key and activity indicator for loading classification wizard images
This commit is contained in:
parent
0f6bd605e3
commit
73eceaf242
@ -45,6 +45,12 @@ export default function Step3ChooseExamples({
|
|||||||
const [isProcessing, setIsProcessing] = useState(false);
|
const [isProcessing, setIsProcessing] = useState(false);
|
||||||
const [currentClassIndex, setCurrentClassIndex] = useState(0);
|
const [currentClassIndex, setCurrentClassIndex] = useState(0);
|
||||||
const [selectedImages, setSelectedImages] = useState<Set<string>>(new Set());
|
const [selectedImages, setSelectedImages] = useState<Set<string>>(new Set());
|
||||||
|
const [cacheKey, setCacheKey] = useState<number>(Date.now());
|
||||||
|
const [loadedImages, setLoadedImages] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
|
const handleImageLoad = useCallback((imageName: string) => {
|
||||||
|
setLoadedImages((prev) => new Set(prev).add(imageName));
|
||||||
|
}, []);
|
||||||
|
|
||||||
const { data: trainImages, mutate: refreshTrainImages } = useSWR<string[]>(
|
const { data: trainImages, mutate: refreshTrainImages } = useSWR<string[]>(
|
||||||
hasGenerated ? `classification/${step1Data.modelName}/train` : null,
|
hasGenerated ? `classification/${step1Data.modelName}/train` : null,
|
||||||
@ -332,6 +338,8 @@ export default function Step3ChooseExamples({
|
|||||||
setHasGenerated(true);
|
setHasGenerated(true);
|
||||||
toast.success(t("wizard.step3.generateSuccess"));
|
toast.success(t("wizard.step3.generateSuccess"));
|
||||||
|
|
||||||
|
// Update cache key to force image reload
|
||||||
|
setCacheKey(Date.now());
|
||||||
await refreshTrainImages();
|
await refreshTrainImages();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const axiosError = error as {
|
const axiosError = error as {
|
||||||
@ -565,10 +573,16 @@ export default function Step3ChooseExamples({
|
|||||||
)}
|
)}
|
||||||
onClick={() => toggleImageSelection(imageName)}
|
onClick={() => toggleImageSelection(imageName)}
|
||||||
>
|
>
|
||||||
|
{!loadedImages.has(imageName) && (
|
||||||
|
<div className="flex h-full items-center justify-center">
|
||||||
|
<ActivityIndicator className="size-6" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<img
|
<img
|
||||||
src={`${baseUrl}clips/${step1Data.modelName}/train/${imageName}`}
|
src={`${baseUrl}clips/${step1Data.modelName}/train/${imageName}?t=${cacheKey}`}
|
||||||
alt={`Example ${index + 1}`}
|
alt={`Example ${index + 1}`}
|
||||||
className="h-full w-full object-cover"
|
className="h-full w-full object-cover"
|
||||||
|
onLoad={() => handleImageLoad(imageName)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user