Taranosaurus commited on
Commit
96eea2a
·
1 Parent(s): 54d4ac0

Small efficiency changes on the classification returns and extra info

Browse files

No need to do two loops which do basically the same thing to `classifications_input` and `classifications_summary`

Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -20,12 +20,9 @@ def do_the_thing(input, hypothesis, labels):
20
  hypothesis= "This example is {}."
21
  summarisation = summary(input, truncation=True)[0]['summary_text']
22
  zsc_results = oracle(sequences=[input, summarisation], candidate_labels=labels, multi_label=False, batch_size=2, hypothesis_template=hypothesis)
23
- classifications_input = {}
24
  for i in range(len(labels)):
25
  classifications_input.update({zsc_results[0]['labels'][i]: zsc_results[0]['scores'][i]})
26
- i+=1
27
- classifications_summary = {}
28
- for i in range(len(labels)):
29
  classifications_summary.update({zsc_results[1]['labels'][i]: zsc_results[1]['scores'][i]})
30
  i+=1
31
  return [summarisation, classifications_input, classifications_summary]
@@ -36,7 +33,7 @@ with gr.Blocks() as frontend:
36
  btn_submit = gr.Button(value="Summarise and Classify")
37
  with gr.Row():
38
  with gr.Column():
39
- input_labels = gr.Dropdown(label="Classification Labels", choices=labels, multiselect=True, value=selected_labels, interactive=True, allow_custom_value=True, info="Labels to classify the original text and summary")
40
  input_hypothesis = gr.Textbox(label="Hypothesis Template", info="This must include the {} format syntax. Blank and invalid inputs get defaulted to the palceholder text.", value="This git commit relates to {} changes.", placeholder="This example is {}.")
41
  with gr.Column():
42
  output_summary_text = gr.TextArea(label="Summary of Notes")
 
20
  hypothesis= "This example is {}."
21
  summarisation = summary(input, truncation=True)[0]['summary_text']
22
  zsc_results = oracle(sequences=[input, summarisation], candidate_labels=labels, multi_label=False, batch_size=2, hypothesis_template=hypothesis)
23
+ classifications_summary, classifications_input = {}, {}
24
  for i in range(len(labels)):
25
  classifications_input.update({zsc_results[0]['labels'][i]: zsc_results[0]['scores'][i]})
 
 
 
26
  classifications_summary.update({zsc_results[1]['labels'][i]: zsc_results[1]['scores'][i]})
27
  i+=1
28
  return [summarisation, classifications_input, classifications_summary]
 
33
  btn_submit = gr.Button(value="Summarise and Classify")
34
  with gr.Row():
35
  with gr.Column():
36
+ input_labels = gr.Dropdown(label="Classification Labels", choices=labels, multiselect=True, value=selected_labels, interactive=True, allow_custom_value=True, info="Labels to classify the original text and summary. Select more or add your own.")
37
  input_hypothesis = gr.Textbox(label="Hypothesis Template", info="This must include the {} format syntax. Blank and invalid inputs get defaulted to the palceholder text.", value="This git commit relates to {} changes.", placeholder="This example is {}.")
38
  with gr.Column():
39
  output_summary_text = gr.TextArea(label="Summary of Notes")