mirror of
https://github.com/ostris/ai-toolkit.git
synced 2026-01-26 16:39:47 +00:00
Fix issue with parsing image info for sample info on some windows machines.
This commit is contained in:
@@ -46,10 +46,21 @@ export default function SampleImageViewer({
|
|||||||
const onCancel = useCallback(() => setIsOpen(false), []);
|
const onCancel = useCallback(() => setIsOpen(false), []);
|
||||||
|
|
||||||
const imgInfo = useMemo(() => {
|
const imgInfo = useMemo(() => {
|
||||||
|
// handle windows C:\\Apps\\AI-Toolkit\\AI-Toolkit\\output\\LoRA-Name\\samples\\1763563000704__000004000_0.jpg
|
||||||
const ii = { filename: '', step: 0, promptIdx: 0 };
|
const ii = { filename: '', step: 0, promptIdx: 0 };
|
||||||
if (imgPath) {
|
if (imgPath) {
|
||||||
const filename = imgPath.split('/').pop();
|
// handle windows
|
||||||
if (!filename) return ii;
|
let filename: string | null = null;
|
||||||
|
if (imgPath.includes('\\')) {
|
||||||
|
const parts = imgPath.split('\\');
|
||||||
|
filename = parts[parts.length - 1];
|
||||||
|
} else {
|
||||||
|
filename = imgPath.split('/').pop() || null;
|
||||||
|
}
|
||||||
|
if (!filename) {
|
||||||
|
console.error('Filename could not be determined from imgPath:', imgPath);
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
ii.filename = filename;
|
ii.filename = filename;
|
||||||
const parts = filename
|
const parts = filename
|
||||||
.split('.')[0]
|
.split('.')[0]
|
||||||
@@ -58,6 +69,8 @@ export default function SampleImageViewer({
|
|||||||
if (parts.length === 3) {
|
if (parts.length === 3) {
|
||||||
ii.step = parseInt(parts[1]);
|
ii.step = parseInt(parts[1]);
|
||||||
ii.promptIdx = parseInt(parts[2]);
|
ii.promptIdx = parseInt(parts[2]);
|
||||||
|
} else {
|
||||||
|
console.error('Unexpected filename format for sample image:', filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ii;
|
return ii;
|
||||||
|
|||||||
Reference in New Issue
Block a user