mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-18 07:35:19 +00:00
should work end2end
This commit is contained in:
1 parent
c274ca47ea
commit
8b11e51b87
10 files changed
+155
-79
No files matched your search
@@ -0,0 +1,68 @@
|
||||
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,
|
||||
"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,
|
||||
}
|
||||
}
|
||||
|
||||
export interface EnqueueVideoStyleTransferResponse {
|
||||
success: boolean,
|
||||
inference_job_token?: string,
|
||||
}
|
||||
|
||||
export async function EnqueueVideoStyleTransfer(request: EnqueueVideoStyleTransferRequest) : Promise<EnqueueVideoStyleTransferResponse>
|
||||
{
|
||||
// const endpoint = "/v1/workflow/comfy/create";
|
||||
|
||||
const endpoint = new ApiConfig().enqueueVideoStyleTransfer();
|
||||
|
||||
return await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
body: JSON.stringify(request),
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
if (!res) {
|
||||
return { success : false };
|
||||
}
|
||||
|
||||
if (res && 'success' in res) {
|
||||
return res;
|
||||
} else {
|
||||
return { success : false };
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
return { success : false };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export type {
|
||||
EnqueueVideoStyleTransferRequest, EnqueueVideoStyleTransferResponse,
|
||||
} from './EnqueueVideoStyleTransfer';
|
||||
|
||||
export {
|
||||
EnqueueVideoStyleTransfer as default
|
||||
} from './EnqueueVideoStyleTransfer';
|
||||
@@ -29,19 +29,19 @@ export default function VideoStyleTransfer(props:{
|
||||
|
||||
const { enqueueInferenceJob } = props;
|
||||
useInferenceJobs(
|
||||
FrontendInferenceJobType.VideoWorkflow
|
||||
FrontendInferenceJobType.VideoStyleTransfer
|
||||
);
|
||||
useEffect(() => {
|
||||
if (
|
||||
pageState.status === states.WORKFLOW_ENQUEUED &&
|
||||
pageState.status === states.JOB_ENQUEUED &&
|
||||
pageState.inferenceJobToken
|
||||
) {
|
||||
enqueueInferenceJob(
|
||||
pageState.inferenceJobToken,
|
||||
FrontendInferenceJobType.VideoWorkflow
|
||||
FrontendInferenceJobType.VideoStyleTransfer
|
||||
);
|
||||
dispatchPageState({
|
||||
type: "enqueueFilterSuccess",
|
||||
type: "enqueueJobSuccess",
|
||||
payload: { inferenceJobToken: undefined },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
|
||||
export const inferenceFailures = (fail = "") => {
|
||||
switch (fail) {
|
||||
case "sample case":
|
||||
return "Sample Case, this should not have been shown";
|
||||
default:
|
||||
return "Unknown failure";
|
||||
}
|
||||
};
|
||||
|
||||
export function TableOfKeyValues(
|
||||
{
|
||||
keyValues,
|
||||
height
|
||||
}:{
|
||||
keyValues:{
|
||||
[key:string]:number|string|boolean|undefined
|
||||
};
|
||||
height?: number | string
|
||||
}){
|
||||
return(<table style={{
|
||||
display:'block',
|
||||
height: height || "100%",
|
||||
overflowY: "scroll",
|
||||
overflowX: "clip",
|
||||
border: "1px solid white",
|
||||
borderTopLeftRadius: "1rem",
|
||||
borderBottomLeftRadius: "1rem",
|
||||
}}>{
|
||||
Object.entries(keyValues).map(([key, val], index: number)=>{
|
||||
return <tr key={index}><td>{`${key}`}</td><td>{`${val}`}</td></tr>
|
||||
})
|
||||
}</table>);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Analytics } from "common/Analytics";
|
||||
import InferenceJobsList from "components/layout/InferenceJobsList";
|
||||
import { FrontendInferenceJobType } from "@storyteller/components/src/jobs/InferenceJob";
|
||||
|
||||
export default function CompVideoStyleTransferJobList({
|
||||
showNoJobs = false
|
||||
}:{
|
||||
showNoJobs?:boolean
|
||||
}){
|
||||
const failures = (fail = "") => {
|
||||
switch (fail) {
|
||||
case "sample case":
|
||||
return "Sample Case, this should not have been shown";
|
||||
default:
|
||||
return "Unknown failure";
|
||||
}
|
||||
};
|
||||
return (
|
||||
<InferenceJobsList {...{
|
||||
showNoJobs,
|
||||
failures,
|
||||
onSelect: () => Analytics.voiceConversionClickDownload(),
|
||||
jobType: FrontendInferenceJobType.VideoStyleTransfer,
|
||||
}}/>
|
||||
);
|
||||
}
|
||||
+14
-6
@@ -1,9 +1,12 @@
|
||||
import React, { memo } from 'react'
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import { states, Action, State } from "../reducer";
|
||||
import { Button, Spinner } from 'components/common';
|
||||
|
||||
import CompJoblist from './compJoblist';
|
||||
import { FrontendInferenceJobType } from "@storyteller/components/src/jobs/InferenceJob";
|
||||
import InferenceJobsList from "components/layout/InferenceJobsList";
|
||||
import { Analytics } from "common/Analytics";
|
||||
import { Button, Spinner } from 'components/common';
|
||||
import { states, Action, State } from "../reducer";
|
||||
import { inferenceFailures } from '../commons';
|
||||
|
||||
export default memo (function PageWorkflowJoblist({
|
||||
t, pageState, dispatchPageState, parentPath
|
||||
@@ -25,13 +28,18 @@ export default memo (function PageWorkflowJoblist({
|
||||
/>
|
||||
</NavLink>
|
||||
</div>
|
||||
{pageState.status === states.WORKFLOW_ENQUEUEING &&
|
||||
{pageState.status === states.JOB_ENQUEUEING &&
|
||||
<div>
|
||||
<h2> Requesting Filter Job</h2>
|
||||
<h2>t("message.requestingJob")</h2>
|
||||
<Spinner />
|
||||
</div>
|
||||
}
|
||||
<CompJoblist showNoJobs />
|
||||
<InferenceJobsList {...{
|
||||
showNoJobs:true,
|
||||
failures: inferenceFailures,
|
||||
onSelect: () => Analytics.voiceConversionClickDownload(),
|
||||
jobType: FrontendInferenceJobType.VideoStyleTransfer,
|
||||
}}/>
|
||||
</>
|
||||
);
|
||||
});
|
||||
-26
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
export type WorkflowValuesType = {
|
||||
@@ -82,28 +81,3 @@ export function mapRequest(workflowValues: WorkflowValuesType){
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function TableOfKeyValues(
|
||||
{
|
||||
keyValues,
|
||||
height
|
||||
}:{
|
||||
keyValues:{
|
||||
[key:string]:number|string|boolean|undefined
|
||||
};
|
||||
height?: number | string
|
||||
}){
|
||||
return(<table style={{
|
||||
display:'block',
|
||||
height: height || "100%",
|
||||
overflowY: "scroll",
|
||||
overflowX: "clip",
|
||||
border: "1px solid white",
|
||||
borderTopLeftRadius: "1rem",
|
||||
borderBottomLeftRadius: "1rem",
|
||||
}}>{
|
||||
Object.entries(keyValues).map(([key, val], index: number)=>{
|
||||
return <tr key={index}><td>{`${key}`}</td><td>{`${val}`}</td></tr>
|
||||
})
|
||||
}</table>);
|
||||
}
|
||||
+6
-6
@@ -2,14 +2,14 @@ import React, { useRef, useState } from "react";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import { useParams, useHistory } from "react-router-dom";
|
||||
|
||||
import { EnqueueVideoWorkflow } from "@storyteller/components/src/api/video_workflow";
|
||||
import { states, Action, State } from "../../reducer";
|
||||
import EnqueueVideoStyleTransfer from "@storyteller/components/src/api/video_styleTransfer";
|
||||
import { Action, State } from "../../reducer";
|
||||
import { TableOfKeyValues } from "../../commons";
|
||||
import ivs from "./initialValues";
|
||||
import {
|
||||
isInputValid,
|
||||
mapRequest,
|
||||
WorkflowValuesType,
|
||||
TableOfKeyValues
|
||||
} from "./helpers";
|
||||
|
||||
import {
|
||||
@@ -80,10 +80,10 @@ export default function PageVSTApp({
|
||||
if (isInputValid(workflowValues)){
|
||||
const request = mapRequest(workflowValues);
|
||||
if (debug) console.log(request);
|
||||
EnqueueVideoWorkflow(request).then(res => {
|
||||
EnqueueVideoStyleTransfer(request).then(res => {
|
||||
if (res.success && res.inference_job_token) {
|
||||
dispatchPageState({
|
||||
type: 'enqueueFilterSuccess',
|
||||
type: 'enqueueJobSuccess',
|
||||
payload: {
|
||||
inferenceJobToken: res.inference_job_token
|
||||
}
|
||||
@@ -92,7 +92,7 @@ export default function PageVSTApp({
|
||||
console.log(res);
|
||||
}
|
||||
})
|
||||
dispatchPageState({type: 'enqueueFilter'})
|
||||
dispatchPageState({type: 'enqueueJob'})
|
||||
history.push(`${parentPath}/jobs`);
|
||||
}else{
|
||||
alert("you must pick an sd weight and input a prompt");
|
||||
|
||||
+13
-2
@@ -1,11 +1,17 @@
|
||||
import React from "react";
|
||||
|
||||
|
||||
import { FrontendInferenceJobType } from "@storyteller/components/src/jobs/InferenceJob";
|
||||
import InferenceJobsList from "components/layout/InferenceJobsList";
|
||||
import { Analytics } from "common/Analytics";
|
||||
import { inferenceFailures } from "../commons";
|
||||
|
||||
import { Panel, Tabs } from "components/common";
|
||||
|
||||
import { State, Action } from "../reducer";
|
||||
import TabContentUpload from "./tabContentUpload";
|
||||
import TabContentLibrary from "./tabContentLibrary";
|
||||
import CompJoblist from "./compJoblist";
|
||||
|
||||
|
||||
export default function PageVideoProvision({
|
||||
debug=false, parentPath, t, pageState, dispatchPageState
|
||||
@@ -48,7 +54,12 @@ export default function PageVideoProvision({
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
<CompJoblist />
|
||||
<InferenceJobsList {...{
|
||||
showNoJobs:false,
|
||||
failures: inferenceFailures,
|
||||
onSelect: () => Analytics.voiceConversionClickDownload(),
|
||||
jobType: FrontendInferenceJobType.VideoStyleTransfer,
|
||||
}}/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -8,8 +8,8 @@ export enum states{
|
||||
FILE_UPLOADED,
|
||||
FILE_LOADING,
|
||||
FILE_LOADED,
|
||||
WORKFLOW_ENQUEUEING,
|
||||
WORKFLOW_ENQUEUED
|
||||
JOB_ENQUEUEING,
|
||||
JOB_ENQUEUED
|
||||
}
|
||||
|
||||
export type State = {
|
||||
@@ -30,8 +30,8 @@ export type Action =
|
||||
| {type: 'loadFileSuccess', payload:{
|
||||
mediaFileToken: string, mediaFile: MediaFile
|
||||
}}
|
||||
| {type: 'enqueueFilter'}
|
||||
| {type: 'enqueueFilterSuccess', payload: {inferenceJobToken: string|undefined}}
|
||||
| {type: 'enqueueJob'}
|
||||
| {type: 'enqueueJobSuccess', payload: {inferenceJobToken: string|undefined}}
|
||||
|
||||
|
||||
export function reducer (state: State, action: Action): State {
|
||||
@@ -68,15 +68,15 @@ export function reducer (state: State, action: Action): State {
|
||||
mediaFile: action.payload.mediaFile,
|
||||
mediaFileToken : action.payload.mediaFileToken,
|
||||
}
|
||||
case 'enqueueFilter':
|
||||
case 'enqueueJob':
|
||||
return {
|
||||
...state,
|
||||
status: states.WORKFLOW_ENQUEUEING
|
||||
status: states.JOB_ENQUEUEING
|
||||
}
|
||||
case 'enqueueFilterSuccess':
|
||||
case 'enqueueJobSuccess':
|
||||
return {
|
||||
...state,
|
||||
status: states.WORKFLOW_ENQUEUED,
|
||||
status: states.JOB_ENQUEUED,
|
||||
inferenceJobToken: action.payload.inferenceJobToken
|
||||
}
|
||||
case 'reset':
|
||||
|
||||
Reference in new issue
Block a user