new vst mapping

This commit is contained in:
wil committed 2024-02-25 18:13:24 -05:00
1 parent ea6526643b
commit e3e800538e
8 files changed
+101 -141

No files matched your search

@@ -1,31 +1,29 @@
import { ApiConfig } from "@storyteller/components";
export interface EnqueueVideoStyleTransferRequest {
"uuid_idempotency_token": string,
"maybe_sd_model": string,
"maybe_workflow_config": string,
"maybe_input_file": string,
"maybe_output_path": string,
"uuid_idempotency_token":string;
"maybe_sd_model": string;
"maybe_workflow_config": string;
"maybe_input_file": string;
"maybe_output_path": string;
"creator_set_visibility": string;
"maybe_json_modifications": {
"$.510.inputs.Text": string,
"$.8.inputs.text": string,
"$.173.inputs.seed": string,
"$.401.inputs.Value": number,
"$.918.inputs.Value": number,
"$.137.inputs.Value": number,
"$.186.inputs.Value": number,
"$.140.inputs.Value":number,
"$.154.inputs.Value": number,
"$.445.inputs.number": number,
// "$.947.inputs.Value": number,
"$.800.inputs.Value": number,
"$.797.inputs.Value": number,
"$.796.inputs.Value": number,
"$.772.inputs.Value": number,
"$.771.inputs.Value": number,
"$.527.inputs.Value": number,
"$.403.inputs.Value": number,
"$.154.inputs.Value": number;
"$.510.inputs.Text": string;
"$.8.inputs.text": string;
"$.800.inputs.Value": number;
"$.772.inputs.Value": number;
"$.797.inputs.Value": number;
"$.796.inputs.Value": number;
"$.1636.inputs.Value": number;
"$.771.inputs.Value": number;
"$.403.inputs.Value": number;
"$.1398.inputs.Value": number;
"$.1531.inputs.Value": number;
// "$.208.inputs.lora_01": string;
// "$.208.inputs.strength_01": number;
}
}
@@ -18,7 +18,6 @@ export interface EnqueueVideoWorkflowRequest {
"$.140.inputs.Value":number,
"$.154.inputs.Value": number,
"$.445.inputs.number": number,
// "$.947.inputs.Value": number,
"$.800.inputs.Value": number,
"$.797.inputs.Value": number,
"$.796.inputs.Value": number,
@@ -36,8 +35,6 @@ export interface EnqueueVideoWorkflowResponse {
export async function EnqueueVideoWorkflow(request: EnqueueVideoWorkflowRequest) : Promise<EnqueueVideoWorkflowResponse>
{
// const endpoint = "/v1/workflow/comfy/create";
const endpoint = new ApiConfig().enqueueVideoWorkflow();
return await fetch(endpoint, {
@@ -1,48 +1,42 @@
export {initialValues, hiddenValues};
const initialValues = {
//config
//files Settings
fileToken: "",
outputPath: "",
workflowConfig: "weight_f5qh4s1dtp266yv313p09tkpa",
//video Settings
width: 544,
height: 544,
maxFrames: 17,
framesCap: 16,
skipFrames: 0,
everyNthFrame: 2,
inputFps: 24,
interpolationMultiplier: 2,
//basics
seed: "",
//Presents
// workflowConfig: "weight_f5qh4s1dtp266yv313p09tkpa",
workflowConfig: "weight_8y19y1gfe0vfnvawgz2z9w7ms",
sdModelToken: "weight_83xpresyjswy97ppk0fyct146",
loraModelToken: "weight_13yfxfafv195ejwh3meesebdk",
loraModelStrength: 1,
//basics
inputFps: 24,
posPrompt: "",
negPrompt: "",
//advance
firstPass: 0,
upscalePass: 0,
motionScale:0,
upscaleMultiplier: 0,
useEmptyLatent: false,
useFaceDetailer: false,
denoiseFaceDetailer: 0,
useLCM: false,
lcmCFG: 0,
lcmSteps: 0,
visibility: "private",
//Control Net
cnCanny: 0.7,
cnDepth: 0.7,
cnLinearAnime: 0.7,
cnLinearRealistic: 0.7,
cnLipsStrength: 0.7,
cnOpenPose: 0.7,
cnPipeFace: 0.7,
cnSparse: 0.7,
// cnTile: 0.7,
cnSparseScribble: 0.7,
cnSoftEdge: 0.7,
cnRegularSteps: 30,
};
const hiddenValues = {
posPrompt: "(masterpiece,detailed,highres:1.4), ",
negPrompt: "flare, lens flare, glare, naked, nsfw, text, logo, Shutterstock, watermark:1.3, embedding:easynegative, embedding:badhandv4,(worst quality, low quality:1.4), lowres, blurry, monochrome, ",
@@ -1,7 +1,7 @@
import { v4 as uuidv4 } from "uuid";
import { hiddenValues } from "./defaultValues";
export type WorkflowValuesType = {
export type VSTType = {
// File Settings
fileToken: string;
outputPath: string;
@@ -11,36 +11,30 @@ export type WorkflowValuesType = {
maxFrames: number;
framesCap: number;
skipFrames: number;
everyNthFrame: number;
inputFps: number;
interpolationMultiplier: number;
// Basic Inputs
// Presets
workflowConfig: string;
seed: string;
sdModelToken: string;
loraModelToken: string;
// loraModelToken: string;
// loraModelStrength: number;
//basics
inputFps: number;
posPrompt: string;
negPrompt: string;
// Advance Options Values
firstPass: number;
upscalePass: number;
motionScale: number;
upscaleMultiplier: number;
useEmptyLatent: boolean;
useFaceDetailer: boolean;
denoiseFaceDetailer: number;
useLCM: boolean;
lcmCFG: number;
lcmSteps: number;
// Control Net Values
visibility: string;
//advance
cnCanny: number;
cnDepth: number;
cnLinearAnime: number;
cnLinearRealistic: number;
cnLipsStrength: number;
cnOpenPose: number;
cnPipeFace: number;
cnSparse: number;
// cnTile: number;
cnSparseScribble: number;
cnSoftEdge: number;
cnRegularSteps: number
}
export function isInputValid(keyValues: {[key:string]:number|string|boolean|undefined}){
@@ -52,35 +46,35 @@ export function isInputValid(keyValues: {[key:string]:number|string|boolean|unde
);
}
export function mapRequest(workflowValues: WorkflowValuesType){
export function mapRequest(vstValues: VSTType){
//TODO: improve the typing of this
return {
return{
"uuid_idempotency_token": uuidv4(),
"maybe_sd_model": workflowValues.sdModelToken,
"maybe_workflow_config": workflowValues.workflowConfig,
"maybe_input_file": workflowValues.fileToken,
"maybe_output_path": workflowValues.outputPath,
"maybe_sd_model": vstValues.sdModelToken,
"maybe_workflow_config":vstValues.workflowConfig,
"maybe_input_file": vstValues.fileToken,
"maybe_output_path":"",
"creator_set_visibility": vstValues.visibility,
"maybe_json_modifications": {
"$.154.inputs.Value": vstValues.inputFps,
"$.510.inputs.Text":
hiddenValues.posPrompt + workflowValues.posPrompt,
hiddenValues.posPrompt + vstValues.posPrompt,
"$.8.inputs.text":
hiddenValues.negPrompt+ workflowValues.negPrompt,
"$.173.inputs.seed": workflowValues.seed,
"$.401.inputs.Value": workflowValues.firstPass,
"$.918.inputs.Value": workflowValues.motionScale,
"$.137.inputs.Value": workflowValues.framesCap,
"$.186.inputs.Value": workflowValues.skipFrames,
"$.140.inputs.Value": workflowValues.everyNthFrame,
"$.154.inputs.Value": workflowValues.inputFps,
"$.445.inputs.number": workflowValues.interpolationMultiplier,
// "$.947.inputs.Value": workflowValues.cnTile,
"$.800.inputs.Value": workflowValues.cnCanny,
"$.797.inputs.Value": workflowValues.cnLinearAnime,
"$.796.inputs.Value": workflowValues.cnLinearRealistic,
"$.772.inputs.Value": workflowValues.cnDepth,
"$.771.inputs.Value": workflowValues.cnOpenPose,
"$.527.inputs.Value": workflowValues.cnPipeFace,
"$.403.inputs.Value": workflowValues.cnSparse
hiddenValues.negPrompt+ vstValues.negPrompt,
"$.800.inputs.Value": vstValues.cnCanny,
"$.772.inputs.Value": vstValues.cnDepth,
"$.797.inputs.Value": vstValues.cnLinearAnime,
"$.796.inputs.Value": vstValues.cnLinearRealistic,
"$.1636.inputs.Value": vstValues.cnLipsStrength,
"$.771.inputs.Value": vstValues.cnOpenPose,
"$.403.inputs.Value": vstValues.cnSparseScribble,
"$.1398.inputs.Value": vstValues.cnSoftEdge,
"$.1531.inputs.Value": vstValues.cnRegularSteps,
// "$.208.inputs.lora_01": vstValues.loraModelToken,
// "$.208.inputs.strength_01": vstValues.loraModelStrength
},
}
}
@@ -12,7 +12,6 @@ import {
} from "components/common";
import EnqueueVideoStyleTransfer from "@storyteller/components/src/api/video_styleTransfer";
import generateRandomSeed from 'resources/generateRandomSeed';
import { Action, State } from "../../reducer";
@@ -20,7 +19,7 @@ import { TableOfKeyValues } from "../../commons";
import { initialValues } from "./defaultValues";
import {
mapRequest,
WorkflowValuesType,
VSTType,
} from "./helpers";
import SectionAdvanceOptions from "./sectionAdvanceOptions";
@@ -39,10 +38,9 @@ export default function PageVSTApp({
const videoRef = useRef<HTMLVideoElement>(null);
const { mediaToken } = useParams<any>();
const [workflowValues, setWorkflowValues] = useState<WorkflowValuesType>({
fileToken: pageState.mediaFileToken || mediaToken,
const [vstValues, setVstValues] = useState<VSTType>({
...initialValues,
seed: generateRandomSeed(),
fileToken: pageState.mediaFileToken || mediaToken,
});
@@ -63,10 +61,10 @@ export default function PageVSTApp({
else if (debug) console.log(`aspectRaio: ${aspectRatio}`);
}
if(ve.duration){
newValues.maxFrames = Math.floor(ve.duration)*workflowValues.inputFps;
newValues.maxFrames = Math.floor(ve.duration)*vstValues.inputFps;
newValues.framesCap = newValues.maxFrames;
}
setWorkflowValues((curr)=>({
setVstValues((curr)=>({
...curr,
...newValues,
}))
@@ -75,15 +73,15 @@ export default function PageVSTApp({
const handleOnChange = (val:{[key: string]: number|string|boolean|undefined}) => {
setWorkflowValues((curr)=>({...curr, ...val}));
setVstValues((curr)=>({...curr, ...val}));
}
const history = useHistory();
const handleGenerate = ()=>{
if(debug) console.log(workflowValues)
if(debug) console.log(vstValues)
const request = mapRequest(workflowValues);
const request = mapRequest(vstValues);
if (debug) console.log(request);
EnqueueVideoStyleTransfer(request).then(res => {
if (res.success && res.inference_job_token) {
@@ -107,7 +105,7 @@ export default function PageVSTApp({
<div className="col-12 col-md-6">
<VideoFakeyou
label={t("video.label.original")}
mediaToken={workflowValues.fileToken}
mediaToken={vstValues.fileToken}
ref={videoRef}
onResponse={(res)=>{
dispatchPageState({
@@ -122,7 +120,7 @@ export default function PageVSTApp({
</div>
<div className="col-12 col-md-6">
<Label label={t("image.label.preview")}/>
{debug && <TableOfKeyValues keyValues={workflowValues} height={400}/>}
{debug && <TableOfKeyValues keyValues={vstValues} height={400}/>}
</div>
</div>
@@ -133,7 +131,7 @@ export default function PageVSTApp({
label: t("input.label.prompt"),
placeholder: t("input.placeholder.prompt"),
onChange: (e:React.ChangeEvent<HTMLTextAreaElement>)=>handleOnChange({posPrompt: e.target.value}),
value: workflowValues.posPrompt,
value: vstValues.posPrompt,
required: false,
}}
/>
@@ -144,7 +142,7 @@ export default function PageVSTApp({
label: t("input.label.negPrompt"),
placeholder: t("input.placeholder.negPrompt"),
onChange: (e:React.ChangeEvent<HTMLTextAreaElement>)=>handleOnChange({negPrompt: e.target.value}),
value: workflowValues.negPrompt,
value: vstValues.negPrompt,
required: false,
}}
/>
@@ -154,7 +152,7 @@ export default function PageVSTApp({
<div className="col-12 col-md-6">
<NumberSliderV2 {...{
min: 1, max: 60, step: 1,
initialValue: workflowValues.inputFps,
initialValue: vstValues.inputFps,
label: "Input FPS",
thumbTip: "Input FPS",
onChange: (val)=>{handleOnChange({inputFps: val})}
@@ -164,7 +162,7 @@ export default function PageVSTApp({
<div className="row g-3 mt-4">
<SectionAdvanceOptions
onChange={handleOnChange}
workflowValues={workflowValues}
vstValues={vstValues}
/>
</div>
<div className="row g-3 mt-4">
@@ -16,13 +16,13 @@ import {
Label,
NumberSliderV2
} from 'components/common';
import { WorkflowValuesType } from './helpers';
import { VSTType } from './helpers';
export default function sectionAdvanceOptions({
workflowValues: wfVal,
vstValues: vstVal,
onChange: handleOnChange
}:{
workflowValues : WorkflowValuesType,
vstValues : VSTType,
onChange: (val:{[key: string]: number|string|boolean|undefined})=>void
}){
return (
@@ -41,7 +41,7 @@ export default function sectionAdvanceOptions({
<div className="col-md-6">
<NumberSliderV2 {...{
min: 0, max: 1, step: 0.1,
initialValue: wfVal.cnCanny,
initialValue: vstVal.cnCanny,
label: "Canny",
thumbTip: "Canny",
onChange: (val)=>{handleOnChange({cnCanny: val})}
@@ -50,7 +50,7 @@ export default function sectionAdvanceOptions({
<div className="col-md-6">
<NumberSliderV2 {...{
min: 0, max: 1, step: 0.1,
initialValue: wfVal.cnLinearAnime,
initialValue: vstVal.cnLinearAnime,
label: "Line Art Anime",
thumbTip: "Line Art Anime",
onChange: (val)=>{handleOnChange({cnLinearAnime: val})}
@@ -61,7 +61,7 @@ export default function sectionAdvanceOptions({
<div className="col-md-6">
<NumberSliderV2 {...{
min: 0, max: 1, step: 0.1,
initialValue: wfVal.cnDepth,
initialValue: vstVal.cnDepth,
label: "Depth",
thumbTip: "Depth",
onChange: (val)=>{handleOnChange({cnDepth: val})}
@@ -70,7 +70,7 @@ export default function sectionAdvanceOptions({
<div className="col-md-6">
<NumberSliderV2 {...{
min: 0, max: 1, step: 0.1,
initialValue: wfVal.cnOpenPose,
initialValue: vstVal.cnOpenPose,
label: "OpenPose",
thumbTip: "OpenPose",
onChange: (val)=>{handleOnChange({cnOpenPose: val})}
@@ -81,7 +81,7 @@ export default function sectionAdvanceOptions({
<div className="col-md-6">
<NumberSliderV2 {...{
min: 0, max: 1, step: 0.1,
initialValue: wfVal.cnPipeFace,
initialValue: vstVal.cnPipeFace,
label: "Media Pipe Face",
thumbTip: "Media Pipe Face",
onChange: (val)=>{handleOnChange({cnPipeFace: val})}
@@ -90,7 +90,7 @@ export default function sectionAdvanceOptions({
<div className="col-md-6">
<NumberSliderV2 {...{
min: 0, max: 1, step: 0.1,
initialValue: wfVal.cnSparse,
initialValue: vstVal.cnSparseScribble,
label: "Sparse Scribble",
thumbTip: "Sparse Scribble",
onChange: (val)=>{handleOnChange({cnSparse: val})}
@@ -101,21 +101,12 @@ export default function sectionAdvanceOptions({
<div className="col-md-6">
<NumberSliderV2 {...{
min: 0, max: 1, step: 0.1,
initialValue: wfVal.cnLinearRealistic,
initialValue: vstVal.cnLinearRealistic,
label: "Video CN (Linear Realistic)",
thumbTip: "Video CN",
onChange: (val)=>{handleOnChange({cnLinearRealistic: val})}
}}/>
</div>
{/* <div className="col-md-6">
<NumberSliderV2 {...{
min: 0, max: 1, step: 0.1,
initialValue: wfVal.cnTile,
label: "Tile CN",
thumbTip: "Tile CN",
onChange: (val)=>{handleOnChange({cnTile: val})}
}}/>
</div> */}
</div>
<div className="d-flex p-3 justify-content-end">
<Button icon={faRotateLeft} label="Reset"/>
@@ -41,7 +41,6 @@ export type WorkflowValuesType = {
cnOpenPose: number;
cnPipeFace: number;
cnSparse: number;
// cnTile: number;
}
export function isInputValid(keyValues: {[key:string]:number|string|boolean|undefined}){
return (
@@ -71,7 +70,6 @@ export function mapRequest(workflowValues: WorkflowValuesType){
"$.140.inputs.Value": workflowValues.everyNthFrame,
"$.154.inputs.Value": workflowValues.inputFps,
"$.445.inputs.number": workflowValues.interpolationMultiplier,
// "$.947.inputs.Value": workflowValues.cnTile,
"$.800.inputs.Value": workflowValues.cnCanny,
"$.797.inputs.Value": workflowValues.cnLinearAnime,
"$.796.inputs.Value": workflowValues.cnLinearRealistic,
@@ -10,7 +10,6 @@ export const ControlNetsInitialValues = {
cnOpenPose: 0,
cnPipeFace: 0,
cnSparse: 0.7,
// cnTile: 0,
}
export default memo( function SectionControlNets({
@@ -93,15 +92,6 @@ export default memo( function SectionControlNets({
onChange: (val)=>{handleOnChange({cnLinearRealistic: val})}
}}/>
</div>
{/* <div className="col-md-6">
<NumberSliderV2 {...{
min: 0, max: 1, step: 0.1,
initialValue: wfVal.cnTile,
label: "Tile CN",
thumbTip: "Tile CN",
onChange: (val)=>{handleOnChange({cnTile: val})}
}}/>
</div> */}
</div>
</>
);