jbilcke-hf HF staff commited on
Commit
930b21b
1 Parent(s): 18efd17

tiny upgrade

Browse files
src/app/interface/generate/index.tsx CHANGED
@@ -12,10 +12,21 @@ import { getLatestPosts, getPost, postToCommunity } from "@/app/server/actions/c
12
  import { useCountdown } from "@/lib/useCountdown"
13
  import { Countdown } from "../countdown"
14
  import { getSDXLModels } from "@/app/server/actions/models"
15
- import { Post, SDXLModel } from "@/types"
16
  import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"
17
  import { TooltipProvider } from "@radix-ui/react-tooltip"
18
 
 
 
 
 
 
 
 
 
 
 
 
19
  export function Generate() {
20
  const router = useRouter()
21
  const pathname = usePathname()
@@ -38,11 +49,12 @@ export function Generate() {
38
 
39
  const [communityRoll, setCommunityRoll] = useState<Post[]>([])
40
 
 
41
 
42
  const { progressPercent, remainingTimeInSec } = useCountdown({
43
  isActive: isLocked,
44
  timerId: runs, // everytime we change this, the timer will reset
45
- durationInSec: 50, // it usually takes 40 seconds, but there might be lag
46
  onEnd: () => {}
47
  })
48
 
@@ -67,7 +79,6 @@ export function Generate() {
67
  })
68
 
69
  const handleSubmit = () => {
70
- console.log("handleSubmit:", { isLocked, promptDraft })
71
  if (isLocked) { return }
72
  if (!promptDraft) { return }
73
 
@@ -91,35 +102,33 @@ export function Generate() {
91
  const search = current.toString()
92
  router.push(`${pathname}${search ? `?${search}` : ""}`)
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  let newAssetUrl = ""
95
  try {
96
  // console.log("starting transition, calling generateAnimation")
97
- newAssetUrl = await generateAnimation({
98
- positivePrompt: promptDraft,
99
- negativePrompt: "",
100
- huggingFaceLora,
101
- triggerWord,
102
- size: "608x416", // "1024x512", // "512x512" // "320x768"
103
- nbFrames: 8, // if duration is 1000ms then it means 8 FPS
104
- duration: 1000, // in ms
105
- steps: 25,
106
- })
107
  setAssetUrl(newAssetUrl)
108
 
109
  } catch (err) {
110
  console.log("generation failed! probably just a Gradio failure, so let's just run the round robin again!")
111
 
112
  try {
113
- newAssetUrl = await generateAnimation({
114
- positivePrompt: promptDraft,
115
- negativePrompt: "",
116
- huggingFaceLora,
117
- triggerWord,
118
- size: "608x416", // "1024x512", // "512x512" // "320x768"
119
- nbFrames: 8, // if duration is 1000ms then it means 8 FPS
120
- duration: 1000, // in ms
121
- steps: 25,
122
- })
123
  setAssetUrl(newAssetUrl)
124
  } catch (err) {
125
  console.error(`generation failed again! ${err}`)
@@ -304,8 +313,8 @@ export function Generate() {
304
  `backdrop-blur-lg bg-white/40`,
305
  `border-2 border-white/10`,
306
  `items-center`,
307
- `space-y-6 md:space-y-8 lg:space-y-12 xl:space-y-16`,
308
- `px-3 py-6 md:px-6 md:py-12 xl:px-8 xl:py-16`,
309
 
310
  )}>
311
  {assetUrl ? <div
@@ -320,7 +329,7 @@ export function Generate() {
320
  autoPlay
321
  loop
322
  src={assetUrl}
323
- className="rounded-md overflow-hidden"
324
  /> :
325
  <img
326
  src={assetUrl}
@@ -415,6 +424,11 @@ export function Generate() {
415
  </animated.button>
416
  </div>
417
  </div>
 
 
 
 
 
418
 
419
  </div>
420
 
 
12
  import { useCountdown } from "@/lib/useCountdown"
13
  import { Countdown } from "../countdown"
14
  import { getSDXLModels } from "@/app/server/actions/models"
15
+ import { HotshotImageInferenceSize, Post, QualityLevel, QualityOption, SDXLModel } from "@/types"
16
  import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"
17
  import { TooltipProvider } from "@radix-ui/react-tooltip"
18
 
19
+ const qualityOptions = [
20
+ {
21
+ level: "low",
22
+ label: "Low (~ 30 sec)"
23
+ },
24
+ {
25
+ level: "medium",
26
+ label: "Medium (~90 secs)"
27
+ }
28
+ ] as QualityOption[]
29
+
30
  export function Generate() {
31
  const router = useRouter()
32
  const pathname = usePathname()
 
49
 
50
  const [communityRoll, setCommunityRoll] = useState<Post[]>([])
51
 
52
+ const [qualityLevel, setQualityLevel] = useState<QualityLevel>("low")
53
 
54
  const { progressPercent, remainingTimeInSec } = useCountdown({
55
  isActive: isLocked,
56
  timerId: runs, // everytime we change this, the timer will reset
57
+ durationInSec: 80, // it usually takes 40 seconds, but there might be lag
58
  onEnd: () => {}
59
  })
60
 
 
79
  })
80
 
81
  const handleSubmit = () => {
 
82
  if (isLocked) { return }
83
  if (!promptDraft) { return }
84
 
 
102
  const search = current.toString()
103
  router.push(`${pathname}${search ? `?${search}` : ""}`)
104
 
105
+ const size: HotshotImageInferenceSize = "608x416"
106
+
107
+ // 608x416 @ 25 steps -> 32 seconds
108
+ const steps = qualityLevel === "low" ? 25 : 35
109
+
110
+ const params = {
111
+ positivePrompt: promptDraft,
112
+ negativePrompt: "",
113
+ huggingFaceLora,
114
+ triggerWord,
115
+ nbFrames: 10, // if duration is 1000ms then it means 8 FPS
116
+ duration: 1000, // in ms
117
+ steps,
118
+ size
119
+ }
120
+
121
  let newAssetUrl = ""
122
  try {
123
  // console.log("starting transition, calling generateAnimation")
124
+ newAssetUrl = await generateAnimation(params)
 
 
 
 
 
 
 
 
 
125
  setAssetUrl(newAssetUrl)
126
 
127
  } catch (err) {
128
  console.log("generation failed! probably just a Gradio failure, so let's just run the round robin again!")
129
 
130
  try {
131
+ newAssetUrl = await generateAnimation(params)
 
 
 
 
 
 
 
 
 
132
  setAssetUrl(newAssetUrl)
133
  } catch (err) {
134
  console.error(`generation failed again! ${err}`)
 
313
  `backdrop-blur-lg bg-white/40`,
314
  `border-2 border-white/10`,
315
  `items-center`,
316
+ `space-y-6 md:space-y-8 lg:space-y-12 xl:space-y-14`,
317
+ `px-3 py-6 md:px-6 md:py-12 xl:px-8 xl:py-14`,
318
 
319
  )}>
320
  {assetUrl ? <div
 
329
  autoPlay
330
  loop
331
  src={assetUrl}
332
+ className="rounded-md overflow-hidden md:h-[400px] lg:h-[500px] xl:h-[560px]"
333
  /> :
334
  <img
335
  src={assetUrl}
 
424
  </animated.button>
425
  </div>
426
  </div>
427
+ {/*
428
+ <div>
429
+ <p>Generation will take about 32 seconds</p>
430
+ </div>
431
+ */}
432
 
433
  </div>
434
 
src/app/server/actions/censorship.ts CHANGED
@@ -15,7 +15,9 @@ const chickens = [
15
  "681fea565117808c6dbe002520d2cfeeb3e5c67e68630afb4a453449a9da587b",
16
  "2f3d913b3db9e15a930aac43eb2d6fe8817db8e4bcf37794bf0227b06b718d1b",
17
  "922a700b807e4994df82eba2b48a6ac131fe8d8d1035d06b3592d622fb232161",
18
- "cb69ee6774eafcc720adb1f689d28acbb9f47998cbea0299ec66a58dedf91c37"
 
 
19
  ]
20
 
21
  const ducks = [
@@ -71,6 +73,8 @@ const roasted = [
71
  ]
72
 
73
  const banned = [
 
 
74
  "03398ec4bdce4de69c76caf151cf3e1db5454208e88da147d607327a56d9ec27",
75
  "f27229416e1e11b9e7fe28f81fedff6cba2f6cd21eb8ac0d78e74908fbef1bd5",
76
  "8175b29dc4d1c6d57b9d986f2f9ebbddf1d4ba597a35962ea246e4a5d4d0b850",
@@ -181,7 +185,6 @@ encode([
181
  ])
182
  */
183
 
184
-
185
  export const filterOutBadWords = (sentence: string) => {
186
  if (process.env.ENABLE_CENSORSHIP !== "true") { return sentence }
187
 
 
15
  "681fea565117808c6dbe002520d2cfeeb3e5c67e68630afb4a453449a9da587b",
16
  "2f3d913b3db9e15a930aac43eb2d6fe8817db8e4bcf37794bf0227b06b718d1b",
17
  "922a700b807e4994df82eba2b48a6ac131fe8d8d1035d06b3592d622fb232161",
18
+ "cb69ee6774eafcc720adb1f689d28acbb9f47998cbea0299ec66a58dedf91c37",
19
+ "bc1d4ab3fd611d6931e7fbaef942555a3a5e836dc7bacbf1939183a96e41a03b",
20
+ "cf79a5ba29b984a1d35c4cafe917328838af7d9b10e00f4ce91298317212b2b9"
21
  ]
22
 
23
  const ducks = [
 
73
  ]
74
 
75
  const banned = [
76
+ "3ec2ad1877284220d0515bdb8716c9984143f72f9dcadb5396f0ad8f0ba934fb",
77
+ "e7db7d13264f1fc484d07e5ae960a702d50ab004055210c9085b6a77a77e182e",
78
  "03398ec4bdce4de69c76caf151cf3e1db5454208e88da147d607327a56d9ec27",
79
  "f27229416e1e11b9e7fe28f81fedff6cba2f6cd21eb8ac0d78e74908fbef1bd5",
80
  "8175b29dc4d1c6d57b9d986f2f9ebbddf1d4ba597a35962ea246e4a5d4d0b850",
 
185
  ])
186
  */
187
 
 
188
  export const filterOutBadWords = (sentence: string) => {
189
  if (process.env.ENABLE_CENSORSHIP !== "true") { return sentence }
190
 
src/types.ts CHANGED
@@ -313,4 +313,11 @@ export type SDXLModel = {
313
  is_compatible: boolean
314
  likes: number
315
  downloads: number
316
- }
 
 
 
 
 
 
 
 
313
  is_compatible: boolean
314
  likes: number
315
  downloads: number
316
+ }
317
+
318
+ export type QualityLevel = "low" | "medium" | "high"
319
+
320
+ export type QualityOption = {
321
+ level: QualityLevel
322
+ label: string
323
+ }