auto enable and disable auto segment for workflow only starts with auto_segment

This commit is contained in:
BennyKok
2023-11-16 14:08:13 -08:00
parent 0f7b8cfe26
commit b59acce30c
3 changed files with 15 additions and 2 deletions
+11 -1
View File
@@ -8,6 +8,7 @@ import {
previewImgLoading,
alertDialog,
isGenerateFlow,
enableAutoSegment
} from "./state.js";
const { button, iframe, div, img, input, label, span, textarea, ul, li } =
van.tags;
@@ -30,7 +31,16 @@ const workflowList = [
];
// const workflowList = ["Auto_segment_workflow"];
/**
* Load JSON workflow
* @param {string} name - The name of the workflow to load
*/
async function loadJSONWorkflow(name) {
if (name === 'default' || name.toLowerCase().startsWith("Auto_segment")) {
enableAutoSegment.val = true
} else {
enableAutoSegment.val = false
}
const json = await (await fetch(`./get_workflow?name=${name}`)).json();
app.loadGraphData(json);
console.log(json);
@@ -286,7 +296,7 @@ export function AvatarPreview() {
},
},
div({ class: "badge badge-neutral" }, "2"),
"Edit Segment",
() => enableAutoSegment.val ? "Edit Segment (Auto)" : "Edit Segment",
),
button(
{
+3 -1
View File
@@ -16,6 +16,7 @@ import {
shareLoading,
previewModelId,
embeddingID,
enableAutoSegment
} from "./state.js";
import { van } from "./van.js";
import { app } from "./app.js";
@@ -344,7 +345,8 @@ function showMyImageEditor(node) {
);
loadNpyTensor(embeedingUrl).then(async (tensor) => {
embeddings.val = tensor;
await autoSegment();
if (enableAutoSegment.val)
await autoSegment();
drawSegment(getClicks());
});
targetNode.val = node;
+1
View File
@@ -21,6 +21,7 @@ export const showPreview = van.state(true);
export const previewUrl = van.state("https://editor.avatech.ai/viewer?avatarId=default&debug=false&width=300&height=300&hideTrigger=true&voiceSelection=true");
export const previewImg = van.state("");
export const previewImgLoading = van.state(false);
export const enableAutoSegment = van.state(false);
// export const previewUrl = van.state("http://localhost:3006/viewer?avatarId=default&hideUI=true&debug=true&width=300&height=300&showAudioControl=true");
export const isDirty = van.state(false);
export const fileName = van.state('');