CesarLeblanc commited on
Commit
3fcba4f
1 Parent(s): 2af4114

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -5,11 +5,7 @@ from bs4 import BeautifulSoup
5
  import random
6
 
7
  classification_model = pipeline("text-classification", model="plantbert_text_classification_model", tokenizer="plantbert_text_classification_model")
8
- mask_model = pipeline("fill-mask", model="plantbert_fill_mask_model", tokenizer="plantbert_fill_mask_model", top_k=14189)
9
-
10
- def return_text(habitat_label):
11
- text = f"This vegetation plot belongs to the habitat {habitat_label}."
12
- return text
13
 
14
  def return_habitat_image(habitat_label):
15
  floraveg_url = f"https://floraveg.eu/habitat/overview/{habitat_label}"
@@ -23,7 +19,7 @@ def return_habitat_image(habitat_label):
23
  image_url = "https://www.salonlfc.com/wp-content/uploads/2018/01/image-not-found-scaled-1150x647.png"
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"
27
  image = gr.Image(value=image_url)
28
  return image
29
 
@@ -70,9 +66,9 @@ def classification(text):
70
  text = gbif_normalization(text)
71
  result = classification_model(text)
72
  habitat_label = result[0]['label']
73
- formatted_output = return_text(habitat_label)
74
  image_output = return_habitat_image(habitat_label)
75
- return formatted_output, image_output
76
 
77
  def masking(text):
78
  text = gbif_normalization(text)
@@ -141,7 +137,7 @@ def masking(text):
141
  best_position = len(text.split(', '))
142
  best_sentence = sentence
143
 
144
- text = f"The most likely missing species is {best_prediction} at position {best_position}.\nThe new vegetation plot is {best_sentence}."
145
  image = return_species_image(best_prediction)
146
  return text, image
147
 
 
5
  import random
6
 
7
  classification_model = pipeline("text-classification", model="plantbert_text_classification_model", tokenizer="plantbert_text_classification_model")
8
+ mask_model = pipeline("fill-mask", model="plantbert_fill_mask_model", tokenizer="plantbert_fill_mask_model", top_k=100)
 
 
 
 
9
 
10
  def return_habitat_image(habitat_label):
11
  floraveg_url = f"https://floraveg.eu/habitat/overview/{habitat_label}"
 
19
  image_url = "https://www.salonlfc.com/wp-content/uploads/2018/01/image-not-found-scaled-1150x647.png"
20
  else:
21
  image_url = "https://www.salonlfc.com/wp-content/uploads/2018/01/image-not-found-scaled-1150x647.png"
22
+ image_url = "https://www.commissionoceanindien.org/wp-content/uploads/2018/07/plantnet.jpg" # While we don't have the rights
23
  image = gr.Image(value=image_url)
24
  return image
25
 
 
66
  text = gbif_normalization(text)
67
  result = classification_model(text)
68
  habitat_label = result[0]['label']
69
+ text = f"This vegetation plot belongs to the habitat {habitat_label}."
70
  image_output = return_habitat_image(habitat_label)
71
+ return text, image_output
72
 
73
  def masking(text):
74
  text = gbif_normalization(text)
 
137
  best_position = len(text.split(', '))
138
  best_sentence = sentence
139
 
140
+ text = f"The most likely missing species is {best_prediction} (position {best_position}).\nThe new vegetation plot is {best_sentence}."
141
  image = return_species_image(best_prediction)
142
  return text, image
143