CesarLeblanc commited on
Commit
736419a
·
1 Parent(s): 4e59324
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -75,7 +75,8 @@ def classification(text, k):
75
  else:
76
  text = f"This vegetation plot belongs to the habitats {', '.join(habitat_labels[:-1])} and {habitat_labels[-1]}."
77
  habitat_name = eunis_habitats[eunis_habitats['EUNIS 2020 code'] == habitat_labels[0]]['EUNIS-2021 habitat name'].values[0]
78
- text += f"\nThe most likely habitat is {habitat_name} (see image below)."
 
79
  image_output = return_habitat_image(habitat_labels[0])
80
  return text, image_output
81
 
@@ -85,7 +86,6 @@ def masking(text, k):
85
 
86
  best_predictions = []
87
  best_positions = []
88
- best_sentences = []
89
 
90
  for _ in range(k):
91
  max_score = 0
@@ -116,14 +116,14 @@ def masking(text, k):
116
 
117
  best_predictions.append(best_prediction)
118
  best_positions.append(best_position)
119
- best_sentences.append(best_sentence)
120
  text_split.insert(best_position, best_prediction)
121
  if k == 1:
122
  text = f"The most likely missing species is {best_predictions[0]} (position {best_positions[0]})."
123
  else:
124
  text = f"The most likely missing species are {', '.join(best_predictions[:-1])} and {best_predictions[-1]} (positions {', '.join(map(str, best_positions[:-1]))} and {best_positions[-1]})."
125
- text += f"\nThe new vegetation plot is {best_sentences[-1]}. (see image of the most likely species below)."
126
- image = return_species_image(best_prediction)
 
127
  return text, image
128
 
129
  with gr.Blocks() as demo:
@@ -155,7 +155,7 @@ with gr.Blocks() as demo:
155
  gr.Markdown("""<h5 style="text-align: center;">An example of input</h5>""")
156
  gr.Examples([["vaccinium myrtillus, dryopteris dilatata, molinia caerulea", 1]], [species_masking, k_masking], [text_masking, image_masking], masking, True)
157
 
158
- button_classification.click(classification, inputs=[species_classification, k_classification], outputs=[textclassification, image_classification])
159
  button_masking.click(masking, inputs=[species_masking, k_masking], outputs=[text_masking, image_masking])
160
 
161
  demo.launch()
 
75
  else:
76
  text = f"This vegetation plot belongs to the habitats {', '.join(habitat_labels[:-1])} and {habitat_labels[-1]}."
77
  habitat_name = eunis_habitats[eunis_habitats['EUNIS 2020 code'] == habitat_labels[0]]['EUNIS-2021 habitat name'].values[0]
78
+ text += f"\nThe most likely habitat is '{habitat_name}'."
79
+ text += f"\n See image of the most likely habitat, {habitat_labels[0]}, below)."
80
  image_output = return_habitat_image(habitat_labels[0])
81
  return text, image_output
82
 
 
86
 
87
  best_predictions = []
88
  best_positions = []
 
89
 
90
  for _ in range(k):
91
  max_score = 0
 
116
 
117
  best_predictions.append(best_prediction)
118
  best_positions.append(best_position)
 
119
  text_split.insert(best_position, best_prediction)
120
  if k == 1:
121
  text = f"The most likely missing species is {best_predictions[0]} (position {best_positions[0]})."
122
  else:
123
  text = f"The most likely missing species are {', '.join(best_predictions[:-1])} and {best_predictions[-1]} (positions {', '.join(map(str, best_positions[:-1]))} and {best_positions[-1]})."
124
+ text += f"\nThe new vegetation plot is {best_sentence}."
125
+ text += f"\n See image of the most likely species, {best_predictions[0]}, below)."
126
+ image = return_species_image(best_prediction[0])
127
  return text, image
128
 
129
  with gr.Blocks() as demo:
 
155
  gr.Markdown("""<h5 style="text-align: center;">An example of input</h5>""")
156
  gr.Examples([["vaccinium myrtillus, dryopteris dilatata, molinia caerulea", 1]], [species_masking, k_masking], [text_masking, image_masking], masking, True)
157
 
158
+ button_classification.click(classification, inputs=[species_classification, k_classification], outputs=[text_classification, image_classification])
159
  button_masking.click(masking, inputs=[species_masking, k_masking], outputs=[text_masking, image_masking])
160
 
161
  demo.launch()