File size: 1,193 Bytes
a0562b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# https://www.gradio.app/guides/sharing-your-app#mounting-within-another-fast-api-app
import logging
import json
import gradio as gr
log_format = "[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s"
logging.basicConfig(level=logging.INFO, format=log_format)
logger = logging.getLogger()
def api_classification(url):
logger.info(f'api_classification({url})')
data = {"status":"WorkInProgress"}
return json.dumps(data)
with gr.Blocks() as app:
with gr.Tab("BioCLIP API"):
with gr.Row():
with gr.Column():
api_input = gr.Textbox(
placeholder="Image url here",
lines=1,
label="Image url",
show_label=True,
info="Add image url here.",
)
api_classification_btn = gr.Button("API", variant="primary")
with gr.Column():
api_classification_output = gr.JSON() # https://www.gradio.app/docs/gradio/json
api_classification_btn.click(
fn=api_classification,
inputs=[api_input],
outputs=[api_classification_output],
)
app.queue(max_size=20)
app.launch()
|