xizaoqu
commited on
Commit
·
3b61a0b
1
Parent(s):
750f1b3
update
Browse files
app.py
CHANGED
@@ -227,6 +227,18 @@ def set_denoising_steps(denoising_steps, sampling_timesteps_state):
|
|
227 |
print("set denoising steps to", worldmem.sampling_timesteps)
|
228 |
return sampling_timesteps_state
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
def generate(keys):
|
231 |
# print("algo frame:", len(worldmem.frames))
|
232 |
actions = parse_input_to_tensor(keys)
|
@@ -336,41 +348,51 @@ with gr.Blocks(css=css) as demo:
|
|
336 |
# </a>
|
337 |
# </div>
|
338 |
|
|
|
|
|
|
|
|
|
339 |
with gr.Row(variant="panel"):
|
340 |
video_display = gr.Video(autoplay=True, loop=True)
|
341 |
image_display = gr.Image(value=DEFAULT_IMAGE, interactive=False, label="Last Frame")
|
342 |
|
|
|
343 |
with gr.Row(variant="panel"):
|
344 |
with gr.Column(scale=2):
|
345 |
input_box = gr.Textbox(label="Action Sequence", placeholder="Enter action sequence here...", lines=1, max_lines=1)
|
346 |
log_output = gr.Textbox(label="History Log", interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
with gr.Column(scale=1):
|
348 |
-
|
|
|
|
|
349 |
submit_button = gr.Button("Generate")
|
350 |
reset_btn = gr.Button("Reset")
|
351 |
|
352 |
sampling_timesteps_state = gr.State(worldmem.sampling_timesteps)
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
|
357 |
def set_action(action):
|
358 |
return action
|
359 |
|
360 |
-
gr.Markdown("### Action sequence examples.")
|
361 |
-
|
362 |
-
buttons = []
|
363 |
-
for action in example_actions[:2]:
|
364 |
-
with gr.Column(scale=len(action)):
|
365 |
-
buttons.append(gr.Button(action))
|
366 |
-
with gr.Row():
|
367 |
-
for action in example_actions[2:4]:
|
368 |
-
with gr.Column(scale=len(action)):
|
369 |
-
buttons.append(gr.Button(action))
|
370 |
-
with gr.Row():
|
371 |
-
for action in example_actions[4:5]:
|
372 |
-
with gr.Column(scale=len(action)):
|
373 |
-
buttons.append(gr.Button(action))
|
374 |
|
375 |
for button, action in zip(buttons, example_actions):
|
376 |
button.click(set_action, inputs=[gr.State(value=action)], outputs=input_box)
|
@@ -403,7 +425,7 @@ with gr.Blocks(css=css) as demo:
|
|
403 |
- N: no-op (do nothing)
|
404 |
- 1: switch to hotbar 1
|
405 |
- U: use item
|
406 |
-
5. Higher denoising steps produce more detailed results but take longer. **20 steps** is a good balance between quality and speed.
|
407 |
6. If you find this project interesting or useful, please consider giving it a ⭐️ on [GitHub]()!
|
408 |
7. For feedback or suggestions, feel free to open a GitHub issue or contact me directly at **zeqixiao1@gmail.com**.
|
409 |
"""
|
@@ -418,6 +440,8 @@ with gr.Blocks(css=css) as demo:
|
|
418 |
image_display_5.select(lambda: on_image_click(SUNFLOWERS_RAIN_IMAGE), outputs=image_display)
|
419 |
image_display_6.select(lambda: on_image_click(PLACE_IMAGE), outputs=image_display)
|
420 |
|
421 |
-
|
|
|
|
|
422 |
|
423 |
demo.launch()
|
|
|
227 |
print("set denoising steps to", worldmem.sampling_timesteps)
|
228 |
return sampling_timesteps_state
|
229 |
|
230 |
+
def set_context_length(context_length, sampling_context_length_state):
|
231 |
+
worldmem.n_tokens = context_length
|
232 |
+
sampling_context_length_state = context_length
|
233 |
+
print("set context length to", worldmem.n_tokens)
|
234 |
+
return sampling_context_length_state
|
235 |
+
|
236 |
+
def set_memory_length(memory_length, sampling_memory_length_state):
|
237 |
+
worldmem.condition_similar_length = memory_length
|
238 |
+
sampling_memory_length_state = memory_length
|
239 |
+
print("set memory length to", worldmem.condition_similar_length)
|
240 |
+
return sampling_memory_length_state
|
241 |
+
|
242 |
def generate(keys):
|
243 |
# print("algo frame:", len(worldmem.frames))
|
244 |
actions = parse_input_to_tensor(keys)
|
|
|
348 |
# </a>
|
349 |
# </div>
|
350 |
|
351 |
+
example_actions = ["AAAAAAAAAAAADDDDDDDDDDDD", "AAAAAAAAAAAAAAAAAAAAAAAA", "DDDDDDDDEEEEEEEEEESSSAAAAAAAAWWW", "DDDDDDDDDDDDQQQQQQQQQQQQQQQDDDDDDDDDDDD",
|
352 |
+
"DDDDWWWDDDDDDDDDDDDDDDDDDDDSSS", "SSUNNWWEEEEEEEEEAAASSUNNWWEEEEEEEEE"]
|
353 |
+
|
354 |
+
|
355 |
with gr.Row(variant="panel"):
|
356 |
video_display = gr.Video(autoplay=True, loop=True)
|
357 |
image_display = gr.Image(value=DEFAULT_IMAGE, interactive=False, label="Last Frame")
|
358 |
|
359 |
+
|
360 |
with gr.Row(variant="panel"):
|
361 |
with gr.Column(scale=2):
|
362 |
input_box = gr.Textbox(label="Action Sequence", placeholder="Enter action sequence here...", lines=1, max_lines=1)
|
363 |
log_output = gr.Textbox(label="History Log", interactive=False)
|
364 |
+
gr.Markdown("### Action sequence examples.")
|
365 |
+
with gr.Row():
|
366 |
+
buttons = []
|
367 |
+
for action in example_actions[:2]:
|
368 |
+
with gr.Column(scale=len(action)):
|
369 |
+
buttons.append(gr.Button(action))
|
370 |
+
with gr.Row():
|
371 |
+
for action in example_actions[2:4]:
|
372 |
+
with gr.Column(scale=len(action)):
|
373 |
+
buttons.append(gr.Button(action))
|
374 |
+
with gr.Row():
|
375 |
+
for action in example_actions[4:6]:
|
376 |
+
with gr.Column(scale=len(action)):
|
377 |
+
buttons.append(gr.Button(action))
|
378 |
+
|
379 |
with gr.Column(scale=1):
|
380 |
+
slider_denoising_step = gr.Slider(minimum=10, maximum=50, value=worldmem.sampling_timesteps, step=1, label="Denoising Steps")
|
381 |
+
slider_context_length = gr.Slider(minimum=2, maximum=10, value=worldmem.n_tokens, step=1, label="Context Length")
|
382 |
+
slider_memory_length = gr.Slider(minimum=4, maximum=16, value=worldmem.condition_similar_length, step=1, label="Memory Length")
|
383 |
submit_button = gr.Button("Generate")
|
384 |
reset_btn = gr.Button("Reset")
|
385 |
|
386 |
sampling_timesteps_state = gr.State(worldmem.sampling_timesteps)
|
387 |
+
sampling_context_length_state = gr.State(worldmem.n_tokens)
|
388 |
+
sampling_memory_length_state = gr.State(worldmem.condition_similar_length)
|
389 |
+
|
390 |
|
391 |
def set_action(action):
|
392 |
return action
|
393 |
|
394 |
+
# gr.Markdown("### Action sequence examples.")
|
395 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
|
397 |
for button, action in zip(buttons, example_actions):
|
398 |
button.click(set_action, inputs=[gr.State(value=action)], outputs=input_box)
|
|
|
425 |
- N: no-op (do nothing)
|
426 |
- 1: switch to hotbar 1
|
427 |
- U: use item
|
428 |
+
5. Higher denoising steps produce more detailed results but take longer. **20 steps** is a good balance between quality and speed. The same applies to context and memory length.
|
429 |
6. If you find this project interesting or useful, please consider giving it a ⭐️ on [GitHub]()!
|
430 |
7. For feedback or suggestions, feel free to open a GitHub issue or contact me directly at **zeqixiao1@gmail.com**.
|
431 |
"""
|
|
|
440 |
image_display_5.select(lambda: on_image_click(SUNFLOWERS_RAIN_IMAGE), outputs=image_display)
|
441 |
image_display_6.select(lambda: on_image_click(PLACE_IMAGE), outputs=image_display)
|
442 |
|
443 |
+
slider_denoising_step.change(fn=set_denoising_steps, inputs=[slider_denoising_step, sampling_timesteps_state], outputs=sampling_timesteps_state)
|
444 |
+
slider_context_length.change(fn=set_context_length, inputs=[slider_context_length, sampling_context_length_state], outputs=sampling_context_length_state)
|
445 |
+
slider_memory_length.change(fn=set_memory_length, inputs=[slider_memory_length, sampling_memory_length_state], outputs=sampling_memory_length_state)
|
446 |
|
447 |
demo.launch()
|