Spaces:
Running on Zero
Running on Zero
Video only (ADLIB_MODE=video): Wan 2.2 alone fits the default ZeroGPU size
Browse filesFiles changed (2)
- __pycache__/app.cpython-310.pycAdded
- app.py+11-5
2 unmodified lines34567896 unmodified lines161718192021222318192024252627282924 unmodified lines54555651575859606156626364652 unmodified lines# the user's own Hugging Face token). Endpoint names and input order are a# contract with adlib's catalog (huggingface-space/image and /video).import mathimport osimport tempfile
import gradio as gr6 unmodified linesIMAGE_MODEL = "Tongyi-MAI/Z-Image-Turbo" # Apache-2.0, not gatedVIDEO_MODEL = "Wan-AI/Wan2.2-TI2V-5B-Diffusers" # Apache-2.0
# One model per Space: both together do not fit the default ZeroGPU size# (48 GB). ADLIB_MODE is set per Space: "image" or "video".MODE = os.environ.get("ADLIB_MODE", "video")if MODE == "image": image_pipe = ZImagePipeline.from_pretrained(IMAGE_MODEL, torch_dtype=torch.bfloat16).to("cuda")image_pipe = ZImagePipeline.from_pretrained(IMAGE_MODEL, torch_dtype=torch.bfloat16).to("cuda")vae = AutoencoderKLWan.from_pretrained(VIDEO_MODEL, subfolder="vae", torch_dtype=torch.float32)video_pipe = WanImageToVideoPipeline.from_pretrained(VIDEO_MODEL, vae=vae, torch_dtype=torch.bfloat16).to("cuda")else: vae = AutoencoderKLWan.from_pretrained(VIDEO_MODEL, subfolder="vae", torch_dtype=torch.float32) video_pipe = WanImageToVideoPipeline.from_pretrained(VIDEO_MODEL, vae=vae, torch_dtype=torch.bfloat16).to("cuda")
SIZES = {"9:16": (768, 1344), "16:9": (1344, 768), "1:1": (1024, 1024), "4:5": (896, 1120)}FPS = 2424 unmodified lines
with gr.Blocks(title="adlib preview") as demo: gr.Markdown("Free preview shots for adlib. Calls use your own ZeroGPU quota.") with gr.Tab("Image"): if MODE == "image": p1 = gr.Textbox(label="prompt") a1 = gr.Dropdown(list(SIZES), value="9:16", label="aspect") o1 = gr.Image(type="filepath") gr.Button("Generate").click(image, [p1, a1], o1, api_name="image") with gr.Tab("Video"): else: p2 = gr.Textbox(label="prompt") i2 = gr.Image(type="filepath", label="start image") s2 = gr.Number(value=5, label="seconds")__pycache__/app.cpython-310.pycAdded
app.py+11-5