MCPcopy
hub / github.com/XingangPan/DragGAN / on_click_start

Function on_click_start

visualizer_drag_gradio.py:446–643  ·  view source on GitHub ↗
(global_state, image)

Source from the content-addressed store, hash-verified

444 )
445
446 def on_click_start(global_state, image):
447 p_in_pixels = []
448 t_in_pixels = []
449 valid_points = []
450
451 # handle of start drag in mask editing mode
452 global_state = preprocess_mask_info(global_state, image)
453
454 # Prepare the points for the inference
455 if len(global_state["points"]) == 0:
456 # yield on_click_start_wo_points(global_state, image)
457 image_raw = global_state['images']['image_raw']
458 update_image_draw(
459 image_raw,
460 global_state['points'],
461 global_state['mask'],
462 global_state['show_mask'],
463 global_state,
464 )
465
466 yield (
467 global_state,
468 0,
469 global_state['images']['image_show'],
470 # gr.File.update(visible=False),
471 gr.Button.update(interactive=True),
472 gr.Button.update(interactive=True),
473 gr.Button.update(interactive=True),
474 gr.Button.update(interactive=True),
475 gr.Button.update(interactive=True),
476 # latent space
477 gr.Radio.update(interactive=True),
478 gr.Button.update(interactive=True),
479 # NOTE: disable stop button
480 gr.Button.update(interactive=False),
481
482 # update other comps
483 gr.Dropdown.update(interactive=True),
484 gr.Number.update(interactive=True),
485 gr.Number.update(interactive=True),
486 gr.Button.update(interactive=True),
487 gr.Button.update(interactive=True),
488 gr.Checkbox.update(interactive=True),
489 # gr.Number.update(interactive=True),
490 gr.Number.update(interactive=True),
491 )
492 else:
493
494 # Transform the points into torch tensors
495 for key_point, point in global_state["points"].items():
496 try:
497 p_start = point.get("start_temp", point["start"])
498 p_end = point["target"]
499
500 if p_start is None or p_end is None:
501 continue
502
503 except KeyError:

Callers

nothing calls this directly

Calls 5

preprocess_mask_infoFunction · 0.85
update_image_drawFunction · 0.85
reverse_point_pairsFunction · 0.85
_render_drag_implMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected