Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess, gradio as gr, os, sys
|
| 2 |
+
|
| 3 |
+
def run_game(prompt, res):
|
| 4 |
+
# launch Matrix-Game’s built-in CLI
|
| 5 |
+
cmd = [
|
| 6 |
+
sys.executable, "-m", "matrix_game.play",
|
| 7 |
+
"--prompt", prompt,
|
| 8 |
+
"--resolution", res
|
| 9 |
+
]
|
| 10 |
+
# stream logs to the browser so you see progress
|
| 11 |
+
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
| 12 |
+
for line in process.stdout:
|
| 13 |
+
yield line.decode()
|
| 14 |
+
|
| 15 |
+
with gr.Blocks() as demo:
|
| 16 |
+
gr.Markdown("# Matrix-Game 2.0 interactive world model")
|
| 17 |
+
prompt = gr.Textbox(value="sunny beach with palm trees", label="Text prompt")
|
| 18 |
+
res = gr.Radio(["512", "720"], value="512", label="Resolution (pixels)")
|
| 19 |
+
out = gr.Textbox(label="Build log", lines=20)
|
| 20 |
+
gr.Button("Generate & Play").click(run_game, [prompt, res], out)
|
| 21 |
+
|
| 22 |
+
demo.launch()
|