Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -3,9 +3,10 @@ import spaces
|
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
from diffusers import ModularPipelineBlocks
|
| 6 |
-
from diffusers.utils import export_to_video
|
| 7 |
from diffusers.modular_pipelines import WanModularPipeline
|
| 8 |
|
|
|
|
| 9 |
class MatrixGameWanModularPipeline(WanModularPipeline):
|
| 10 |
"""
|
| 11 |
A ModularPipeline for MatrixGameWan.
|
|
@@ -34,10 +35,13 @@ blocks.sub_blocks.insert("image_to_action", image_to_action_block, 0)
|
|
| 34 |
pipe = MatrixGameWanModularPipeline(blocks, "diffusers/matrix-game-2-modular")
|
| 35 |
pipe.load_components(trust_remote_code=True, device_map="cuda", torch_dtype={"default": torch.bfloat16, "vae": torch.float32})
|
| 36 |
|
|
|
|
| 37 |
@spaces.GPU(120)
|
| 38 |
-
def predict(prompt):
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
|
| 42 |
examples = []
|
| 43 |
|
|
@@ -57,12 +61,14 @@ css = """
|
|
| 57 |
|
| 58 |
with gr.Blocks(css=css) as demo:
|
| 59 |
with gr.Column(elem_id="col-container"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
with gr.Row():
|
| 61 |
with gr.Column():
|
| 62 |
-
|
| 63 |
-
show_label=False,
|
| 64 |
-
type="pil",
|
| 65 |
-
interactive=True)
|
| 66 |
|
| 67 |
with gr.Column():
|
| 68 |
result = gr.Video(label="Result")
|
|
@@ -71,15 +77,17 @@ with gr.Blocks(css=css) as demo:
|
|
| 71 |
prompt = gr.Text(
|
| 72 |
label="Prompt",
|
| 73 |
show_label=False,
|
| 74 |
-
placeholder="describe how you
|
| 75 |
container=False,
|
| 76 |
)
|
|
|
|
| 77 |
run_button = gr.Button("Run!", variant="primary")
|
| 78 |
|
| 79 |
gr.on(
|
| 80 |
-
triggers=[run_button.click
|
| 81 |
fn=predict,
|
| 82 |
inputs=[
|
|
|
|
| 83 |
prompt,
|
| 84 |
],
|
| 85 |
outputs=[result],
|
|
|
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
from diffusers import ModularPipelineBlocks
|
| 6 |
+
from diffusers.utils import export_to_video
|
| 7 |
from diffusers.modular_pipelines import WanModularPipeline
|
| 8 |
|
| 9 |
+
|
| 10 |
class MatrixGameWanModularPipeline(WanModularPipeline):
|
| 11 |
"""
|
| 12 |
A ModularPipeline for MatrixGameWan.
|
|
|
|
| 35 |
pipe = MatrixGameWanModularPipeline(blocks, "diffusers/matrix-game-2-modular")
|
| 36 |
pipe.load_components(trust_remote_code=True, device_map="cuda", torch_dtype={"default": torch.bfloat16, "vae": torch.float32})
|
| 37 |
|
| 38 |
+
|
| 39 |
@spaces.GPU(120)
|
| 40 |
+
def predict(image, prompt):
|
| 41 |
+
return image
|
| 42 |
+
#output = pipe(image=image, prompt=prompt, num_frames=141)
|
| 43 |
+
#return export_to_video(output.values['videos'][0], "output.mp4")
|
| 44 |
+
|
| 45 |
|
| 46 |
examples = []
|
| 47 |
|
|
|
|
| 61 |
|
| 62 |
with gr.Blocks(css=css) as demo:
|
| 63 |
with gr.Column(elem_id="col-container"):
|
| 64 |
+
gr.Markdown(
|
| 65 |
+
"Image to Video [Modular Diffusers](https://huggingface.co/docs/diffusers/v0.35.1/en/modular_diffusers/overview) "
|
| 66 |
+
"Pipeline that uses Qwen 2.5 VL 72B Instruct and [Matrix Game 2.0](https://huggingface.co/Skywork/Matrix-Game-2.0) "
|
| 67 |
+
"to allow you to move through images. Works best for scenes with static elements"
|
| 68 |
+
)
|
| 69 |
with gr.Row():
|
| 70 |
with gr.Column():
|
| 71 |
+
image = gr.Image(label="Input Image", show_label=False, type="pil", interactive=True)
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
with gr.Column():
|
| 74 |
result = gr.Video(label="Result")
|
|
|
|
| 77 |
prompt = gr.Text(
|
| 78 |
label="Prompt",
|
| 79 |
show_label=False,
|
| 80 |
+
placeholder="describe how you would like to move in the image",
|
| 81 |
container=False,
|
| 82 |
)
|
| 83 |
+
with gr.Row():
|
| 84 |
run_button = gr.Button("Run!", variant="primary")
|
| 85 |
|
| 86 |
gr.on(
|
| 87 |
+
triggers=[run_button.click],
|
| 88 |
fn=predict,
|
| 89 |
inputs=[
|
| 90 |
+
image,
|
| 91 |
prompt,
|
| 92 |
],
|
| 93 |
outputs=[result],
|