<jupyter_start><jupyter_text>Interactive<jupyter_code>%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
global alpha


a = image.copy()
h,w,c = image.shape
trimap = np.zeros((h,w,2))
alpha = np.zeros((h,w))
fig  = plt.figure(figsize=(7, 10))
ax = fig.gca()
ax.imshow(a)
fig.tight_layout()



def onclick(event):
    global alpha
    x = min(max(int(np.round(event.xdata)),0), a.shape[1])
    y = min(max(int(np.round(event.ydata)),0), a.shape[0])
    v = int(event.button==1)
    trimap[y,x,v] = 1
    a[y-2:y+2+1,x-2:x+2+1] = v
    for i in range(1):
        alpha =  pred(image, trimap, alpha, model)
    disp_im = (1-0.4*alpha[:,:,None])*a + 0.4*alpha[:,:,None]*np.array((1,0,0))
    ax.imshow(disp_im, vmin=0, vmax=1)



    
# Create an hard reference to the callback not to be cleared by the garbage collector
ka = fig.canvas.mpl_connect('button_press_event', onclick)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1650390625, 'fraction_numerical': 0.0263671875, 'mean_word_length': 4.481283422459893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '303158', 'license': 'MIT', 'n_tokens_mistral': 424, 'n_tokens_neox': 411, 'n_words': 87, 'path': 'Interactive-User-Interface.ipynb', 'repo_name': 'MarcoForte/DeepInteractiveSegmentation', 'size': '1024'}