andrewzamp commited on
Commit
b503865
·
1 Parent(s): f147a22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -21
app.py CHANGED
@@ -97,30 +97,17 @@ def make_prediction(image, taxonomic_level):
97
 
98
  return output_text
99
 
100
- # Define a function to update the welcome message based on the logged-in user
101
- def update_message(request: gr.Request):
102
- return f"Welcome to the demo, Dr. {request.username}!"
103
-
104
- # Define the Gradio interface
105
  with gr.Blocks() as demo:
106
- # Add a Markdown component for displaying the welcome message
107
- welcome_message = gr.Markdown()
 
 
108
 
109
- # Load the update_message function to display the welcome message
110
- demo.load(update_message, None, welcome_message)
111
-
112
- # Define the main interface for predictions
113
- interface = gr.Interface(
114
- fn=make_prediction, # Function to be called for predictions
115
- inputs=[gr.Image(type="pil"), # Input type: Image (PIL format)
116
- gr.Dropdown(choices=taxonomic_levels, label="Taxonomic level", value="species")], # Use 'value' instead of 'default'
117
- outputs="html", # Output type: HTML for formatting
118
- title="Amazon arboreal species classification",
119
- description="Upload an image and select the taxonomic level to classify the species."
120
- )
121
 
122
- # Add the prediction interface to the main demo
123
- interface.render()
124
 
125
  # Launch the Gradio interface with authentication for the specified users
126
  demo.launch(auth=[
 
97
 
98
  return output_text
99
 
 
 
 
 
 
100
  with gr.Blocks() as demo:
101
+ # Define the input and output components for predictions
102
+ image_input = gr.Image(type="pil", label="Upload Image") # Input type: Image (PIL format)
103
+ taxonomic_level_input = gr.Dropdown(choices=taxonomic_levels, label="Taxonomic level", value="species") # Dropdown for taxonomic level
104
+ output_html = gr.HTML(label="Prediction Result") # Output type: HTML for formatting
105
 
106
+ # Create the prediction button
107
+ predict_button = gr.Button("Make Prediction")
 
 
 
 
 
 
 
 
 
 
108
 
109
+ # Define what happens when the button is clicked
110
+ predict_button.click(make_prediction, inputs=[image_input, taxonomic_level_input], outputs=output_html)
111
 
112
  # Launch the Gradio interface with authentication for the specified users
113
  demo.launch(auth=[