jbilcke-hf HF staff commited on
Commit
ae65ad2
1 Parent(s): 250440d

add support for reference images

Browse files
src/app/api/parsers/parseTurbo.ts CHANGED
@@ -7,7 +7,8 @@ export function parseTurbo(
7
  try {
8
  let maybeTurbo = decodeURIComponent(`${input || value}`).trim().toLowerCase()
9
 
10
- if (maybeTurbo === "true" || maybeTurbo === "1") { return false }
 
11
 
12
  if (maybeTurbo === "false") { return false }
13
 
 
7
  try {
8
  let maybeTurbo = decodeURIComponent(`${input || value}`).trim().toLowerCase()
9
 
10
+
11
+ if (maybeTurbo === "true" || maybeTurbo === "1") { return true }
12
 
13
  if (maybeTurbo === "false") { return false }
14
 
src/app/api/providers/videochain/renderWithVideoChain.ts CHANGED
@@ -10,6 +10,7 @@ const apiKey = `${process.env.VIDEOCHAIN_API_KEY || ""}`
10
  export async function newRender({
11
  prompt,
12
  negativePrompt,
 
13
  nbFrames,
14
  nbFPS,
15
  nbSteps,
@@ -21,6 +22,7 @@ export async function newRender({
21
  }: {
22
  prompt: string
23
  negativePrompt: string
 
24
  nbFrames: number
25
  nbFPS: number
26
  nbSteps: number
@@ -64,6 +66,7 @@ export async function newRender({
64
  body: JSON.stringify({
65
  prompt,
66
  negativePrompt,
 
67
  // nbFrames: 8 and nbSteps: 15 --> ~10 sec generation
68
  nbFrames, // when nbFrames is 1, we will only generate static images
69
  nbFPS,
 
10
  export async function newRender({
11
  prompt,
12
  negativePrompt,
13
+ identityImage,
14
  nbFrames,
15
  nbFPS,
16
  nbSteps,
 
22
  }: {
23
  prompt: string
24
  negativePrompt: string
25
+ identityImage?: string
26
  nbFrames: number
27
  nbFPS: number
28
  nbSteps: number
 
66
  body: JSON.stringify({
67
  prompt,
68
  negativePrompt,
69
+ identityImage,
70
  // nbFrames: 8 and nbSteps: 15 --> ~10 sec generation
71
  nbFrames, // when nbFrames is 1, we will only generate static images
72
  nbFPS,
src/app/api/v1/edit/storyboards/generateStoryboard.ts CHANGED
@@ -7,6 +7,7 @@ import { getNegativePrompt, getPositivePrompt } from "@/app/api/utils/imagePromp
7
  export async function generateStoryboard({
8
  prompt,
9
  // negativePrompt,
 
10
  width,
11
  height,
12
  seed,
@@ -14,6 +15,7 @@ export async function generateStoryboard({
14
  }: {
15
  prompt: string
16
  // negativePrompt?: string
 
17
  width?: number
18
  height?: number
19
  seed?: number
@@ -23,13 +25,14 @@ export async function generateStoryboard({
23
  width = getValidNumber(width, 256, 8192, 512)
24
  height = getValidNumber(height, 256, 8192, 288)
25
 
26
- // console.log("calling await newRender")
27
  prompt = getPositivePrompt(prompt)
28
  const negativePrompt = getNegativePrompt()
29
 
30
  let render = await newRender({
31
  prompt,
32
  negativePrompt,
 
33
  nbFrames: 1,
34
  nbFPS: 1,
35
  nbSteps: turbo ? 8 : 25,
 
7
  export async function generateStoryboard({
8
  prompt,
9
  // negativePrompt,
10
+ identityImage,
11
  width,
12
  height,
13
  seed,
 
15
  }: {
16
  prompt: string
17
  // negativePrompt?: string
18
+ identityImage?: string
19
  width?: number
20
  height?: number
21
  seed?: number
 
25
  width = getValidNumber(width, 256, 8192, 512)
26
  height = getValidNumber(height, 256, 8192, 288)
27
 
28
+
29
  prompt = getPositivePrompt(prompt)
30
  const negativePrompt = getNegativePrompt()
31
 
32
  let render = await newRender({
33
  prompt,
34
  negativePrompt,
35
+ identityImage,
36
  nbFrames: 1,
37
  nbFPS: 1,
38
  nbSteps: turbo ? 8 : 25,
src/app/api/v1/edit/storyboards/processShot.ts CHANGED
@@ -79,12 +79,22 @@ export async function processShot({
79
  if (!shotStoryboardSegment.assetUrl) {
80
  // console.log(`[api/v1/edit/storyboards] generating image..`)
81
 
 
 
 
 
 
 
82
  try {
83
  shotStoryboardSegment.assetUrl = await generateStoryboard({
84
  prompt: getPositivePrompt(shotStoryboardSegment.prompt),
 
85
  width: existingClap.meta.width,
86
  height: existingClap.meta.height,
87
- turbo,
 
 
 
88
  })
89
  shotStoryboardSegment.assetSourceType = getClapAssetSourceType(shotStoryboardSegment.assetUrl)
90
  shotStoryboardSegment.status = "completed"
 
79
  if (!shotStoryboardSegment.assetUrl) {
80
  // console.log(`[api/v1/edit/storyboards] generating image..`)
81
 
82
+ // console.log(`we have ${existingClap.entities.length} entities`)
83
+ // check if we have an entity image we can use
84
+ const identityImage = existingClap.entities.find(e => e.id === shotStoryboardSegment.entityId)?.imageId
85
+ if (identityImage) {
86
+ // console.log(`[api/v1/edit/storyboards] processShot: using an entity to generate the storyboard..`)
87
+ }
88
  try {
89
  shotStoryboardSegment.assetUrl = await generateStoryboard({
90
  prompt: getPositivePrompt(shotStoryboardSegment.prompt),
91
+ identityImage,
92
  width: existingClap.meta.width,
93
  height: existingClap.meta.height,
94
+
95
+ // turbo mode is mandatory if we have an identity image
96
+ // that's because it will use PuLID instead of SDXL
97
+ turbo: !!identityImage,
98
  })
99
  shotStoryboardSegment.assetSourceType = getClapAssetSourceType(shotStoryboardSegment.assetUrl)
100
  shotStoryboardSegment.status = "completed"
src/app/api/v1/edit/storyboards/route.ts CHANGED
@@ -24,7 +24,7 @@ export async function POST(req: NextRequest) {
24
 
25
  const mode = parseCompletionMode(query?.c)
26
  const turbo = parseTurbo(query?.t)
27
-
28
  const blob = await req.blob()
29
 
30
  const existingClap: ClapProject = await parseClap(blob)
 
24
 
25
  const mode = parseCompletionMode(query?.c)
26
  const turbo = parseTurbo(query?.t)
27
+
28
  const blob = await req.blob()
29
 
30
  const existingClap: ClapProject = await parseClap(blob)