jbilcke-hf HF staff commited on
Commit
8bc9511
1 Parent(s): 7448744

work in progress

Browse files
src/app/interface/generate/index.tsx CHANGED
@@ -45,8 +45,10 @@ export function Generate() {
45
  try {
46
  console.log("starting transition, calling generateAnimation")
47
  const newAssetUrl = await generateAnimation({
48
- prompt: promptDraft,
 
49
  huggingFaceLora: "KappaNeuro/studio-ghibli-style",
 
50
  // huggingFaceLora: "veryVANYA/ps1-graphics-sdxl-v2", //
51
  // huggingFaceLora: "ostris/crayon_style_lora_sdxl", // "https://huggingface.co/ostris/crayon_style_lora_sdxl/resolve/main/crayons_v1_sdxl.safetensors",
52
  // replicateLora: "https://replicate.com/jbilcke/sdxl-panorama",
@@ -70,7 +72,9 @@ export function Generate() {
70
 
71
  size: "768x320", // "1024x512", // "512x512" // "320x768"
72
 
73
- steps: 40,
 
 
74
  })
75
  setAssetUrl(newAssetUrl)
76
  } catch (err) {
@@ -90,7 +94,7 @@ export function Generate() {
90
  )}>
91
  <div className={cn(
92
  `flex flex-col md:flex-row`,
93
- `w-full md:max-w-3xl lg:max-w-4xl xl:max-w-5xl max-h-[80vh]`,
94
  `space-y-3 md:space-y-0 md:space-x-6`,
95
  `transition-all duration-300 ease-in-out`,
96
 
@@ -111,13 +115,20 @@ export function Generate() {
111
  `space-y-3 md:space-y-6`,
112
  `items-center`,
113
  )}>
 
 
 
 
 
 
 
114
  <img
115
  src={assetUrl}
116
  className={cn(
117
  `w-[512px] object-cover`,
118
  `rounded-2xl`
119
  )}
120
- />
121
  </div> : null}
122
 
123
  <div className={cn(
 
45
  try {
46
  console.log("starting transition, calling generateAnimation")
47
  const newAssetUrl = await generateAnimation({
48
+ positivePrompt: promptDraft,
49
+ negativePrompt: "",
50
  huggingFaceLora: "KappaNeuro/studio-ghibli-style",
51
+ triggerWord: "Studio Ghibli Style",
52
  // huggingFaceLora: "veryVANYA/ps1-graphics-sdxl-v2", //
53
  // huggingFaceLora: "ostris/crayon_style_lora_sdxl", // "https://huggingface.co/ostris/crayon_style_lora_sdxl/resolve/main/crayons_v1_sdxl.safetensors",
54
  // replicateLora: "https://replicate.com/jbilcke/sdxl-panorama",
 
72
 
73
  size: "768x320", // "1024x512", // "512x512" // "320x768"
74
 
75
+ nbFrames: 8, // if duration is 1000ms then it means 8 FPS
76
+ duration: 1000, // in ms
77
+ steps: 25,
78
  })
79
  setAssetUrl(newAssetUrl)
80
  } catch (err) {
 
94
  )}>
95
  <div className={cn(
96
  `flex flex-col md:flex-row`,
97
+ `w-full md:max-w-4xl lg:max-w-5xl xl:max-w-6xl max-h-[80vh]`,
98
  `space-y-3 md:space-y-0 md:space-x-6`,
99
  `transition-all duration-300 ease-in-out`,
100
 
 
115
  `space-y-3 md:space-y-6`,
116
  `items-center`,
117
  )}>
118
+ {assetUrl.startsWith("data:video/mp4")
119
+ ? <video
120
+ muted
121
+ autoPlay
122
+ loop
123
+ src={assetUrl}
124
+ /> :
125
  <img
126
  src={assetUrl}
127
  className={cn(
128
  `w-[512px] object-cover`,
129
  `rounded-2xl`
130
  )}
131
+ />}
132
  </div> : null}
133
 
134
  <div className={cn(
src/app/server/actions/animation.ts CHANGED
@@ -16,6 +16,7 @@ export async function generateAnimation({
16
  size = "512x512",
17
  huggingFaceLora,
18
  replicateLora,
 
19
  nbFrames = 8,
20
  duration = 1000,
21
  steps = 30,
@@ -26,6 +27,7 @@ export async function generateAnimation({
26
 
27
  // pimp the prompt
28
  positivePrompt = [
 
29
  positivePrompt,
30
  "beautiful",
31
  "hd"
 
16
  size = "512x512",
17
  huggingFaceLora,
18
  replicateLora,
19
+ triggerWord,
20
  nbFrames = 8,
21
  duration = 1000,
22
  steps = 30,
 
27
 
28
  // pimp the prompt
29
  positivePrompt = [
30
+ triggerWord,
31
  positivePrompt,
32
  "beautiful",
33
  "hd"
src/app/server/actions/generateWithGradioApi.ts CHANGED
@@ -14,6 +14,17 @@ export async function generateVideoWithGradioAPI({
14
  duration = 1000,
15
  steps = 30,
16
  }: VideoOptions): Promise<string> {
 
 
 
 
 
 
 
 
 
 
 
17
  const res = await fetch(gradioApi + (gradioApi.endsWith("/") ? "" : "/") + "api/predict", {
18
  method: "POST",
19
  headers: {
@@ -21,7 +32,7 @@ export async function generateVideoWithGradioAPI({
21
  // Authorization: `Bearer ${token}`,
22
  },
23
  body: JSON.stringify({
24
- fn_index: 0,
25
  data: [
26
  accessToken,
27
  positivePrompt,
@@ -41,6 +52,7 @@ export async function generateVideoWithGradioAPI({
41
 
42
  const { data } = await res.json()
43
 
 
44
  // Recommendation: handle errors
45
  if (res.status !== 200) {
46
  // This will activate the closest `error.js` Error Boundary
@@ -48,5 +60,5 @@ export async function generateVideoWithGradioAPI({
48
  }
49
  // console.log("data:", data.slice(0, 50))
50
 
51
- return data
52
  }
 
14
  duration = 1000,
15
  steps = 30,
16
  }: VideoOptions): Promise<string> {
17
+ console.log(`SEND TO ${gradioApi + (gradioApi.endsWith("/") ? "" : "/") + "api/predict"}:`, [
18
+ accessToken,
19
+ positivePrompt,
20
+ negativePrompt,
21
+ huggingFaceLora,
22
+ size,
23
+ generateSeed(),
24
+ steps,
25
+ nbFrames,
26
+ duration,
27
+ ])
28
  const res = await fetch(gradioApi + (gradioApi.endsWith("/") ? "" : "/") + "api/predict", {
29
  method: "POST",
30
  headers: {
 
32
  // Authorization: `Bearer ${token}`,
33
  },
34
  body: JSON.stringify({
35
+ fn_index: 1, // <- important!
36
  data: [
37
  accessToken,
38
  positivePrompt,
 
52
 
53
  const { data } = await res.json()
54
 
55
+ // console.log("data:", data)
56
  // Recommendation: handle errors
57
  if (res.status !== 200) {
58
  // This will activate the closest `error.js` Error Boundary
 
60
  }
61
  // console.log("data:", data.slice(0, 50))
62
 
63
+ return data[0]
64
  }
src/app/server/actions/generateWithReplicateAPI.ts CHANGED
@@ -14,7 +14,9 @@ export async function generateVideoWithReplicateAPI({
14
  size = "512x512",
15
  huggingFaceLora,
16
  replicateLora,
17
- steps = 30
 
 
18
  }: VideoOptions): Promise<string> {
19
  if (!replicateToken) {
20
  throw new Error(`you need to configure your AUTH_REPLICATE_API_TOKEN in order to use the REPLICATE rendering engine`)
 
14
  size = "512x512",
15
  huggingFaceLora,
16
  replicateLora,
17
+ nbFrames = 8,
18
+ duration = 1000,
19
+ steps = 30,
20
  }: VideoOptions): Promise<string> {
21
  if (!replicateToken) {
22
  throw new Error(`you need to configure your AUTH_REPLICATE_API_TOKEN in order to use the REPLICATE rendering engine`)
src/types.ts CHANGED
@@ -295,6 +295,8 @@ export type VideoOptions = {
295
 
296
  replicateLora?: string
297
 
 
 
298
  nbFrames?: number // FPS (eg. 8)
299
  duration?: number // in milliseconds
300
 
 
295
 
296
  replicateLora?: string
297
 
298
+ triggerWord?: string
299
+
300
  nbFrames?: number // FPS (eg. 8)
301
  duration?: number // in milliseconds
302