Spaces:
Running
Running
Commit
·
8b8c9a9
1
Parent(s):
3d01956
Finished the full example table at the bottom with links and images.
Browse files
app.py
CHANGED
@@ -11,10 +11,52 @@ def predict(image_np, description=None):
|
|
11 |
confidences = {classes[idx]: f'{prob:.04f}' for idx, prob in enumerate(probs)}
|
12 |
return confidences
|
13 |
|
14 |
-
example_metadata = [{'idigbio_specimen': '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
'idigbio_media': 'e3276fdd-ce58-40dc-bf20-8742f7634428',
|
|
|
|
|
16 |
'organism': 'Prunus oocarpa',
|
17 |
-
'intrageneric_group': 'Paleotropical racemose'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
table_header = """**Example Guide**
|
20 |
| Image | Species | Link to iDigBio Specimen Record | Intrageneric group |
|
@@ -22,8 +64,10 @@ table_header = """**Example Guide**
|
|
22 |
"""
|
23 |
|
24 |
table_body = ''
|
|
|
25 |
for example in example_metadata:
|
26 |
-
image_src = f"<image src = 'https://api.idigbio.org/v2/media/{example['idigbio_media']}?size=thumbnail'></image>"
|
|
|
27 |
species = f"*{example['organism']}*"
|
28 |
idigbio_link = f"https://www.idigbio.org/portal/records/{example['idigbio_specimen']}"
|
29 |
intrageneric_group = example['intrageneric_group']
|
@@ -42,11 +86,15 @@ example_list = ["examples/myrtifolia_1c086296-6d1f-4218-a18a-ca2f86c295d0.jpg",
|
|
42 |
"examples/glandulosa_52e06de9-c035-4afc-9fac-c8bee7628d38.jpg",
|
43 |
"examples/pensylvanica_0b13e5eb-73da-4e0e-9b1a-794b737f7716.jpg"]
|
44 |
|
|
|
|
|
|
|
|
|
45 |
demo = gr.Interface(predict,
|
46 |
gr.Image(type="numpy"),
|
47 |
outputs="label",
|
48 |
examples=example_list,
|
49 |
-
description=
|
50 |
title="Image classification of four major lineages in the plum genus",
|
51 |
article=example_table)
|
52 |
|
|
|
11 |
confidences = {classes[idx]: f'{prob:.04f}' for idx, prob in enumerate(probs)}
|
12 |
return confidences
|
13 |
|
14 |
+
example_metadata = [{'idigbio_specimen': '36b28730-fd06-44b4-86a4-77d3be052ef1',
|
15 |
+
'idigbio_media': '1c086296-6d1f-4218-a18a-ca2f86c295d0',
|
16 |
+
'gbif_occurrence': '2425450644',
|
17 |
+
'gbif_media': '60d5b76a58cf28eff526d5c1d7906321',
|
18 |
+
'organism': 'Prunus myrtifolia',
|
19 |
+
'intrageneric_group': 'Neotropical racemose'},
|
20 |
+
{'idigbio_specimen': '0252042a-e14f-4437-99f8-f9c690f1d2a8',
|
21 |
+
'idigbio_media': '104f44c9-63f1-4579-93c2-54c6ddeddeda',
|
22 |
+
'gbif_occurrence': '1056985949',
|
23 |
+
'gbif_media': '65d035ce17427cba5a698850e903cbc8',
|
24 |
+
'organism': 'Prunus oleifolia',
|
25 |
+
'intrageneric_group': 'Neotropical racemose'},
|
26 |
+
{'idigbio_specimen': 'e025ff74-333b-461f-a86e-63d8f4a6bd90',
|
27 |
'idigbio_media': 'e3276fdd-ce58-40dc-bf20-8742f7634428',
|
28 |
+
'gbif_occurrence': '2515155769',
|
29 |
+
'gbif_media': 'd952c78c4b50825dc267d3ab915ea71e',
|
30 |
'organism': 'Prunus oocarpa',
|
31 |
+
'intrageneric_group': 'Paleotropical racemose'},
|
32 |
+
{'idigbio_specimen': '4a991d4d-d6a5-4a4a-9c99-9af948f9e0e0',
|
33 |
+
'idigbio_media': 'e5ac59df-5b18-4c8d-a19b-02131d358855',
|
34 |
+
'gbif_occurrence': '2515160308',
|
35 |
+
'gbif_media': 'fc94119768b9ea1c453cb0ab9887b54a',
|
36 |
+
'organism': 'Prunus pullei',
|
37 |
+
'intrageneric_group': 'Paleotropical racemose'},
|
38 |
+
{'idigbio_specimen': 'e32b4d05-5389-4466-83cb-25e319c2fa9f',
|
39 |
+
'idigbio_media': '0060a57d-e779-4984-913c-95b576daf0d3',
|
40 |
+
'gbif_occurrence': '3865356188',
|
41 |
+
'gbif_media': 'c40a3ebe7ea67f67d33b7405134f3133',
|
42 |
+
'organism': 'Prunus serotina',
|
43 |
+
'intrageneric_group': 'Temperate racemose'},
|
44 |
+
{'idigbio_specimen': '31697ac1-223d-477b-bc8d-0d10ced90ad0',
|
45 |
+
'idigbio_media': 'b9fa9ff9-2e8b-42f5-8728-5b0b5be98490',
|
46 |
+
'gbif_occurrence': '2515504033',
|
47 |
+
'gbif_media': 'be7e108416c0a052311f879642997dee',
|
48 |
+
'organism': 'Prunus grayana',
|
49 |
+
'intrageneric_group': 'Temperate racemose'},
|
50 |
+
{'idigbio_specimen': '80a8afd7-ca01-4df1-a566-305912e25166',
|
51 |
+
'idigbio_media': '52e06de9-c035-4afc-9fac-c8bee7628d38',
|
52 |
+
'organism': 'Prunus glandulosa',
|
53 |
+
'intrageneric_group': 'Solitary/Corymbose'},
|
54 |
+
{'idigbio_specimen': '7835f8bd-d78c-4884-a669-853634296371',
|
55 |
+
'idigbio_media': '0b13e5eb-73da-4e0e-9b1a-794b737f7716',
|
56 |
+
'gbif_occurrence': '2265382670',
|
57 |
+
'gbif_media': '1373276d8fdd232579e7d04c4e64edb1',
|
58 |
+
'organism': 'Prunus pensylvanica',
|
59 |
+
'intrageneric_group': 'Solitary/Corymbose'}]
|
60 |
|
61 |
table_header = """**Example Guide**
|
62 |
| Image | Species | Link to iDigBio Specimen Record | Intrageneric group |
|
|
|
64 |
"""
|
65 |
|
66 |
table_body = ''
|
67 |
+
gbif_scale = 150
|
68 |
for example in example_metadata:
|
69 |
+
#image_src = f"<image src = 'https://api.idigbio.org/v2/media/{example['idigbio_media']}?size=thumbnail'></image>"
|
70 |
+
image_src = f"<image src = 'https://api.gbif.org/v1/image/cache/fit-in/{gbif_scale}x/occurrence/{example['gbif_occurrence']}/media/{example['gbif_media']}'></image>"
|
71 |
species = f"*{example['organism']}*"
|
72 |
idigbio_link = f"https://www.idigbio.org/portal/records/{example['idigbio_specimen']}"
|
73 |
intrageneric_group = example['intrageneric_group']
|
|
|
86 |
"examples/glandulosa_52e06de9-c035-4afc-9fac-c8bee7628d38.jpg",
|
87 |
"examples/pensylvanica_0b13e5eb-73da-4e0e-9b1a-794b737f7716.jpg"]
|
88 |
|
89 |
+
description = """This model can place herbarium sheet images from the genus Prunus into one of four
|
90 |
+
categories that represent key clades within the genus: Solitary/Corymbose, Temperate Racemose, Neotropical
|
91 |
+
Racemose, Paleotropical Racemose."""
|
92 |
+
|
93 |
demo = gr.Interface(predict,
|
94 |
gr.Image(type="numpy"),
|
95 |
outputs="label",
|
96 |
examples=example_list,
|
97 |
+
description=description,
|
98 |
title="Image classification of four major lineages in the plum genus",
|
99 |
article=example_table)
|
100 |
|