Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,8 @@ masking_model = pipeline("fill-mask", model="models/fill_mask_model", tokenizer=
|
|
| 10 |
|
| 11 |
eunis_habitats = pd.read_excel('data/eunis_habitats.xlsx')
|
| 12 |
|
|
|
|
|
|
|
| 13 |
def return_image(task, label):
|
| 14 |
image = None
|
| 15 |
if task == "classification":
|
|
@@ -61,7 +63,7 @@ def classification(text, k):
|
|
| 61 |
text += "\nBelow is an example of this habitat type taken from the website FloraVEG."
|
| 62 |
else:
|
| 63 |
text += f"\nNo image found for this habitat type."
|
| 64 |
-
image =
|
| 65 |
return text, image
|
| 66 |
|
| 67 |
def masking(text, k):
|
|
@@ -97,15 +99,12 @@ 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]
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
best_sentence = ", ".join(
|
| 107 |
-
[s.strip().capitalize() for s in best_sentence.split(",")]
|
| 108 |
-
)
|
| 109 |
|
| 110 |
if k == 1:
|
| 111 |
text = f"The most likely missing species is {best_predictions} (position {best_positions[0]})."
|
|
@@ -119,7 +118,7 @@ def masking(text, k):
|
|
| 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 =
|
| 123 |
return text, image
|
| 124 |
|
| 125 |
with gr.Blocks() as demo:
|
|
|
|
| 10 |
|
| 11 |
eunis_habitats = pd.read_excel('data/eunis_habitats.xlsx')
|
| 12 |
|
| 13 |
+
image_not_found = gr.Image("https://img.freepik.com/premium-vector/file-folder-mascot-character-design-vector_166742-4413.jpg")
|
| 14 |
+
|
| 15 |
def return_image(task, label):
|
| 16 |
image = None
|
| 17 |
if task == "classification":
|
|
|
|
| 63 |
text += "\nBelow is an example of this habitat type taken from the website FloraVEG."
|
| 64 |
else:
|
| 65 |
text += f"\nNo image found for this habitat type."
|
| 66 |
+
image = image_not_found
|
| 67 |
return text, image
|
| 68 |
|
| 69 |
def masking(text, k):
|
|
|
|
| 99 |
best_position = i
|
| 100 |
best_sentence = sentence
|
| 101 |
|
| 102 |
+
best_predictions.append(best_prediction)
|
| 103 |
text_split.insert(best_position, best_prediction)
|
| 104 |
|
| 105 |
best_positions = [text_split.index(prediction) for prediction in best_predictions]
|
| 106 |
+
best_predictions = [s.strip().capitalize() for s in best_predictions]
|
| 107 |
+
best_sentence = ", ".join([s.strip().capitalize() for s in best_sentence.split(",")])
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
if k == 1:
|
| 110 |
text = f"The most likely missing species is {best_predictions} (position {best_positions[0]})."
|
|
|
|
| 118 |
text += f"\nBelow is an image of the first missing species (i.e., {best_predictions}) taken from the website FloraVEG."
|
| 119 |
else:
|
| 120 |
text += f"\nNo image found for the first missing species (i.e., {best_predictions})."
|
| 121 |
+
image = image_not_found
|
| 122 |
return text, image
|
| 123 |
|
| 124 |
with gr.Blocks() as demo:
|