-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Docs] Add shape-level classification examples (#539)
- Loading branch information
Showing
14 changed files
with
431 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+230 KB
examples/classification/shape-level/.data/annotated_person_attributes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+197 KB
examples/classification/shape-level/.data/annotated_vehicle_attributes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Shape-level Classification Example | ||
|
||
## Multi-task Classification | ||
|
||
### Introduction | ||
|
||
**Multi-task Classification** involves training a model to perform multiple classification tasks simultaneously. For example, a model could be trained to classify both the type of person and vehicle attributes in a single image. | ||
|
||
<img src=".data/annotated_person_attributes.png" width="100%" /> | ||
<img src=".data/annotated_vehicle_attributes.png" width="100%" /> | ||
|
||
### Usage | ||
|
||
**Step 0: Preparation** | ||
|
||
Prepare a attributes file like [attributes.json](./attributes.json). An example is shown below: | ||
|
||
```json | ||
{ | ||
"vehicle": { | ||
"bodyColor": [ | ||
"red", | ||
"white", | ||
"blue" | ||
], | ||
"vehicleType": [ | ||
"SUV", | ||
"sedan", | ||
"bus", | ||
"truck" | ||
] | ||
}, | ||
"person": { | ||
"wearsGlasses": ["yes", "no"], | ||
"wearsMask": ["yes", "no"], | ||
"clothingColor": [ | ||
"red", | ||
"green", | ||
"blue" | ||
] | ||
} | ||
} | ||
|
||
``` | ||
|
||
**Step 1: Run the Application** | ||
|
||
```bash | ||
python anylabeling/app.py | ||
``` | ||
|
||
**Step 2: Upload the Configuration File** | ||
|
||
Click on `Upload -> Upload Attributes File` in the top menu bar and select the prepared configuration file to upload. | ||
|
||
For detailed output examples, refer to [this file](./sources/multi-task/elon-musk-tesla.json). | ||
|
||
|
||
## Multiclass & Multilabel Classification | ||
|
||
Similar to [Image-Level Classification](../image-level/README.md), you can also conduct multiclass and multilabel classification for Shape-Level Annotation. | ||
|
||
<img src=".data/annotated_person_flags.png" width="100%" /> | ||
<img src=".data/annotated_helmet_flags.png" width="100%" /> | ||
|
||
## Usage | ||
|
||
### GUI Import (Recommended) | ||
|
||
**Step 0: Preparation** | ||
|
||
Prepare a flags file like [label_flags.yaml](./label_flags.yaml). An example is shown below: | ||
|
||
```YAML | ||
person: | ||
- male | ||
- female | ||
helmet: | ||
- white | ||
- red | ||
- blue | ||
- yellow | ||
- green | ||
``` | ||
**Step 1: Run the Application** | ||
```bash | ||
python anylabeling/app.py | ||
``` | ||
|
||
**Step 2: Upload the Configuration File** | ||
|
||
Click on `Upload -> Upload Label Flags File` in the top menu bar and select the prepared configuration file to upload. | ||
|
||
### Command Line Loading | ||
|
||
**Option 1: Quick Start** | ||
|
||
```bash | ||
python anylabeling/app.py --labels person,helmet --labelflags "{'person': ['male', 'female'], 'helmet': ['white', 'red', 'blue', 'yellow', 'green']}" --validatelabel exact | ||
``` | ||
|
||
> [!TIP] | ||
> The `labelflags` key field supports regular expressions. For instance, you can use patterns like `{person-\d+: [male, tall], "dog-\d+": [black, brown, white], .*: [occluded]}`. | ||
**Option 2: Using a Configuration File** | ||
|
||
```bash | ||
python anylabeling/app.py --labels labels.txt --labelflags label_flags.yaml --validatelabel exact | ||
``` | ||
|
||
For detailed output examples, refer to [this file](./sources/multi-label/worker.json). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"vehicle": { | ||
"bodyColor": [ | ||
"red", | ||
"white", | ||
"blue" | ||
], | ||
"vehicleType": [ | ||
"SUV", | ||
"sedan", | ||
"bus", | ||
"truck" | ||
] | ||
}, | ||
"person": { | ||
"wearsGlasses": ["yes", "no"], | ||
"wearsMask": ["yes", "no"], | ||
"clothingColor": [ | ||
"red", | ||
"green", | ||
"blue" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
person: | ||
- male | ||
- female | ||
helmet: | ||
- white | ||
- red | ||
- blue | ||
- yellow | ||
- green |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
person | ||
helmet |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.