Spaces:
Running
Running
CesarLeblanc
commited on
Commit
•
763f5b7
1
Parent(s):
9795f93
app.py
CHANGED
@@ -71,9 +71,9 @@ def classification(text, k):
|
|
71 |
result = classification_model(text)
|
72 |
habitat_labels = [res['label'] for res in result[0][:k]]
|
73 |
if k == 1:
|
74 |
-
text = f"This vegetation plot belongs to the habitat {habitat_labels[0]}."
|
75 |
else:
|
76 |
-
text = f"This vegetation plot belongs to the
|
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"\nSee an image of this habitat (i.e., {habitat_labels[0]}) below."
|
@@ -121,7 +121,7 @@ def masking(text, k):
|
|
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
|
125 |
text += f"\nSee an image of the most likely species (i.e., {best_predictions[0]}) below."
|
126 |
image = return_species_image(best_prediction[0])
|
127 |
return text, image
|
@@ -141,7 +141,7 @@ with gr.Blocks() as demo:
|
|
141 |
image_classification = gr.Image()
|
142 |
button_classification = gr.Button("Classify")
|
143 |
gr.Markdown("""<h5 style="text-align: center;">An example of input</h5>""")
|
144 |
-
gr.Examples([["
|
145 |
|
146 |
with gr.Tab("Missing species finding"):
|
147 |
gr.Markdown("""<h3 style="text-align: center;">Finding the missing species!</h3>""")
|
@@ -154,7 +154,7 @@ with gr.Blocks() as demo:
|
|
154 |
image_masking = gr.Image()
|
155 |
button_masking = gr.Button("Find")
|
156 |
gr.Markdown("""<h5 style="text-align: center;">An example of input</h5>""")
|
157 |
-
gr.Examples([["
|
158 |
|
159 |
button_classification.click(classification, inputs=[species_classification, k_classification], outputs=[text_classification, image_classification])
|
160 |
button_masking.click(masking, inputs=[species_masking, k_masking], outputs=[text_masking, image_masking])
|
|
|
71 |
result = classification_model(text)
|
72 |
habitat_labels = [res['label'] for res in result[0][:k]]
|
73 |
if k == 1:
|
74 |
+
text = f"This vegetation plot probably belongs to the habitat {habitat_labels[0]}."
|
75 |
else:
|
76 |
+
text = f"This vegetation plot probably belongs to the habitat {', '.join(habitat_labels[:-1])} or {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"\nSee an image of this habitat (i.e., {habitat_labels[0]}) below."
|
|
|
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 completed vegetation plot is '{best_sentence}'."
|
125 |
text += f"\nSee an image of the most likely species (i.e., {best_predictions[0]}) below."
|
126 |
image = return_species_image(best_prediction[0])
|
127 |
return text, image
|
|
|
141 |
image_classification = gr.Image()
|
142 |
button_classification = gr.Button("Classify")
|
143 |
gr.Markdown("""<h5 style="text-align: center;">An example of input</h5>""")
|
144 |
+
gr.Examples([["phragmites australis, lemna minor, typha latifolia", 3]], [species_classification, k_classification], [text_classification, image_classification], classification, True)
|
145 |
|
146 |
with gr.Tab("Missing species finding"):
|
147 |
gr.Markdown("""<h3 style="text-align: center;">Finding the missing species!</h3>""")
|
|
|
154 |
image_masking = gr.Image()
|
155 |
button_masking = gr.Button("Find")
|
156 |
gr.Markdown("""<h5 style="text-align: center;">An example of input</h5>""")
|
157 |
+
gr.Examples([["calamagrostis arenaria, medicago marina, pancratium maritimum, thinopyrum junceum", 1]], [species_masking, k_masking], [text_masking, image_masking], masking, True)
|
158 |
|
159 |
button_classification.click(classification, inputs=[species_classification, k_classification], outputs=[text_classification, image_classification])
|
160 |
button_masking.click(masking, inputs=[species_masking, k_masking], outputs=[text_masking, image_masking])
|