Brice Vandeputte
commited on
Commit
•
a0562b3
1
Parent(s):
68f918a
json api
Browse files- .gitignore +5 -0
- PYTHON_SETUP.md +16 -0
- app.py +39 -0
- requirements.txt +2 -0
.gitignore
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.idea/
|
2 |
+
flagged/
|
3 |
+
node_modules/
|
4 |
+
venv/
|
5 |
+
myenv/
|
PYTHON_SETUP.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
## Installation (WSL2)
|
3 |
+
|
4 |
+
|
5 |
+
```bash
|
6 |
+
/usr/bin/python3.11 --version
|
7 |
+
Python 3.11.9
|
8 |
+
# cd grBird
|
9 |
+
/usr/bin/python3.11 -m venv ./venv
|
10 |
+
. ./venv/bin/activate
|
11 |
+
# verify version
|
12 |
+
python --version
|
13 |
+
## expect Python 3.11.9
|
14 |
+
python -m pip install --upgrade pip
|
15 |
+
pip install -r ./requirements.txt
|
16 |
+
```
|
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# https://www.gradio.app/guides/sharing-your-app#mounting-within-another-fast-api-app
|
2 |
+
import logging
|
3 |
+
import json
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
log_format = "[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s"
|
7 |
+
logging.basicConfig(level=logging.INFO, format=log_format)
|
8 |
+
logger = logging.getLogger()
|
9 |
+
|
10 |
+
|
11 |
+
def api_classification(url):
|
12 |
+
logger.info(f'api_classification({url})')
|
13 |
+
data = {"status":"WorkInProgress"}
|
14 |
+
return json.dumps(data)
|
15 |
+
|
16 |
+
|
17 |
+
with gr.Blocks() as app:
|
18 |
+
with gr.Tab("BioCLIP API"):
|
19 |
+
with gr.Row():
|
20 |
+
with gr.Column():
|
21 |
+
api_input = gr.Textbox(
|
22 |
+
placeholder="Image url here",
|
23 |
+
lines=1,
|
24 |
+
label="Image url",
|
25 |
+
show_label=True,
|
26 |
+
info="Add image url here.",
|
27 |
+
)
|
28 |
+
api_classification_btn = gr.Button("API", variant="primary")
|
29 |
+
with gr.Column():
|
30 |
+
api_classification_output = gr.JSON() # https://www.gradio.app/docs/gradio/json
|
31 |
+
|
32 |
+
|
33 |
+
api_classification_btn.click(
|
34 |
+
fn=api_classification,
|
35 |
+
inputs=[api_input],
|
36 |
+
outputs=[api_classification_output],
|
37 |
+
)
|
38 |
+
app.queue(max_size=20)
|
39 |
+
app.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
huggingface_hub==0.22.2
|
2 |
+
gradio
|