Nekochu commited on
Commit
3dd1e63
·
1 Parent(s): 548c933

keep the download button out of cached examples, gradio crashes on it

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -58,8 +58,23 @@ def momask_generate(text, length, seed):
58
  def kimodo_example(prompt, model_label, frames, seed):
59
  """Examples vary the four columns worth varying; the advanced controls keep
60
  their defaults. Delegating to K.generate rather than duplicating it means a
61
- cached example is the same code path the Generate button runs."""
62
- yield from K.generate(prompt, model_label, int(frames), 20, int(seed), 2.0, True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
 
65
  def kimodo_tab():
@@ -111,7 +126,7 @@ def kimodo_tab():
111
  ["a person kicks with their right leg", K.CHECKPOINTS[2].label, 120, 101],
112
  ],
113
  inputs=[prompt, model_label, frames, seed],
114
- outputs=[video, viewer, bvh, status],
115
  fn=kimodo_example,
116
  # Lazy is the only sane mode here. Each distinct prompt pays a ~110 s
117
  # LLM2Vec encode, so eager would add roughly ten minutes to every build
@@ -161,8 +176,8 @@ def momask_tab():
161
  ["A person does a salsa dance", 0, 789],
162
  ["A person kicks with their right leg", 0, 101],
163
  ],
164
- inputs=[text, length, seed], outputs=[video, bvh],
165
- fn=momask_generate,
166
  # Lazy, not eager. Eager runs every row before the Space serves its first
167
  # request, and it would force torch, onnxruntime and CLIP resident at
168
  # startup for every visitor, which is exactly what _ensure_backends()
 
58
  def kimodo_example(prompt, model_label, frames, seed):
59
  """Examples vary the four columns worth varying; the advanced controls keep
60
  their defaults. Delegating to K.generate rather than duplicating it means a
61
+ cached example is the same code path the Generate button runs.
62
+
63
+ The BVH button is dropped from the yielded tuple on purpose. Caching an
64
+ example whose outputs include a gr.DownloadButton crashes inside gradio:
65
+ postprocess_data reaches components/base.py `if self.info:` and
66
+ DownloadButton has no `info` attribute. Video, skeleton and log cache fine,
67
+ and the button still works normally from Generate.
68
+ """
69
+ for video, glb, _bvh, status in K.generate(
70
+ prompt, model_label, int(frames), 20, int(seed), 2.0, True):
71
+ yield video, glb, status
72
+
73
+
74
+ def momask_example(text, length, seed):
75
+ """Same reason as above: cache the preview, leave the download button out."""
76
+ video, _bvh = momask_generate(text, length, seed)
77
+ return video
78
 
79
 
80
  def kimodo_tab():
 
126
  ["a person kicks with their right leg", K.CHECKPOINTS[2].label, 120, 101],
127
  ],
128
  inputs=[prompt, model_label, frames, seed],
129
+ outputs=[video, viewer, status],
130
  fn=kimodo_example,
131
  # Lazy is the only sane mode here. Each distinct prompt pays a ~110 s
132
  # LLM2Vec encode, so eager would add roughly ten minutes to every build
 
176
  ["A person does a salsa dance", 0, 789],
177
  ["A person kicks with their right leg", 0, 101],
178
  ],
179
+ inputs=[text, length, seed], outputs=[video],
180
+ fn=momask_example,
181
  # Lazy, not eager. Eager runs every row before the Space serves its first
182
  # request, and it would force torch, onnxruntime and CLIP resident at
183
  # startup for every visitor, which is exactly what _ensure_backends()