CesarLeblanc commited on
Commit
5282aca
1 Parent(s): f5a3585

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -34
app.py CHANGED
@@ -78,39 +78,25 @@ def masking(text, task):
78
  image = return_species_image(new_species)
79
  return text, image
80
 
81
- def plantbert(text, typology, confidence, task):
82
- if task == "classification":
83
- formatted_output, image_output = classification(text, typology, confidence, task)
84
- else:
85
- formatted_output, image_output = masking(text, task)
86
- return formatted_output, image_output
87
-
88
- inputs=[
89
- gr.Textbox(lines=2, label="Species", placeholder="Enter a list of comma-separated binomial names here."),
90
- gr.Dropdown(["EUNIS"], value="EUNIS", label="Typology", info="Will add more typologies later!"),
91
- gr.Slider(0, 100, value=90, label="Confidence", info="Choose the level of confidence for the prediction."),
92
- gr.Radio(["classification", "masking"], value="classification", label="Task", info="Which task to choose?")
93
- ]
94
-
95
- outputs=[
96
- gr.Textbox(lines=2, label="Vegetation Plot Classification Result"),
97
- "image"
98
- ]
99
-
100
- title="Pl@ntBERT"
101
-
102
- description="Vegetation Plot Classification: enter the species found in a vegetation plot and see its EUNIS habitat!"
103
-
104
- examples=[
105
- ["sparganium erectum, calystegia sepium, persicaria amphibia", "EUNIS", 90, "classification"],
106
- ["vaccinium myrtillus, dryopteris dilatata, molinia caerulea", "EUNIS", 90, "masking"]
107
- ]
108
 
109
- io = gr.Interface(fn=plantbert,
110
- inputs=inputs,
111
- outputs=outputs,
112
- title=title,
113
- description=description,
114
- examples=examples)
115
 
116
- io.launch()
 
78
  image = return_species_image(new_species)
79
  return text, image
80
 
81
+ with gr.Blocks() as demo:
82
+ gr.Markdown("Classify vegetation plots or find the missing species.")
83
+ with gr.Tab("Vegetation plot classification"):
84
+ species = gr.Textbox(lines=2, label="Species", placeholder="Enter a list of comma-separated binomial names here.")
85
+ typology = gr.Dropdown(["EUNIS"], value="EUNIS", label="Typology", info="Will add more typologies later!")
86
+ confidence = gr.Slider(0, 100, value=90, label="Confidence", info="Choose the level of confidence for the prediction.")
87
+ task = gr.Radio(["classification", "masking"], value="classification", label="Task", info="Which task to choose?")
88
+ text_output_1 = gr.Textbox()
89
+ text_output_2 = gr.Image()
90
+ text_button = gr.Button("Classify")
91
+ with gr.Tab("Missing species finding"):
92
+ with gr.Row():
93
+ species_2 = gr.Textbox(lines=2, label="Species", placeholder="Enter a list of comma-separated binomial names here.")
94
+ task_2 = gr.Radio(["classification", "masking"], value="classification", label="Task", info="Which task to choose?")
95
+ image_output_1 = gr.Textbox()
96
+ image_output_2 = gr.Image()
97
+ image_button = gr.Button("Find")
 
 
 
 
 
 
 
 
 
 
98
 
99
+ text_button.click(classification, inputs=[species, typology, confidence, task], outputs=[text_output_1, text_output_2]])
100
+ image_button.click(masking, inputs=[species_2, task_2], outputs=[image_output_1, image_output_2]])
 
 
 
 
101
 
102
+ demo.launch()