Skip to content

Commit

Permalink
WeedCOCO category names are now a combination of role and species (#84)
Browse files Browse the repository at this point in the history
* WeedCOCO category names are now a combination of role and species

Fixes #83

Fixes #57

Helps towards specifying categories in importers (#33, #34)

* Pattern in quotes

* Allow space in species name

* Avoid changing timestamp.

* Try tweak pattern. NFI why it's failing to match 'weed: chinee apple'

* use scientific species names

* debugging

* More attempts to make CI happy
  • Loading branch information
jnothman committed Sep 24, 2020
1 parent 6bffc57 commit 47bfc2d
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 26 deletions.
18 changes: 4 additions & 14 deletions search/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class App extends Component {
queryFormat: "or",
URLParams: true,
react: {
and: ["searchbox", "resslider", "agcontextfilter", "rolefilter", "speciesfilter", "grainstextfilter"]
and: ["searchbox", "resslider", "agcontextfilter", "categoryfilter", "grainstextfilter"]
},
...multilistFacetProps
}
Expand Down Expand Up @@ -60,24 +60,14 @@ class App extends Component {
>
<div style={{ position: "fixed", width: "20rem", overflow: "scroll", height: "100%" }}>
<MultiList
componentId="rolefilter"
title="Filter by role"
dataField="annotation__category__role.keyword"
sortBy="asc"
selectAllLabel="All roles"
placeholder="Search Role"
filterLabel="Role"
{...makeProps("rolefilter", true)}
/>
<MultiList
componentId="speciesfilter"
componentId="categoryfilter"
title="Filter by species"
dataField="annotation__category__species.keyword"
dataField="annotation__category__name.keyword"
sortBy="asc"
selectAllLabel="All species"
placeholder="Search Species"
filterLabel="Species"
{...makeProps("speciesfilter", true)}
{...makeProps("categoryfilter", true)}
/>
<MultiList
componentId="agcontextfilter"
Expand Down
4 changes: 3 additions & 1 deletion weedcoco/cwfid_to_json/cwfid_imageinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -17269,6 +17269,7 @@
],
"categories": [
{
"name": "crop: daugus carota",
"common_name": "carrot",
"species": "daugus carota",
"eppo_taxon_code": "DAUCS",
Expand All @@ -17277,6 +17278,7 @@
"id": 0
},
{
"name": "weed: UNSPECIFIED",
"species": "UNSPECIFIED",
"role": "weed",
"id": 1
Expand Down Expand Up @@ -17415,4 +17417,4 @@
"collection_id": 0
}
]
}
}
27 changes: 18 additions & 9 deletions weedcoco/deepweeds_to_json/deepweeds_imageinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -262644,61 +262644,70 @@
"id": 0,
"role": "weed",
"species": "ziziphus mauritiana",
"eppo_taxon_code": "ZIPMA"
"eppo_taxon_code": "ZIPMA",
"name": "weed: ziziphus mauritiana"
},
{
"common_name": "lantana",
"id": 1,
"role": "weed",
"species": "lantana camara",
"eppo_taxon_code": "LANCA"
"eppo_taxon_code": "LANCA",
"name": "weed: lantana camara"
},
{
"common_name": "negative",
"id": 8,
"name": "none",
"role": "na"
},
{
"common_name": "snake weed",
"id": 7,
"role": "weed",
"species": "gutierrezia sarothrae",
"eppo_taxon_code": "GUESA"
"eppo_taxon_code": "GUESA",
"name": "weed: gutierrezia sarothrae"
},
{
"common_name": "siam weed",
"id": 6,
"role": "weed",
"species": "chromolaena odorata",
"eppo_taxon_code": "EUPOD"
"eppo_taxon_code": "EUPOD",
"name": "weed: chromolaena odorata"
},
{
"common_name": "prickly acacia",
"id": 4,
"role": "weed",
"species": "vachellia nilotica",
"eppo_taxon_code": "ACANL"
"eppo_taxon_code": "ACANL",
"name": "weed: vachellia nilotica"
},
{
"common_name": "parthenium",
"id": 3,
"role": "weed",
"species": "parthenium hysterophorus",
"eppo_taxon_code": "PTNHY"
"eppo_taxon_code": "PTNHY",
"name": "weed: parthenium hysterophorus"
},
{
"common_name": "rubber vine",
"id": 5,
"role": "weed",
"species": "cryptostegia grandiflora",
"eppo_taxon_code": "CVRGR"
"eppo_taxon_code": "CVRGR",
"name": "weed: cryptostegia grandiflora"
},
{
"common_name": "parkinsonia",
"id": 2,
"role": "weed",
"species": "parkinsonia aculeata",
"eppo_taxon_code": "PAKAC"
"eppo_taxon_code": "PAKAC",
"name": "weed: parkinsonia aculeata"
}
],
"info": [
Expand Down Expand Up @@ -262759,4 +262768,4 @@
"id": 0
}
]
}
}
8 changes: 7 additions & 1 deletion weedcoco/importers/cwfid.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@
CATEGORY_MAP = {
# TODO: we need a spec for species unspecified, and we need a spec for species specified
"crop": {
"name": "crop: daugus carota",
"common_name": "carrot",
"species": "daugus carota",
"eppo_taxon_code": "DAUCS",
"eppo_nontaxon_code": "3UMRC",
"role": "crop",
"id": 0,
},
"weed": {"species": "UNSPECIFIED", "role": "weed", "id": 1},
"weed": {
"name": "weed: UNSPECIFIED",
"species": "UNSPECIFIED",
"role": "weed",
"id": 1,
},
}


Expand Down
3 changes: 3 additions & 0 deletions weedcoco/importers/deepweeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
category["id"] = row["Label"]
categoryIDToCategories[categoryID] = category
if category["common_name"] == "negative":
category["name"] = "none"
category["role"] = "na"
else:
category["role"] = "weed"
Expand Down Expand Up @@ -140,6 +141,8 @@
if category["common_name"] == "parkinsonia":
category["species"] = "parkinsonia aculeata"
category["eppo_taxon_code"] = "PAKAC"
if "name" not in category:
category["name"] = f"{category['role']}: {category['species']}"

# Create an annotation
ann = {}
Expand Down
29 changes: 29 additions & 0 deletions weedcoco/schema/Category.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$id: https://weedid.sydney.edu.au/schema/Category.json
type: object
required:
- id
- name

properties:
id:
type: number
description: |-
A number identifying the image.
name:
type: string
pattern: "^((crop|weed): ([a-z][a-z ]+|UNSPECIFIED)|crop|weed|none)$"
description: |-
A category for an annotation, consisting of an agricultural role and
optionally a biological name, separated by ": ". Currently allowed
agricultural roles are "weed" and "crop". The "none" category may be
used to indicate that no weed or crop is identified in the image.
Annotations should be labelled with the most specific category possible,
usually "weed: <species name>", but super categories may be more general.
Biological names should be lowercase.
For an unspecified species of weed, "weed: UNSPECIFIED" may be used.
For example, to label an oat crop in an image, the category name would be
"crop: avena sativa". Its super categories may include "crop: grasses"
and "crop". Oats as a volunteer crop would be "weed: avena sativa".
7 changes: 6 additions & 1 deletion weedcoco/schema/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ description: |
type: object
required:
- agcontexts
- annotations
- categories
- collections
- images
- annotations
properties:
images:
type: array
Expand All @@ -19,6 +20,10 @@ properties:
type: array
items:
$ref: https://weedid.sydney.edu.au/schema/Annotation.json#/
categories:
type: array
items:
$ref: https://weedid.sydney.edu.au/schema/Category.json#/
agcontexts:
type: array
items:
Expand Down

0 comments on commit 47bfc2d

Please sign in to comment.