Update app.py
Browse files47 unmodified lines48495051525354555657585960616263646566676869707145 unmodified lines11711811912012112212312412512647 unmodified lines# checking domain bounds inputstry:start = int(domain_bounds['start'][0])end = int(domain_bounds['end'][0])except ValueError:raise gr.Error("Error: Start and end indices must be integers.")return None, None, Noneif start >= end:raise gr.Error("Start index must be smaller than end index.")return None, None, Noneif start == 0 and end != 0:raise gr.Error("Indexing starts at 1. Please enter valid domain bounds.")return None, None, Noneif start == 0 or end == 0:raise gr.Error("Domain bounds cannot be zero. Please enter valid domain bounds.")return None, None, Noneif start > len(sequence) or end > len(sequence):raise gr.Error("Domain bounds exceed sequence length.")return None, None, None# checking n inputsif n == None:raise gr.Error("Choose Top N Tokens from the dropdown menu.")45 unmodified linesnormalized_logits_array = F.softmax(torch.tensor(all_logits_array), dim=-1).numpy()transposed_logits_array = normalized_logits_array.T# Plotting the heatmapdomain_len = end - startif domain_len > 100:step_size = 50elif domain_len < 10:step_size = 1else:47 unmodified lines48495051525354555657585960616263646566676869707145 unmodified lines11711811912012112212312412512612712847 unmodified lines# checking domain bounds inputstry:start = int(domain_bounds['start'][0])end = int(domain_bounds['end'][0])except ValueError:raise gr.Error("Error: Start and end indices must be integers.")return None, None, Noneif start >= end:raise gr.Error("Start index must be smaller than end index.")return None, None, Noneif start == 0 and end != 0:raise gr.Error("Indexing starts at 1. Please enter valid domain bounds.")return None, None, Noneif start <= 0 or end <= 0:raise gr.Error("Domain bounds must be positive integers. Please enter valid domain bounds.")return None, None, Noneif start > len(sequence) or end > len(sequence):raise gr.Error("Domain bounds exceed sequence length.")return None, None, None# checking n inputsif n == None:raise gr.Error("Choose Top N Tokens from the dropdown menu.")45 unmodified linesnormalized_logits_array = F.softmax(torch.tensor(all_logits_array), dim=-1).numpy()transposed_logits_array = normalized_logits_array.T# Plotting the heatmapdomain_len = end - startif 500 > domain_len > 100:step_size = 50elif 500 <= domain_len:step_size = 100elif domain_len < 10:step_size = 1else:
app.py+10-8