MCPcopy Create free account
hub / github.com/TencentARC/MotionCtrl / main

Function main

app.py:320–717  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

318
319
320def main(args):
321 demo = gr.Blocks()
322 with demo:
323
324 gr.Markdown(title)
325 gr.Markdown(important_link)
326 gr.Markdown(description)
327
328
329 with gr.Column():
330 # step 0: select based model.
331 gr.Markdown("## Step0: Selecting the model", show_label=False)
332 gr.Markdown( f'- {BASE_MODEL[0]}: **MotionCtrl** deployed on {BASE_MODEL[0]}', show_label=False)
333 gr.Markdown( f'- {BASE_MODEL[1]}: **MotionCtrl** deployed on {BASE_MODEL[1]}', show_label=False)
334 # gr.HighlightedText(value=[("",""), (f'Choosing {BASE_MODEL[1]} requires time for loading new model. Please be patient.', "Normal")],
335 # color_map={"Normal": "green", "Error": "red", "Clear clicks": "gray", "Add mask": "green", "Remove mask": "red"}, visible=True)
336 choose_model = gr.Radio(choices=BASE_MODEL, value=BASE_MODEL[0], label="Based Model", interactive=True)
337 choose_model_button = gr.Button(value="Proceed")
338
339 # step 1: select motion control mode
340 step1 = gr.Markdown("## Step 1/3: Selecting the motion control mode", show_label=False, visible=False)
341 setp1_dec = gr.Markdown( f'\n - {MODE[0]}: Control the camera motion only \
342 \n- {MODE[1]}: Control the object motion only \
343 \n- {MODE[2]}: Control both the camera and object motion \
344 \n- Click `Proceed` to go into next step',
345 show_label=False, visible=False)
346 infer_mode = gr.Radio(choices=MODE, value=MODE[0], label="Motion Control Mode", interactive=True, visible=False)
347 mode_info = gr.Button(value="Proceed", visible=False)
348
349 # step2 - camera + object motion control
350 step2_camera_object_motion = gr.Markdown("---\n## Step 2/3: Select the camera poses and trajectory", show_label=False, visible=False)
351 step2_camera_object_motion_des = gr.Markdown(f"\n 1. Select a basic camera pose. \
352 \n 2. Select a provided trajectory or draw the trajectory yourself.",
353 show_label=False, visible=False)
354
355 # step2 - camera motion control
356 step2_camera_motion = gr.Markdown("---\n## Step 2/3: Select the camera poses", show_label=False, visible=False)
357 step2_camera_motion_des = gr.Markdown(f"\n - {CAMERA_MOTION_MODE[0]}: Including 8 basic camera poses, such as pan up, pan down, zoom in, and zoom out. \
358 \n - {CAMERA_MOTION_MODE[1]}: Complex camera poses extracted from the real videos. \
359 \n - {CAMERA_MOTION_MODE[2]}: You can customize complex camera poses yourself by combining or fusing two of the eight basic camera poses. \
360 \n - Click `Proceed` to go into next step",
361 show_label=False, visible=False)
362 camera_mode = gr.Radio(choices=CAMERA_MOTION_MODE, value=CAMERA_MOTION_MODE[0], label="Camera Motion Control Mode", interactive=True, visible=False)
363 camera_info = gr.Button(value="Proceed", visible=False)
364
365 with gr.Row():
366 with gr.Column():
367 # step2.1 - camera motion control - basic
368 basic_camera_motion = gr.Markdown("---\n### Basic Camera Poses", show_label=False, visible=False)
369 basic_camera_motion_des = gr.Markdown(f"\n 1. Click one of the basic camera poses, such as `Pan Up`; \
370 \n 2. Slide the `Motion speed` to get a speed value. The large the value, the fast the camera motion; \
371 \n 3. Click `Visualize Camera and Proceed` to visualize the camera poses and go proceed; \
372 \n 4. Click `Reset Camera` to reset the camera poses (If needed). ",
373 show_label=False, visible=False)
374
375
376 # step2.2 - camera motion control - provided complex
377 complex_camera_motion = gr.Markdown("---\n### Provided Complex Camera Poses", show_label=False, visible=False)

Callers 1

app.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected