CesarLeblanc commited on
Commit
7145ecb
1 Parent(s): 51f1003
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -2,11 +2,10 @@ import gradio as gr
2
  from transformers import pipeline
3
  import requests
4
  from bs4 import BeautifulSoup
5
- import random
6
 
7
  # Initialize models
8
- classification_model = pipeline("text-classification", model="plantbert_text_classification_model", tokenizer="plantbert_text_classification_model")
9
- mask_model = pipeline("fill-mask", model="plantbert_fill_mask_model", tokenizer="plantbert_fill_mask_model", top_k=100)
10
 
11
  def return_habitat_image(habitat_label):
12
  floraveg_url = f"https://floraveg.eu/habitat/overview/{habitat_label}"
@@ -143,6 +142,7 @@ def masking(text):
143
  return text, image
144
 
145
  with gr.Blocks() as demo:
 
146
  gr.Markdown("""<h1 style="text-align: center;">Pl@ntBERT</h1>""")
147
 
148
  with gr.Tab("Vegetation plot classification"):
@@ -150,13 +150,13 @@ with gr.Blocks() as demo:
150
  with gr.Row():
151
  with gr.Column():
152
  species = gr.Textbox(lines=2, label="Species", placeholder="Enter a list of comma-separated binomial names here.")
153
- top_k =
154
  with gr.Column():
155
  text_output_1 = gr.Textbox()
156
  text_output_2 = gr.Image()
157
  text_button = gr.Button("Classify")
158
  gr.Markdown("""<h5 style="text-align: center;">An example of input</h5>""")
159
- gr.Examples([["sparganium erectum, calystegia sepium, persicaria amphibia"]], [species], [text_output_1, text_output_2], classification, True)
160
 
161
  with gr.Tab("Missing species finding"):
162
  gr.Markdown("""<h3 style="text-align: center;">Finding the missing species!</h3>""")
@@ -172,4 +172,4 @@ with gr.Blocks() as demo:
172
  text_button.click(classification, inputs=[species], outputs=[text_output_1, text_output_2])
173
  image_button.click(masking, inputs=[species_2], outputs=[image_output_1, image_output_2])
174
 
175
- demo.launch()
 
2
  from transformers import pipeline
3
  import requests
4
  from bs4 import BeautifulSoup
 
5
 
6
  # Initialize models
7
+ classification_model = pipeline("text-classification", model="models/text_classification_model", tokenizer="models/text_classification_model")
8
+ mask_model = pipeline("fill-mask", model="models/fill_mask_model", tokenizer="models/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}"
 
142
  return text, image
143
 
144
  with gr.Blocks() as demo:
145
+
146
  gr.Markdown("""<h1 style="text-align: center;">Pl@ntBERT</h1>""")
147
 
148
  with gr.Tab("Vegetation plot classification"):
 
150
  with gr.Row():
151
  with gr.Column():
152
  species = gr.Textbox(lines=2, label="Species", placeholder="Enter a list of comma-separated binomial names here.")
153
+ top_k = gr.Slider(1, 5, value=1, label="Top-k", info="Choose between 1 and 5.")
154
  with gr.Column():
155
  text_output_1 = gr.Textbox()
156
  text_output_2 = gr.Image()
157
  text_button = gr.Button("Classify")
158
  gr.Markdown("""<h5 style="text-align: center;">An example of input</h5>""")
159
+ gr.Examples([["sparganium erectum, calystegia sepium, persicaria amphibia", 1]], [species, top_k], [text_output_1, text_output_2], classification, True)
160
 
161
  with gr.Tab("Missing species finding"):
162
  gr.Markdown("""<h3 style="text-align: center;">Finding the missing species!</h3>""")
 
172
  text_button.click(classification, inputs=[species], outputs=[text_output_1, text_output_2])
173
  image_button.click(masking, inputs=[species_2], outputs=[image_output_1, image_output_2])
174
 
175
+ demo.launch()