From b59acce30ce76658b63522390bf8faa6cdb55dbc Mon Sep 17 00:00:00 2001 From: BennyKok Date: Thu, 16 Nov 2023 14:08:13 -0800 Subject: [PATCH] auto enable and disable auto segment for workflow only starts with auto_segment --- js/AvatarPreview.js | 12 +++++++++++- js/index.js | 4 +++- js/state.js | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/js/AvatarPreview.js b/js/AvatarPreview.js index aad94e9..fb15555 100644 --- a/js/AvatarPreview.js +++ b/js/AvatarPreview.js @@ -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( { diff --git a/js/index.js b/js/index.js index 6955d7f..527a1b8 100644 --- a/js/index.js +++ b/js/index.js @@ -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; diff --git a/js/state.js b/js/state.js index 7925d41..d60e46f 100644 --- a/js/state.js +++ b/js/state.js @@ -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('');