Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,7 +24,7 @@ def return_habitat_image(habitat_label):
|
|
| 24 |
else:
|
| 25 |
image_url = "https://www.salonlfc.com/wp-content/uploads/2018/01/image-not-found-scaled-1150x647.png"
|
| 26 |
#image_url = "https://www.commissionoceanindien.org/wp-content/uploads/2018/07/plantnet.jpg" # While we don't have the rights
|
| 27 |
-
|
| 28 |
image = gr.Image(value=image_url)
|
| 29 |
return image
|
| 30 |
|
|
@@ -42,7 +42,7 @@ def return_species_image(species):
|
|
| 42 |
else:
|
| 43 |
image_url = "https://www.salonlfc.com/wp-content/uploads/2018/01/image-not-found-scaled-1150x647.png"
|
| 44 |
#image_url = "https://www.commissionoceanindien.org/wp-content/uploads/2018/07/plantnet.jpg" # While we don't have the rights
|
| 45 |
-
|
| 46 |
image = gr.Image(value=image_url)
|
| 47 |
return image
|
| 48 |
|
|
@@ -74,8 +74,10 @@ def classification(text, k):
|
|
| 74 |
habitat_labels = [res['label'] for res in result[0][:k]]
|
| 75 |
if k == 1:
|
| 76 |
text = f"This vegetation plot probably belongs to the habitat {habitat_labels[0]}."
|
| 77 |
-
|
| 78 |
text = f"This vegetation plot probably belongs to the habitat {', '.join(habitat_labels[:-1])} or {habitat_labels[-1]}."
|
|
|
|
|
|
|
| 79 |
habitat_name = eunis_habitats[eunis_habitats['EUNIS 2020 code'] == habitat_labels[0]]['EUNIS-2021 habitat name'].values[0]
|
| 80 |
text += f"\nThe most likely habitat is '{habitat_name}'."
|
| 81 |
text += f"\nSee an image of this habitat (i.e., {habitat_labels[0]}) below."
|
|
@@ -122,8 +124,10 @@ def masking(text, k):
|
|
| 122 |
|
| 123 |
if k == 1:
|
| 124 |
text = f"The most likely missing species is {best_predictions[0]} (position {best_positions[0]})."
|
| 125 |
-
|
| 126 |
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]})."
|
|
|
|
|
|
|
| 127 |
text += f"\nThe completed vegetation plot is '{best_sentence}'."
|
| 128 |
text += f"\nSee an image of the most likely species (i.e., {best_predictions[0]}) below."
|
| 129 |
image = return_species_image(best_predictions[0])
|
|
|
|
| 24 |
else:
|
| 25 |
image_url = "https://www.salonlfc.com/wp-content/uploads/2018/01/image-not-found-scaled-1150x647.png"
|
| 26 |
#image_url = "https://www.commissionoceanindien.org/wp-content/uploads/2018/07/plantnet.jpg" # While we don't have the rights
|
| 27 |
+
image_url = "https://files.ibot.cas.cz/cevs/images/syntaxa/large/Rorippo-Phalaridetum_arundinaceae2.jpg" # 800-600 for Q51
|
| 28 |
image = gr.Image(value=image_url)
|
| 29 |
return image
|
| 30 |
|
|
|
|
| 42 |
else:
|
| 43 |
image_url = "https://www.salonlfc.com/wp-content/uploads/2018/01/image-not-found-scaled-1150x647.png"
|
| 44 |
#image_url = "https://www.commissionoceanindien.org/wp-content/uploads/2018/07/plantnet.jpg" # While we don't have the rights
|
| 45 |
+
image_url = "https://files.ibot.cas.cz/cevs/images/taxa/large/Eryngium_maritimum18.jpg" # 1600-1200 for Q51 for eryngium maritimum
|
| 46 |
image = gr.Image(value=image_url)
|
| 47 |
return image
|
| 48 |
|
|
|
|
| 74 |
habitat_labels = [res['label'] for res in result[0][:k]]
|
| 75 |
if k == 1:
|
| 76 |
text = f"This vegetation plot probably belongs to the habitat {habitat_labels[0]}."
|
| 77 |
+
elif k == 2:
|
| 78 |
text = f"This vegetation plot probably belongs to the habitat {', '.join(habitat_labels[:-1])} or {habitat_labels[-1]}."
|
| 79 |
+
else:
|
| 80 |
+
text = f"This vegetation plot probably belongs to the habitat {', '.join(habitat_labels[:-1])}, or {habitat_labels[-1]}."
|
| 81 |
habitat_name = eunis_habitats[eunis_habitats['EUNIS 2020 code'] == habitat_labels[0]]['EUNIS-2021 habitat name'].values[0]
|
| 82 |
text += f"\nThe most likely habitat is '{habitat_name}'."
|
| 83 |
text += f"\nSee an image of this habitat (i.e., {habitat_labels[0]}) below."
|
|
|
|
| 124 |
|
| 125 |
if k == 1:
|
| 126 |
text = f"The most likely missing species is {best_predictions[0]} (position {best_positions[0]})."
|
| 127 |
+
elif k == 2:
|
| 128 |
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]})."
|
| 129 |
+
else:
|
| 130 |
+
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]})."
|
| 131 |
text += f"\nThe completed vegetation plot is '{best_sentence}'."
|
| 132 |
text += f"\nSee an image of the most likely species (i.e., {best_predictions[0]}) below."
|
| 133 |
image = return_species_image(best_predictions[0])
|