Spaces:
Running on Zero
Running on Zero
Commit ·
86efd2b
1
Parent(s): 248353b
[Admin maintenance] Support new ZeroGPU hardware (#5)
Browse files- [Admin maintenance] Support new ZeroGPU hardware (336d55d6d624108d984c8de53ec3f226fb7ae67d)
- README.md +1 -1
- demo.py +33 -10
- requirements.txt +3 -3
README.md
CHANGED
|
@@ -4,7 +4,7 @@ app_file: demo.py
|
|
| 4 |
tags:
|
| 5 |
- Text-to-Video
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
short_description: Text-to-Video
|
| 9 |
emoji: 🤗
|
| 10 |
colorFrom: blue
|
|
|
|
| 4 |
tags:
|
| 5 |
- Text-to-Video
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.20.0
|
| 8 |
short_description: Text-to-Video
|
| 9 |
emoji: 🤗
|
| 10 |
colorFrom: blue
|
demo.py
CHANGED
|
@@ -2,6 +2,24 @@
|
|
| 2 |
# imported by older gradio/oauth.py). Must run before `import spaces` (which imports gradio).
|
| 3 |
import huggingface_hub
|
| 4 |
import huggingface_hub.constants as _hub_const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# old diffusers/transformers import symbols removed from newer huggingface_hub; restore them
|
| 6 |
if not hasattr(huggingface_hub, "cached_download"):
|
| 7 |
huggingface_hub.cached_download = huggingface_hub.hf_hub_download
|
|
@@ -20,6 +38,11 @@ if not hasattr(huggingface_hub, "HfFolder"):
|
|
| 20 |
try: huggingface_hub.logout()
|
| 21 |
except Exception: pass
|
| 22 |
huggingface_hub.HfFolder = HfFolder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
import gradio as gr
|
| 24 |
import os
|
| 25 |
import spaces
|
|
@@ -223,17 +246,17 @@ with gr.Blocks() as demo:
|
|
| 223 |
with gr.Row():
|
| 224 |
with gr.Column(visible=True) as input_raws:
|
| 225 |
with gr.Row():
|
| 226 |
-
with gr.Column(scale=1
|
| 227 |
text_input = gr.Textbox(show_label=True, interactive=True, label="Prompt")
|
| 228 |
|
| 229 |
with gr.Row():
|
| 230 |
-
with gr.Column(scale=
|
| 231 |
sample_method = gr.Dropdown(choices=["DDIM", "EulerDiscrete", "PNDM"], label="Sample Method", value="DDIM")
|
| 232 |
|
| 233 |
-
with gr.Column(scale=
|
| 234 |
video_length = gr.Dropdown(choices=[1, 16], label="Video Length (1 for T2I and 16 for T2V)", value=16)
|
| 235 |
with gr.Row():
|
| 236 |
-
with gr.Column(scale=1
|
| 237 |
scfg_scale = gr.Slider(
|
| 238 |
minimum=1,
|
| 239 |
maximum=50,
|
|
@@ -243,7 +266,7 @@ with gr.Blocks() as demo:
|
|
| 243 |
label="Guidence Scale",
|
| 244 |
)
|
| 245 |
with gr.Row():
|
| 246 |
-
with gr.Column(scale=1
|
| 247 |
seed = gr.Slider(
|
| 248 |
minimum=1,
|
| 249 |
maximum=2147483647,
|
|
@@ -253,7 +276,7 @@ with gr.Blocks() as demo:
|
|
| 253 |
label="Seed",
|
| 254 |
)
|
| 255 |
with gr.Row():
|
| 256 |
-
with gr.Column(scale=
|
| 257 |
height = gr.Slider(
|
| 258 |
minimum=256,
|
| 259 |
maximum=768,
|
|
@@ -263,7 +286,7 @@ with gr.Blocks() as demo:
|
|
| 263 |
label="Height",
|
| 264 |
)
|
| 265 |
# with gr.Row():
|
| 266 |
-
with gr.Column(scale=
|
| 267 |
width = gr.Slider(
|
| 268 |
minimum=256,
|
| 269 |
maximum=768,
|
|
@@ -273,7 +296,7 @@ with gr.Blocks() as demo:
|
|
| 273 |
label="Width",
|
| 274 |
)
|
| 275 |
with gr.Row():
|
| 276 |
-
with gr.Column(scale=1
|
| 277 |
diffusion_step = gr.Slider(
|
| 278 |
minimum=20,
|
| 279 |
maximum=250,
|
|
@@ -284,11 +307,11 @@ with gr.Blocks() as demo:
|
|
| 284 |
)
|
| 285 |
|
| 286 |
|
| 287 |
-
with gr.Column(scale=
|
| 288 |
output = gr.Video(interactive=False, include_audio=True, elem_id="输出的视频") #.style(height=360)
|
| 289 |
|
| 290 |
with gr.Row():
|
| 291 |
-
with gr.Column(scale=1
|
| 292 |
run = gr.Button(value="Generate", variant='primary')
|
| 293 |
|
| 294 |
EXAMPLES = [
|
|
|
|
| 2 |
# imported by older gradio/oauth.py). Must run before `import spaces` (which imports gradio).
|
| 3 |
import huggingface_hub
|
| 4 |
import huggingface_hub.constants as _hub_const
|
| 5 |
+
# newer huggingface_hub dropped the `use_auth_token` kwarg (renamed to `token`), still passed
|
| 6 |
+
# by diffusers==0.24.0 (load_config, from_pretrained, download). Wrap the hub entry points it
|
| 7 |
+
# uses so `use_auth_token` is translated to `token`.
|
| 8 |
+
import functools as _functools
|
| 9 |
+
def _drop_use_auth_token(fn):
|
| 10 |
+
@_functools.wraps(fn)
|
| 11 |
+
def _wrapped(*args, **kwargs):
|
| 12 |
+
if "use_auth_token" in kwargs:
|
| 13 |
+
_tok = kwargs.pop("use_auth_token")
|
| 14 |
+
kwargs.setdefault("token", _tok)
|
| 15 |
+
return fn(*args, **kwargs)
|
| 16 |
+
return _wrapped
|
| 17 |
+
for _mod_fn in ("hf_hub_download", "snapshot_download", "model_info", "repo_info", "list_repo_files"):
|
| 18 |
+
if hasattr(huggingface_hub, _mod_fn):
|
| 19 |
+
setattr(huggingface_hub, _mod_fn, _drop_use_auth_token(getattr(huggingface_hub, _mod_fn)))
|
| 20 |
+
for _api_fn in ("model_info", "repo_info", "snapshot_download", "hf_hub_download", "list_repo_files"):
|
| 21 |
+
if hasattr(huggingface_hub.HfApi, _api_fn):
|
| 22 |
+
setattr(huggingface_hub.HfApi, _api_fn, _drop_use_auth_token(getattr(huggingface_hub.HfApi, _api_fn)))
|
| 23 |
# old diffusers/transformers import symbols removed from newer huggingface_hub; restore them
|
| 24 |
if not hasattr(huggingface_hub, "cached_download"):
|
| 25 |
huggingface_hub.cached_download = huggingface_hub.hf_hub_download
|
|
|
|
| 38 |
try: huggingface_hub.logout()
|
| 39 |
except Exception: pass
|
| 40 |
huggingface_hub.HfFolder = HfFolder
|
| 41 |
+
# transformers>=5 removed FLAX_WEIGHTS_NAME (still imported by diffusers==0.24.0
|
| 42 |
+
# pipeline_utils); restore the constant so the old diffusers import succeeds.
|
| 43 |
+
import transformers.utils as _tf_utils
|
| 44 |
+
if not hasattr(_tf_utils, "FLAX_WEIGHTS_NAME"):
|
| 45 |
+
_tf_utils.FLAX_WEIGHTS_NAME = "flax_model.msgpack"
|
| 46 |
import gradio as gr
|
| 47 |
import os
|
| 48 |
import spaces
|
|
|
|
| 246 |
with gr.Row():
|
| 247 |
with gr.Column(visible=True) as input_raws:
|
| 248 |
with gr.Row():
|
| 249 |
+
with gr.Column(scale=1):
|
| 250 |
text_input = gr.Textbox(show_label=True, interactive=True, label="Prompt")
|
| 251 |
|
| 252 |
with gr.Row():
|
| 253 |
+
with gr.Column(scale=1):
|
| 254 |
sample_method = gr.Dropdown(choices=["DDIM", "EulerDiscrete", "PNDM"], label="Sample Method", value="DDIM")
|
| 255 |
|
| 256 |
+
with gr.Column(scale=1):
|
| 257 |
video_length = gr.Dropdown(choices=[1, 16], label="Video Length (1 for T2I and 16 for T2V)", value=16)
|
| 258 |
with gr.Row():
|
| 259 |
+
with gr.Column(scale=1):
|
| 260 |
scfg_scale = gr.Slider(
|
| 261 |
minimum=1,
|
| 262 |
maximum=50,
|
|
|
|
| 266 |
label="Guidence Scale",
|
| 267 |
)
|
| 268 |
with gr.Row():
|
| 269 |
+
with gr.Column(scale=1):
|
| 270 |
seed = gr.Slider(
|
| 271 |
minimum=1,
|
| 272 |
maximum=2147483647,
|
|
|
|
| 276 |
label="Seed",
|
| 277 |
)
|
| 278 |
with gr.Row():
|
| 279 |
+
with gr.Column(scale=1):
|
| 280 |
height = gr.Slider(
|
| 281 |
minimum=256,
|
| 282 |
maximum=768,
|
|
|
|
| 286 |
label="Height",
|
| 287 |
)
|
| 288 |
# with gr.Row():
|
| 289 |
+
with gr.Column(scale=1):
|
| 290 |
width = gr.Slider(
|
| 291 |
minimum=256,
|
| 292 |
maximum=768,
|
|
|
|
| 296 |
label="Width",
|
| 297 |
)
|
| 298 |
with gr.Row():
|
| 299 |
+
with gr.Column(scale=1):
|
| 300 |
diffusion_step = gr.Slider(
|
| 301 |
minimum=20,
|
| 302 |
maximum=250,
|
|
|
|
| 307 |
)
|
| 308 |
|
| 309 |
|
| 310 |
+
with gr.Column(scale=1, visible=True) as video_upload:
|
| 311 |
output = gr.Video(interactive=False, include_audio=True, elem_id="输出的视频") #.style(height=360)
|
| 312 |
|
| 313 |
with gr.Row():
|
| 314 |
+
with gr.Column(scale=1, min_width=0):
|
| 315 |
run = gr.Button(value="Generate", variant='primary')
|
| 316 |
|
| 317 |
EXAMPLES = [
|
requirements.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
torch
|
| 2 |
-
torchvision
|
| 3 |
-
torchaudio
|
| 4 |
timm
|
| 5 |
diffusers[torch]==0.24.0
|
| 6 |
accelerate
|
|
|
|
| 1 |
+
torch==2.8.0
|
| 2 |
+
torchvision==0.23.0
|
| 3 |
+
torchaudio==2.8.0
|
| 4 |
timm
|
| 5 |
diffusers[torch]==0.24.0
|
| 6 |
accelerate
|