Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,7 @@ def return_image(task, label):
|
|
| 16 |
floraveg_url = f"https://floraveg.eu/habitat/overview/{label}"
|
| 17 |
floraveg_tag = "https://files.ibot.cas.cz/cevs/images/syntaxa/thumbs/"
|
| 18 |
elif task == "masking":
|
| 19 |
-
floraveg_url = f"https://floraveg.eu/taxon/overview/{label
|
| 20 |
floraveg_tag = "https://files.ibot.cas.cz/cevs/images/taxa/large/"
|
| 21 |
response = requests.get(floraveg_url)
|
| 22 |
if response.status_code == 200:
|
|
@@ -97,7 +97,7 @@ def masking(text, k):
|
|
| 97 |
best_position = i
|
| 98 |
best_sentence = sentence
|
| 99 |
|
| 100 |
-
best_predictions.append(best_prediction)
|
| 101 |
text_split.insert(best_position, best_prediction)
|
| 102 |
|
| 103 |
best_positions = [text_split.index(prediction) for prediction in best_predictions]
|
|
@@ -108,17 +108,17 @@ def masking(text, k):
|
|
| 108 |
)
|
| 109 |
|
| 110 |
if k == 1:
|
| 111 |
-
text = f"The most likely missing species is {best_predictions
|
| 112 |
elif k == 2:
|
| 113 |
-
text = f"The most likely missing species are {
|
| 114 |
else:
|
| 115 |
-
text = f"The most likely missing species are {', '.join(best_predictions[:-1]
|
| 116 |
text += f"\nThe completed vegetation plot is thus '{best_sentence}'."
|
| 117 |
image = return_image("masking", best_predictions[0])
|
| 118 |
if image is not None:
|
| 119 |
-
text += f"\nBelow is an image of the first missing species (i.e., {best_predictions
|
| 120 |
else:
|
| 121 |
-
text += f"\nNo image found for the first missing species (i.e., {best_predictions
|
| 122 |
image = gr.Image("https://img.freepik.com/premium-vector/file-folder-mascot-character-design-vector_166742-4413.jpg")
|
| 123 |
return text, image
|
| 124 |
|
|
|
|
| 16 |
floraveg_url = f"https://floraveg.eu/habitat/overview/{label}"
|
| 17 |
floraveg_tag = "https://files.ibot.cas.cz/cevs/images/syntaxa/thumbs/"
|
| 18 |
elif task == "masking":
|
| 19 |
+
floraveg_url = f"https://floraveg.eu/taxon/overview/{label}"
|
| 20 |
floraveg_tag = "https://files.ibot.cas.cz/cevs/images/taxa/large/"
|
| 21 |
response = requests.get(floraveg_url)
|
| 22 |
if response.status_code == 200:
|
|
|
|
| 97 |
best_position = i
|
| 98 |
best_sentence = sentence
|
| 99 |
|
| 100 |
+
best_predictions.append(best_prediction.capitalize())
|
| 101 |
text_split.insert(best_position, best_prediction)
|
| 102 |
|
| 103 |
best_positions = [text_split.index(prediction) for prediction in best_predictions]
|
|
|
|
| 108 |
)
|
| 109 |
|
| 110 |
if k == 1:
|
| 111 |
+
text = f"The most likely missing species is {best_predictions} (position {best_positions[0]})."
|
| 112 |
elif k == 2:
|
| 113 |
+
text = f"The most likely missing species are {best_predictions[0]} and {best_predictions[1]} (positions {best_positions[0]} and {best_positions[1]})."
|
| 114 |
else:
|
| 115 |
+
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]})."
|
| 116 |
text += f"\nThe completed vegetation plot is thus '{best_sentence}'."
|
| 117 |
image = return_image("masking", best_predictions[0])
|
| 118 |
if image is not None:
|
| 119 |
+
text += f"\nBelow is an image of the first missing species (i.e., {best_predictions}) taken from the website FloraVEG."
|
| 120 |
else:
|
| 121 |
+
text += f"\nNo image found for the first missing species (i.e., {best_predictions})."
|
| 122 |
image = gr.Image("https://img.freepik.com/premium-vector/file-folder-mascot-character-design-vector_166742-4413.jpg")
|
| 123 |
return text, image
|
| 124 |
|