Here are the examples of the python api bokeh.models.widgets.ColorPicker taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
Source : view.py
with BSD 3-Clause "New" or "Revised" License
from JaneliaSciComp
with BSD 3-Clause "New" or "Revised" License
from JaneliaSciComp
def init(_bokeh_document):
global bokeh_document, cluster_dot_palette, snippet_palette, p_cluster, cluster_dots, p_cluster_dots, precomputed_dots, snippets_dy, p_snippets, snippets_label_sources_clustered, snippets_label_sources_annotated, snippets_wave_sources, snippets_wave_glyphs, snippets_gram_sources, snippets_gram_glyphs, snippets_quad_grey, dot_size_cluster, dot_alpha_cluster, cluster_circle_fuchsia, p_waveform, p_spectrogram, p_probability, probability_source, probability_glyph, spectrogram_source, spectrogram_glyph, waveform_span_red, spectrogram_span_red, waveform_quad_grey_clustered, waveform_quad_grey_annotated, waveform_quad_grey_pan, waveform_quad_fuchsia, spectrogram_quad_grey_clustered, spectrogram_quad_grey_annotated, spectrogram_quad_grey_pan, spectrogram_quad_fuchsia, snippets_quad_fuchsia, waveform_source, waveform_glyph, waveform_label_source_clustered, waveform_label_source_annotated, spectrogram_label_source_clustered, spectrogram_label_source_annotated, which_layer, which_species, which_word, which_nohyphen, which_kind, color_picker, circle_radius, dot_size, dot_alpha, zoom_context, zoom_offset, zoomin, zoomout, reset, panleft, panright, allleft, allout, allright, save_indicator, label_count_widgets, label_text_widgets, play, play_callback, video_toggle, video_div, undo, redo, detect, misses, configuration_file, train, leaveoneout, leaveallout, xvalidate, mistakes, activations, cluster, visualize, accuracy, freeze, classify, ethogram, compare, congruence, status_ticker, waitfor, file_dialog_source, file_dialog_source, configuration_contents, logs, logs_folder, model, model_file, wavtfcsvfiles, wavtfcsvfiles_string, groundtruth, groundtruth_folder, validationfiles, testfiles, validationfiles_string, testfiles_string, wantedwords, wantedwords_string, labeltypes, labeltypes_string, prevalences, prevalences_string, copy, labelsounds, makepredictions, fixfalsepositives, fixfalsenegatives, generalize, tunehyperparameters, findnovellabels, examineerrors, testdensely, doit, time_sigma_string, time_smooth_ms_string, frequency_n_ms_string, frequency_nw_string, frequency_p_string, frequency_smooth_ms_string, nsteps_string, restore_from_string, save_and_validate_period_string, validate_percentage_string, mini_batch_string, kfold_string, activations_equalize_ratio_string, activations_max_samples_string, pca_fraction_variance_to_retain_string, tsne_perplexity_string, tsne_exaggeration_string, umap_neighbors_string, umap_distance_string, cluster_algorithm, cluster_these_layers, precision_recall_ratios_string, context_ms_string, shiftby_ms_string, representation, window_ms_string, stride_ms_string, mel_dct_string, optimizer, learning_rate_string, replicates_string, batch_seed_string, weights_seed_string, file_dialog_string, file_dialog_table, readme_contents, wordcounts, wizard_buttons, action_buttons, parameter_buttons, parameter_textinputs, wizard2actions, action2parameterbuttons, action2parametertextinputs, status_ticker_update, status_ticker_pre, status_ticker_post, model_parameters
bokeh_document = _bokeh_document
M.cluster_circle_color = M.cluster_circle_color
if '#' in M.cluster_dot_palette:
cluster_dot_palette = ast.literal_eval(M.cluster_dot_palette)
else:
cluster_dot_palette = getattr(palettes, M.cluster_dot_palette)
snippet_palette = getattr(palettes, M.snippets_colormap)
dot_size_cluster = ColumnDataSource(data=dict(ds=[M.state["dot_size"]]))
dot_alpha_cluster = ColumnDataSource(data=dict(da=[M.state["dot_alpha"]]))
cluster_dots = ColumnDataSource(data=dict(dx=[], dy=[], dz=[], dl=[], dc=[]))
cluster_circle_fuchsia = ColumnDataSource(data=dict(cx=[], cy=[], cz=[], cr=[], cc=[]))
p_cluster = ScatterNd(dx='dx', dy='dy', dz='dz', dl='dl', dc='dc',
dots_source=cluster_dots,
cx='cx', cy='cy', cz='cz', cr='cr', cc='cc',
circle_fuchsia_source=cluster_circle_fuchsia,
ds='ds',
dot_size_source=dot_size_cluster,
da='da',
dot_alpha_source=dot_alpha_cluster,
width=M.gui_width_pix//2)
p_cluster.on_change("click_position", lambda a,o,n: C.cluster_tap_callback(n))
precomputed_dots = None
snippets_dy = 2*M.snippets_waveform + 2*M.snippets_spectrogram
p_snippets = figure(plot_width=M.gui_width_pix//2, \
background_fill_color='#FFFFFF', toolbar_location=None)
p_snippets.toolbar.active_drag = None
p_snippets.grid.visible = False
p_snippets.xaxis.visible = False
p_snippets.yaxis.visible = False
snippets_gram_sources=[None]*(M.snippets_nx*M.snippets_ny)
snippets_gram_glyphs=[None]*(M.snippets_nx*M.snippets_ny)
for ixy in range(M.snippets_nx*M.snippets_ny):
snippets_gram_sources[ixy]=[None]*M.audio_nchannels
snippets_gram_glyphs[ixy]=[None]*M.audio_nchannels
for ichannel in range(M.audio_nchannels):
snippets_gram_sources[ixy][ichannel] = ColumnDataSource(data=dict(image=[]))
snippets_gram_glyphs[ixy][ichannel] = p_snippets.image('image',
source=snippets_gram_sources[ixy][ichannel],
palette=M.spectrogram_colormap)
snippets_quad_grey = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_snippets.quad('left','right','top','bottom',source=snippets_quad_grey,
fill_color="lightgrey", fill_alpha=0.5, line_color="lightgrey")
snippets_wave_sources=[None]*(M.snippets_nx*M.snippets_ny)
snippets_wave_glyphs=[None]*(M.snippets_nx*M.snippets_ny)
for ixy in range(M.snippets_nx*M.snippets_ny):
snippets_wave_sources[ixy]=[None]*M.audio_nchannels
snippets_wave_glyphs[ixy]=[None]*M.audio_nchannels
for ichannel in range(M.audio_nchannels):
snippets_wave_sources[ixy][ichannel]=ColumnDataSource(data=dict(x=[], y=[]))
snippets_wave_glyphs[ixy][ichannel]=p_snippets.line(
'x', 'y', source=snippets_wave_sources[ixy][ichannel])
xdata = [(i%M.snippets_nx)*(M.snippets_gap_pix+M.snippets_pix)
for i in range(M.snippets_nx*M.snippets_ny)]
ydata = [-(i//M.snippets_nx*snippets_dy-1)
for i in range(M.snippets_nx*M.snippets_ny)]
text = ['' for i in range(M.snippets_nx*M.snippets_ny)]
snippets_label_sources_clustered = ColumnDataSource(data=dict(x=xdata, y=ydata, text=text))
p_snippets.text('x', 'y', source=snippets_label_sources_clustered, text_font_size='6pt',
text_baseline='top',
text_color='black' if M.snippets_waveform else 'white')
xdata = [(i%M.snippets_nx)*(M.snippets_gap_pix+M.snippets_pix)
for i in range(M.snippets_nx*M.snippets_ny)]
ydata = [-(i//M.snippets_nx*snippets_dy+1+2*(M.snippets_waveform and M.snippets_spectrogram))
for i in range(M.snippets_nx*M.snippets_ny)]
text_annotated = ['' for i in range(M.snippets_nx*M.snippets_ny)]
snippets_label_sources_annotated = ColumnDataSource(data=dict(x=xdata, y=ydata,
text=text_annotated))
p_snippets.text('x', 'y', source=snippets_label_sources_annotated,
text_font_size='6pt',
text_color='white' if M.snippets_spectrogram else 'black')
snippets_quad_fuchsia = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_snippets.quad('left','right','top','bottom',source=snippets_quad_fuchsia,
fill_color=None, line_color="fuchsia")
p_snippets.on_event(Tap, C.snippets_tap_callback)
p_snippets.on_event(DoubleTap, C.snippets_doubletap_callback)
p_waveform = figure(plot_width=M.gui_width_pix,
plot_height=M.context_waveform_height_pix,
background_fill_color='#FFFFFF', toolbar_location=None)
p_waveform.toolbar.active_drag = None
p_waveform.grid.visible = False
if M.context_spectrogram:
p_waveform.xaxis.visible = False
else:
p_waveform.xaxis.axis_label = 'Time (sec)'
p_waveform.yaxis.axis_label = ""
p_waveform.yaxis.ticker = []
p_waveform.x_range.range_padding = p_waveform.y_range.range_padding = 0.0
p_waveform.y_range.start = -1
p_waveform.y_range.end = 1
p_waveform.title.text=' '
waveform_span_red = Span(location=0, dimension='height', line_color='red')
p_waveform.add_layout(waveform_span_red)
waveform_span_red.visible=False
waveform_quad_grey_clustered = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_waveform.quad('left','right','top','bottom',source=waveform_quad_grey_clustered,
fill_color="lightgrey", fill_alpha=0.5, line_color="lightgrey",
level='underlay')
waveform_quad_grey_annotated = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_waveform.quad('left','right','top','bottom',source=waveform_quad_grey_annotated,
fill_color="lightgrey", fill_alpha=0.5, line_color="lightgrey",
level='underlay')
waveform_quad_grey_pan = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_waveform.quad('left','right','top','bottom',source=waveform_quad_grey_pan,
fill_color="lightgrey", fill_alpha=0.5, line_color="lightgrey",
level='underlay')
waveform_quad_fuchsia = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_waveform.quad('left','right','top','bottom',source=waveform_quad_fuchsia,
fill_color=None, line_color="fuchsia", level='underlay')
waveform_source=[None]*M.audio_nchannels
waveform_glyph=[None]*M.audio_nchannels
for ichannel in range(M.audio_nchannels):
waveform_source[ichannel] = ColumnDataSource(data=dict(x=[], y=[]))
waveform_glyph[ichannel] = p_waveform.line('x', 'y', source=waveform_source[ichannel])
waveform_label_source_clustered = ColumnDataSource(data=dict(x=[], y=[], text=[]))
p_waveform.text('x', 'y', source=waveform_label_source_clustered,
text_font_size='6pt', text_align='center', text_baseline='top',
text_line_height=0.8, level='underlay')
waveform_label_source_annotated = ColumnDataSource(data=dict(x=[], y=[], text=[]))
p_waveform.text('x', 'y', source=waveform_label_source_annotated,
text_font_size='6pt', text_align='center', text_baseline='bottom',
text_line_height=0.8, level='underlay')
p_waveform.on_event(DoubleTap, lambda e: C.context_doubletap_callback(e, 0))
p_waveform.on_event(PanStart, C.waveform_pan_start_callback)
p_waveform.on_event(Pan, C.waveform_pan_callback)
p_waveform.on_event(PanEnd, C.waveform_pan_end_callback)
p_waveform.on_event(Tap, C.waveform_tap_callback)
p_spectrogram = figure(plot_width=M.gui_width_pix,
plot_height=M.context_spectrogram_height_pix,
background_fill_color='#FFFFFF', toolbar_location=None)
p_spectrogram.toolbar.active_drag = None
p_spectrogram.x_range.range_padding = p_spectrogram.y_range.range_padding = 0
p_spectrogram.xgrid.visible = False
p_spectrogram.ygrid.visible = True
p_spectrogram.xaxis.axis_label = 'Time (sec)'
p_spectrogram.yaxis.axis_label = 'Frequency (' + M.context_spectrogram_units + ')'
p_spectrogram.yaxis.ticker = list(range(1+M.audio_nchannels))
spectrogram_source = [None]*M.audio_nchannels
spectrogram_glyph = [None]*M.audio_nchannels
for ichannel in range(M.audio_nchannels):
spectrogram_source[ichannel] = ColumnDataSource(data=dict(image=[]))
spectrogram_glyph[ichannel] = p_spectrogram.image('image',
source=spectrogram_source[ichannel],
palette=M.spectrogram_colormap,
level="image")
p_spectrogram.on_event(MouseWheel, C.spectrogram_mousewheel_callback)
p_spectrogram.on_event(DoubleTap,
lambda e: C.context_doubletap_callback(e, M.audio_nchannels/2))
p_spectrogram.on_event(PanStart, C.spectrogram_pan_start_callback)
p_spectrogram.on_event(Pan, C.spectrogram_pan_callback)
p_spectrogram.on_event(PanEnd, C.spectrogram_pan_end_callback)
p_spectrogram.on_event(Tap, C.spectrogram_tap_callback)
spectrogram_span_red = Span(location=0, dimension='height', line_color='red')
p_spectrogram.add_layout(spectrogram_span_red)
spectrogram_span_red.visible=False
spectrogram_quad_grey_clustered = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_spectrogram.quad('left','right','top','bottom',source=spectrogram_quad_grey_clustered,
fill_color="lightgrey", fill_alpha=0.5, line_color="lightgrey",
level='underlay')
spectrogram_quad_grey_annotated = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_spectrogram.quad('left','right','top','bottom',source=spectrogram_quad_grey_annotated,
fill_color="lightgrey", fill_alpha=0.5, line_color="lightgrey",
level='underlay')
spectrogram_quad_grey_pan = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_spectrogram.quad('left','right','top','bottom',source=spectrogram_quad_grey_pan,
fill_color="lightgrey", fill_alpha=0.5, line_color="lightgrey",
level='underlay')
spectrogram_quad_fuchsia = ColumnDataSource(data=dict(left=[], right=[], top=[], bottom=[]))
p_spectrogram.quad('left','right','top','bottom',source=spectrogram_quad_fuchsia,
fill_color=None, line_color="fuchsia", level='underlay')
spectrogram_label_source_clustered = ColumnDataSource(data=dict(x=[], y=[], text=[]))
p_spectrogram.text('x', 'y', source=spectrogram_label_source_clustered,
text_font_size='6pt', text_align='center', text_baseline='top',
text_line_height=0.8, level='underlay', text_color='white')
spectrogram_label_source_annotated = ColumnDataSource(data=dict(x=[], y=[], text=[]))
p_spectrogram.text('x', 'y', source=spectrogram_label_source_annotated,
text_font_size='6pt', text_align='center', text_baseline='bottom',
text_line_height=0.8, level='underlay', text_color='white')
TOOLTIPS = """
< div> < div> < span style="color:@colors;">@labels < /span> < /div> < /div>
"""
p_probability = figure(plot_width=M.gui_width_pix, tooltips=TOOLTIPS,
plot_height=M.context_probability_height_pix,
background_fill_color='#FFFFFF', toolbar_location=None)
p_probability.toolbar.active_drag = None
p_probability.grid.visible = False
p_probability.yaxis.axis_label = "Probability"
p_probability.x_range.range_padding = p_probability.y_range.range_padding = 0.0
p_probability.y_range.start = 0
p_probability.y_range.end = 1
p_probability.xaxis.visible = False
probability_source = ColumnDataSource(data=dict(xs=[], ys=[], colors=[], labels=[]))
probability_glyph = p_probability.multi_line(xs='xs', ys='ys',
source=probability_source, color='colors')
probability_span_red = Span(location=0, dimension='height', line_color='red')
p_probability.add_layout(probability_span_red)
probability_span_red.visible=False
which_layer = Select(title="layer:")
which_layer.on_change('value', lambda a,o,n: C.layer_callback(n))
which_species = Select(title="species:")
which_species.on_change('value', lambda a,o,n: C.species_callback(n))
which_word = Select(title="word:")
which_word.on_change('value', lambda a,o,n: C.word_callback(n))
which_nohyphen = Select(title="no hyphen:")
which_nohyphen.on_change('value', lambda a,o,n: C.nohyphen_callback(n))
which_kind = Select(title="kind:")
which_kind.on_change('value', lambda a,o,n: C.kind_callback(n))
color_picker = ColorPicker(title="color:", disabled=True)
color_picker.on_change("color", lambda a,o,n: C.color_picker_callback(n))
circle_radius = Slider(start=0, end=10, step=1, \
value=M.state["circle_radius"], \
title="circle radius", \
disabled=True)
circle_radius.on_change("value_throttled", C.circle_radius_callback)
dot_size = Slider(start=1, end=24, step=1, \
value=M.state["dot_size"], \
title="dot size", \
disabled=True)
dot_size.on_change("value", C.dot_size_callback)
dot_alpha = Slider(start=0.01, end=1.0, step=0.01, \
value=M.state["dot_alpha"], \
title="dot alpha", \
disabled=True)
dot_alpha.on_change("value", C.dot_alpha_callback)
cluster_update()
zoom_context = TextInput(value=str(M.context_width_ms),
title="context (msec):",
disabled=True)
zoom_context.on_change("value", C.zoom_context_callback)
zoom_offset = TextInput(value=str(M.context_offset_ms),
title="offset (msec):",
disabled=True)
zoom_offset.on_change("value", C.zoom_offset_callback)
zoomin = Button(label='\u2191', disabled=True)
zoomin.on_click(C.zoomin_callback)
zoomout = Button(label='\u2193', disabled=True)
zoomout.on_click(C.zoomout_callback)
reset = Button(label='\u25ef', disabled=True)
reset.on_click(C.zero_callback)
panleft = Button(label='\u2190', disabled=True)
panleft.on_click(C.panleft_callback)
panright = Button(label='\u2192', disabled=True)
panright.on_click(C.panright_callback)
allleft = Button(label='\u21e4', disabled=True)
allleft.on_click(C.allleft_callback)
allout = Button(label='\u2913', disabled=True)
allout.on_click(C.allout_callback)
allright = Button(label='\u21e5', disabled=True)
allright.on_click(C.allright_callback)
save_indicator = Button(label='0')
label_count_callbacks=[]
label_count_widgets=[]
label_text_callbacks=[]
label_text_widgets=[]
for i in range(M.nlabels):
label_count_callbacks.append(lambda i=i: C.label_count_callback(i))
label_count_widgets.append(Button(label='0', css_classes=['hide-label'], width=40))
label_count_widgets[-1].on_click(label_count_callbacks[-1])
label_text_callbacks.append(lambda a,o,n,i=i: C.label_text_callback(n,i))
label_text_widgets.append(TextInput(value=M.state['labels'][i],
css_classes=['hide-label']))
label_text_widgets[-1].on_change("value", label_text_callbacks[-1])
C.label_count_callback(M.ilabel)
play = Button(label='play', disabled=True)
play_callback = CustomJS(args=dict(waveform_span_red=waveform_span_red,
spectrogram_span_red=spectrogram_span_red,
probability_span_red=probability_span_red),
code=C.play_callback_code % ("",""))
play.js_on_event(ButtonClick, play_callback)
play.on_change('disabled', lambda a,o,n: reset_video())
play.js_on_change('disabled', play_callback)
video_toggle = Toggle(label='video', active=False, disabled=True)
video_toggle.on_click(lambda x: context_update())
video_div = Div(text=""" < video id="context_video"> < /video>""", width=0, height=0)
undo = Button(label='undo', disabled=True)
undo.on_click(C.undo_callback)
redo = Button(label='redo', disabled=True)
redo.on_click(C.redo_callback)
detect = Button(label='detect')
detect.on_click(lambda: C.action_callback(detect, C.detect_actuate))
misses = Button(label='misses')
misses.on_click(lambda: C.action_callback(misses, C.misses_actuate))
train = Button(label='train')
train.on_click(lambda: C.action_callback(train, C.train_actuate))
leaveoneout = Button(label='omit one')
leaveoneout.on_click(lambda: C.action_callback(leaveoneout,
lambda: C.leaveout_actuate(False)))
leaveallout = Button(label='omit all')
leaveallout.on_click(lambda: C.action_callback(leaveallout,
lambda: C.leaveout_actuate(True)))
xvalidate = Button(label='x-validate')
xvalidate.on_click(lambda: C.action_callback(xvalidate, C.xvalidate_actuate))
mistakes = Button(label='mistakes')
mistakes.on_click(lambda: C.action_callback(mistakes, C.mistakes_actuate))
activations = Button(label='activations')
activations.on_click(lambda: C.action_callback(activations, C.activations_actuate))
cluster = Button(label='cluster')
cluster.on_click(lambda: C.action_callback(cluster, C.cluster_actuate))
visualize = Button(label='visualize')
visualize.on_click(lambda: C.action_callback(visualize, C.visualize_actuate))
accuracy = Button(label='accuracy')
accuracy.on_click(lambda: C.action_callback(accuracy, C.accuracy_actuate))
freeze = Button(label='freeze')
freeze.on_click(lambda: C.action_callback(freeze, C.freeze_actuate))
classify = Button(label='classify')
classify.on_click(C.classify_callback)
ethogram = Button(label='ethogram')
ethogram.on_click(lambda: C.action_callback(ethogram, C.ethogram_actuate))
compare = Button(label='compare')
compare.on_click(lambda: C.action_callback(compare, C.compare_actuate))
congruence = Button(label='congruence')
congruence.on_click(lambda: C.action_callback(congruence, C.congruence_actuate))
status_ticker_pre=" < div style='overflow:auto; white-space:nowrap; width:"+str(M.gui_width_pix-126)+"px'>status: "
status_ticker_post=" < /div>"
status_ticker = Div(text=status_ticker_pre+status_ticker_post)
file_dialog_source = ColumnDataSource(data=dict(names=[], sizes=[], dates=[]))
file_dialog_source.selected.on_change('indices', C.file_dialog_callback)
file_dialog_columns = [
TableColumn(field="names", title="Name", width=M.gui_width_pix//2-50-115-30),
TableColumn(field="sizes", title="Size", width=50, \
formatter=NumberFormatter(format="0 b")),
TableColumn(field="dates", title="Date", width=115, \
formatter=DateFormatter(format="%Y-%m-%d %H:%M:%S")),
]
file_dialog_table = DataTable(source=file_dialog_source, \
columns=file_dialog_columns, \
height=727, width=M.gui_width_pix//2-11, \
index_position=None,
fit_columns=False)
waitfor = Toggle(label='wait for last job', active=False, disabled=True, width=100)
waitfor.on_click(C.waitfor_callback)
logs = Button(label='logs folder:', width=110)
logs.on_click(C.logs_callback)
logs_folder = TextInput(value=M.state['logs'], title="", disabled=False)
logs_folder.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
model = Button(label='checkpoint file:', width=110)
model.on_click(C.model_callback)
model_file = TextInput(value=M.state['model'], title="", disabled=False)
model_file.on_change('value', model_file_update)
wavtfcsvfiles = Button(label='wav,tf,csv files:', width=110)
wavtfcsvfiles.on_click(C.wavtfcsvfiles_callback)
wavtfcsvfiles_string = TextInput(value=M.state['wavtfcsvfiles'], title="", disabled=False)
wavtfcsvfiles_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
groundtruth = Button(label='ground truth:', width=110)
groundtruth.on_click(C.groundtruth_callback)
groundtruth_folder = TextInput(value=M.state['groundtruth'], title="", disabled=False)
groundtruth_folder.on_change('value', lambda a,o,n: groundtruth_update())
validationfiles = Button(label='validation files:', width=110)
validationfiles.on_click(C.validationfiles_callback)
validationfiles_string = TextInput(value=M.state['validationfiles'], title="", disabled=False)
validationfiles_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
testfiles = Button(label='test files:', width=110)
testfiles.on_click(C.testfiles_callback)
testfiles_string = TextInput(value=M.state['testfiles'], title="", disabled=False)
testfiles_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
wantedwords = Button(label='wanted words:', width=110)
wantedwords.on_click(C.wantedwords_callback)
wantedwords_string = TextInput(value=M.state['wantedwords'], title="", disabled=False)
wantedwords_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
labeltypes = Button(label='label types:', width=110)
labeltypes_string = TextInput(value=M.state['labeltypes'], title="", disabled=False)
labeltypes_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
prevalences = Button(label='prevalences:', width=110)
prevalences.on_click(C.prevalences_callback)
prevalences_string = TextInput(value=M.state['prevalences'], title="", disabled=False)
prevalences_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
copy = Button(label='copy')
copy.on_click(C.copy_callback)
labelsounds = Button(label='label sounds')
labelsounds.on_click(lambda: C.wizard_callback(labelsounds))
makepredictions = Button(label='make predictions')
makepredictions.on_click(lambda: C.wizard_callback(makepredictions))
fixfalsepositives = Button(label='fix false positives')
fixfalsepositives.on_click(lambda: C.wizard_callback(fixfalsepositives))
fixfalsenegatives = Button(label='fix false negatives')
fixfalsenegatives.on_click(lambda: C.wizard_callback(fixfalsenegatives))
generalize = Button(label='test generalization')
generalize.on_click(lambda: C.wizard_callback(generalize))
tunehyperparameters = Button(label='tune h-parameters')
tunehyperparameters.on_click(lambda: C.wizard_callback(tunehyperparameters))
findnovellabels = Button(label='find novel labels')
findnovellabels.on_click(lambda: C.wizard_callback(findnovellabels))
examineerrors = Button(label='examine errors')
examineerrors.on_click(lambda: C.wizard_callback(examineerrors))
testdensely = Button(label='test densely')
testdensely .on_click(lambda: C.wizard_callback(testdensely))
doit = Button(label='do it!', disabled=True)
doit.on_click(C.doit_callback)
time_sigma_string = TextInput(value=M.state['time_sigma'], \
title="time σ", \
disabled=False)
time_sigma_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
time_smooth_ms_string = TextInput(value=M.state['time_smooth_ms'], \
title="time smooth", \
disabled=False)
time_smooth_ms_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
frequency_n_ms_string = TextInput(value=M.state['frequency_n_ms'], \
title="freq N (msec)", \
disabled=False)
frequency_n_ms_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
frequency_nw_string = TextInput(value=M.state['frequency_nw'], \
title="freq NW", \
disabled=False)
frequency_nw_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
frequency_p_string = TextInput(value=M.state['frequency_p'], \
title="freq ρ", \
disabled=False)
frequency_p_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
frequency_smooth_ms_string = TextInput(value=M.state['frequency_smooth_ms'], \
title="freq smooth", \
disabled=False)
frequency_smooth_ms_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
nsteps_string = TextInput(value=M.state['nsteps'], title="# steps", disabled=False)
nsteps_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
restore_from_string = TextInput(value=M.state['restore_from'], title="restore from", disabled=False)
restore_from_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
save_and_validate_period_string = TextInput(value=M.state['save_and_validate_interval'], \
title="validate period", \
disabled=False)
save_and_validate_period_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
validate_percentage_string = TextInput(value=M.state['validate_percentage'], \
title="validate %", \
disabled=False)
validate_percentage_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
mini_batch_string = TextInput(value=M.state['mini_batch'], \
title="mini-batch", \
disabled=False)
mini_batch_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
kfold_string = TextInput(value=M.state['kfold'], title="k-fold", disabled=False)
kfold_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
activations_equalize_ratio_string = TextInput(value=M.state['activations_equalize_ratio'], \
title="equalize ratio", \
disabled=False)
activations_equalize_ratio_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
activations_max_samples_string = TextInput(value=M.state['activations_max_samples'], \
title="max samples", \
disabled=False)
activations_max_samples_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
pca_fraction_variance_to_retain_string = TextInput(value=M.state['pca_fraction_variance_to_retain'], \
title="PCA fraction", \
disabled=False)
pca_fraction_variance_to_retain_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
tsne_perplexity_string = TextInput(value=M.state['tsne_perplexity'], \
title="perplexity", \
disabled=False)
tsne_perplexity_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
tsne_exaggeration_string = TextInput(value=M.state['tsne_exaggeration'], \
title="exaggeration", \
disabled=False)
tsne_exaggeration_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
umap_neighbors_string = TextInput(value=M.state['umap_neighbors'], \
title="neighbors", \
disabled=False)
umap_neighbors_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
umap_distance_string = TextInput(value=M.state['umap_distance'], \
title="distance", \
disabled=False)
umap_distance_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
precision_recall_ratios_string = TextInput(value=M.state['precision_recall_ratios'], \
title="P/Rs", \
disabled=False)
precision_recall_ratios_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
context_ms_string = TextInput(value=M.state['context_ms'], \
title="context (msec)", \
disabled=False)
context_ms_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
shiftby_ms_string = TextInput(value=M.state['shiftby_ms'], \
title="shift by (msec)", \
disabled=False)
shiftby_ms_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
representation = Select(title="representation", height=50, \
value=M.state['representation'], \
options=["waveform", "spectrogram", "mel-cepstrum"])
representation.on_change('value', lambda a,o,n: C.generic_parameters_callback(''))
window_ms_string = TextInput(value=M.state['window_ms'], \
title="window (msec)", \
disabled=False)
window_ms_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
stride_ms_string = TextInput(value=M.state['stride_ms'], \
title="stride (msec)", \
disabled=False)
stride_ms_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
mel_dct_string = TextInput(value=M.state['mel&dct'], \
title="Mel & DCT", \
disabled=False)
mel_dct_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
optimizer = Select(title="optimizer", height=50, \
value=M.state['optimizer'], \
options=[("sgd","SGD"), ("adam","Adam"), ("adagrad","AdaGrad"), \
("rmsprop","RMSProp")])
optimizer.on_change('value', lambda a,o,n: C.generic_parameters_callback(''))
learning_rate_string = TextInput(value=M.state['learning_rate'], \
title="learning rate", \
disabled=False)
learning_rate_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
model_parameters = OrderedDict()
for parameter in M.model_parameters:
if parameter[2]=='':
thisparameter = TextInput(value=M.state[parameter[0]], \
title=parameter[1], \
disabled=False, width=94)
thisparameter.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
else:
thisparameter = Select(value=M.state[parameter[0]], \
title=parameter[1], \
options=parameter[2], \
height=50, width=94)
model_parameters[parameter[0]] = thisparameter
configuration_contents = TextAreaInput(rows=49-3*np.ceil(len(model_parameters)/6).astype(np.int),
max_length=50000, \
disabled=True, css_classes=['fixedwidth'])
if M.configuration_file:
with open(M.configuration_file, 'r') as fid:
configuration_contents.value = fid.read()
cluster_algorithm = Select(title="cluster", height=50, \
value=M.state['cluster_algorithm'], \
options=["PCA 2D", "PCA 3D", \
"tSNE 2D", "tSNE 3D", \
"UMAP 2D", "UMAP 3D"])
cluster_algorithm.on_change('value', lambda a,o,n: C.generic_parameters_callback(''))
cluster_these_layers = MultiSelect(title='layers', \
value=M.state['cluster_these_layers'], \
options=[],
height=108)
cluster_these_layers.on_change('value', lambda a,o,n: C.generic_parameters_callback(''))
cluster_these_layers_update()
replicates_string = TextInput(value=M.state['replicates'], \
title="replicates", \
disabled=False)
replicates_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
batch_seed_string = TextInput(value=M.state['batch_seed'], \
title="batch seed", \
disabled=False)
batch_seed_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
weights_seed_string = TextInput(value=M.state['weights_seed'], \
title="weights seed", \
disabled=False)
weights_seed_string.on_change('value', lambda a,o,n: C.generic_parameters_callback(n))
file_dialog_string = TextInput(disabled=False)
file_dialog_string.on_change("value", C.file_dialog_path_callback)
file_dialog_string.value = M.state['file_dialog_string']
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)),'..','..','README.md'), 'r', encoding='utf-8') as fid:
contents = fid.read()
html = markdown.markdown(contents, extensions=['tables','toc'])
readme_contents = Div(text=html, style={'overflow':'scroll','width':'600px','height':'1397px'})
wordcounts = Div(text="")
wordcounts_update()
wizard_buttons = set([
labelsounds,
makepredictions,
fixfalsepositives,
fixfalsenegatives,
generalize,
tunehyperparameters,
findnovellabels,
examineerrors,
testdensely])
action_buttons = set([
detect,
train,
leaveoneout,
leaveallout,
xvalidate,
mistakes,
activations,
cluster,
visualize,
accuracy,
freeze,
classify,
ethogram,
misses,
compare,
congruence])
parameter_buttons = set([
logs,
model,
wavtfcsvfiles,
groundtruth,
validationfiles,
testfiles,
wantedwords,
labeltypes,
prevalences])
parameter_textinputs = set([
logs_folder,
model_file,
wavtfcsvfiles_string,
groundtruth_folder,
validationfiles_string,
testfiles_string,
wantedwords_string,
labeltypes_string,
prevalences_string,
time_sigma_string,
time_smooth_ms_string,
frequency_n_ms_string,
frequency_nw_string,
frequency_p_string,
frequency_smooth_ms_string,
nsteps_string,
restore_from_string,
save_and_validate_period_string,
validate_percentage_string,
mini_batch_string,
kfold_string,
activations_equalize_ratio_string,
activations_max_samples_string,
pca_fraction_variance_to_retain_string,
tsne_perplexity_string,
tsne_exaggeration_string,
umap_neighbors_string,
umap_distance_string,
cluster_algorithm,
cluster_these_layers,
precision_recall_ratios_string,
replicates_string,
batch_seed_string,
weights_seed_string,
context_ms_string,
shiftby_ms_string,
representation,
window_ms_string,
stride_ms_string,
mel_dct_string,
optimizer,
learning_rate_string] +
list(model_parameters.values()))
wizard2actions = {
labelsounds: [detect,train,activations,cluster,visualize],
makepredictions: [train, accuracy, freeze, classify, ethogram],
fixfalsepositives: [activations, cluster, visualize],
fixfalsenegatives: [detect, misses, activations, cluster, visualize],
generalize: [leaveoneout, leaveallout, accuracy],
tunehyperparameters: [xvalidate, accuracy, compare],
findnovellabels: [detect, train, activations, cluster, visualize],
examineerrors: [detect, mistakes, activations, cluster, visualize],
testdensely: [detect, activations, cluster, visualize, classify, ethogram, congruence],
None: action_buttons }
action2parameterbuttons = {
detect: [wavtfcsvfiles],
train: [logs, groundtruth, wantedwords, testfiles, labeltypes],
leaveoneout: [logs, groundtruth, validationfiles, testfiles, wantedwords, labeltypes],
leaveallout: [logs, groundtruth, validationfiles, testfiles, wantedwords, labeltypes],
xvalidate: [logs, groundtruth, testfiles, wantedwords, labeltypes],
mistakes: [groundtruth],
activations: [logs, model, groundtruth, wantedwords, labeltypes],
cluster: [groundtruth],
visualize: [groundtruth],
accuracy: [logs],
freeze: [logs, model],
classify: [logs, model, wavtfcsvfiles, wantedwords, prevalences],
ethogram: [model, wavtfcsvfiles],
misses: [wavtfcsvfiles],
compare: [logs],
congruence: [groundtruth, validationfiles, testfiles],
None: parameter_buttons }
action2parametertextinputs = {
detect: [wavtfcsvfiles_string, time_sigma_string, time_smooth_ms_string, frequency_n_ms_string, frequency_nw_string, frequency_p_string, frequency_smooth_ms_string],
train: [context_ms_string, shiftby_ms_string, representation, window_ms_string, stride_ms_string, mel_dct_string, optimizer, learning_rate_string, replicates_string, batch_seed_string, weights_seed_string, logs_folder, groundtruth_folder, testfiles_string, wantedwords_string, labeltypes_string, nsteps_string, restore_from_string, save_and_validate_period_string, validate_percentage_string, mini_batch_string] + list(model_parameters.values()),
leaveoneout: [context_ms_string, shiftby_ms_string, representation, window_ms_string, stride_ms_string, mel_dct_string, optimizer, learning_rate_string, batch_seed_string, weights_seed_string, logs_folder, groundtruth_folder, validationfiles_string, testfiles_string, wantedwords_string, labeltypes_string, nsteps_string, restore_from_string, save_and_validate_period_string, mini_batch_string] + list(model_parameters.values()),
leaveallout: [context_ms_string, shiftby_ms_string, representation, window_ms_string, stride_ms_string, mel_dct_string, optimizer, learning_rate_string, batch_seed_string, weights_seed_string, logs_folder, groundtruth_folder, validationfiles_string, testfiles_string, wantedwords_string, labeltypes_string, nsteps_string, restore_from_string, save_and_validate_period_string, mini_batch_string] + list(model_parameters.values()),
xvalidate: [context_ms_string, shiftby_ms_string, representation, window_ms_string, stride_ms_string, mel_dct_string, optimizer, learning_rate_string, batch_seed_string, weights_seed_string, logs_folder, groundtruth_folder, testfiles_string, wantedwords_string, labeltypes_string, nsteps_string, restore_from_string, save_and_validate_period_string, mini_batch_string, kfold_string] + list(model_parameters.values()),
mistakes: [groundtruth_folder],
activations: [context_ms_string, shiftby_ms_string, representation, window_ms_string, stride_ms_string, mel_dct_string, logs_folder, model_file, groundtruth_folder, wantedwords_string, labeltypes_string, activations_equalize_ratio_string, activations_max_samples_string, mini_batch_string] + list(model_parameters.values()),
cluster: [groundtruth_folder, cluster_algorithm, cluster_these_layers, pca_fraction_variance_to_retain_string, tsne_perplexity_string, tsne_exaggeration_string, umap_neighbors_string, umap_distance_string],
visualize: [groundtruth_folder],
accuracy: [logs_folder, precision_recall_ratios_string],
freeze: [context_ms_string, representation, window_ms_string, stride_ms_string, mel_dct_string, logs_folder, model_file] + list(model_parameters.values()),
classify: [context_ms_string, shiftby_ms_string, representation, stride_ms_string, logs_folder, model_file, wavtfcsvfiles_string, wantedwords_string, prevalences_string] + list(model_parameters.values()),
ethogram: [model_file, wavtfcsvfiles_string],
misses: [wavtfcsvfiles_string],
compare: [logs_folder],
congruence: [groundtruth_folder, validationfiles_string, testfiles_string],
None: parameter_textinputs }