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 lines3456786 unmodified lines15161718192021222324 unmodified lines4849505152535455565758592 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 tempfileimport 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.0image_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")SIZES = {"9:16": (768, 1344), "16:9": (1344, 768), "1:1": (1024, 1024), "4:5": (896, 1120)}FPS = 2424 unmodified lineswith gr.Blocks(title="adlib preview") as demo:gr.Markdown("Free preview shots for adlib. Calls use your own ZeroGPU quota.")with gr.Tab("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"):p2 = gr.Textbox(label="prompt")i2 = gr.Image(type="filepath", label="start image")s2 = gr.Number(value=5, label="seconds")2 unmodified lines34567896 unmodified lines161718192021222324252627282924 unmodified lines5455565758596061626364652 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 tempfileimport 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")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 lineswith gr.Blocks(title="adlib preview") as demo:gr.Markdown("Free preview shots for adlib. Calls use your own ZeroGPU quota.")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")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