Skip to content

Commit

Permalink
docs(comment): refine comment to improve redability of docs generated…
Browse files Browse the repository at this point in the history
… by sphinx
  • Loading branch information
imhuwq committed Sep 25, 2023
1 parent 184ae40 commit 28a4e85
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 68 deletions.
1 change: 1 addition & 0 deletions build_doc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sphinx-apidoc -o docs/api_reference deepdataspace/
55 changes: 41 additions & 14 deletions deepdataspace/algos/calculate_fnfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,37 @@ def calculate_thresholds(all_gt: List[List],
"""
For given IoU thresh, calculate confidence thresh for precisions from 0.0 to 1.0 .
:param all_gt: All ground truth objects from a subset
[image_id(str), category_id(int), bbox(List[int])], bbox = [x1, y1, x2, y2]
:param all_det: All prediction objects from a subset
[image_id(str), category_id(int), bbox(List[int]), conf(float)], bbox = [x1, y1, x2, y2]
:param iou_thresh: IoU threshold
:return [
{"conf_thresh": xxx, "recall": xxx, "precision": xxx, "precision_thresh": xxx}
:param all_gt: All ground truth objects from a subset.
.. code-block:: python
[
# [image_id, category_id, [x1, y1, x2, y2]]
[1, 1, [10, 20, 30, 40]],
]
:param all_det: All prediction objects from a subset.
.. code-block:: python
[
# [image_id, category_id, [x1, y1, x2, y2], conf]
[1, 1, [10, 20, 33, 43], 0.8],
]
:param iou_thresh: float.
:return conf thresholds: list of dict.
.. code-block:: python
[
{
"conf_thresh": 10,
"recall": 10,
"precision": 10,
"precision_thresh": 10.1
}
]
"""

Expand Down Expand Up @@ -159,14 +183,17 @@ def calculate_fnfp(all_gt: List[List],
"""
For given IoU thresh, check the correctness of all predictions in an image.
:param all_gt: All ground truth objects from a subset
[category_id(int), bbox(List[int])], bbox = [x1, y1, x2, y2]
:param all_det: All prediction objects from a subset
[category_id(int), bbox(List[int]), conf(float)], bbox = [x1, y1, x2, y2]
:param all_gt:
| All ground truth objects from a subset
| [category_id(int), bbox(List[int])], bbox = [x1, y1, x2, y2]
:param all_det:
| All prediction objects from a subset
| [category_id(int), bbox(List[int]), conf(float)], bbox = [x1, y1, x2, y2]
:param iou_thresh: IoU threshold
:return (gt_results, det_results)
gt_results, list, -1 means FN, otherwise means matched det id
det_results, list, 1 means TP, 0 means FP
:return tuple of list of int:
| (gt_results, det_results)
| gt_results, list, -1 means FN, otherwise means matched det id
| det_results, list, 1 means TP, 0 means FP
"""

gt_arr = np.array(all_gt[:], dtype=np.float32)
Expand Down
3 changes: 1 addition & 2 deletions deepdataspace/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ class ContentEncoding:

class DatasetFileType:
"""
| TSV dataset related file types.
| TSV dataset format may contain multiple files, each of these types:
Dataset related file types.
"""

GroundTruth = LabelName.GroundTruth
Expand Down
3 changes: 2 additions & 1 deletion deepdataspace/environs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
.. data:: DDS_RUNTIME_DIR
| The runtime directory of dds.
The runtime directory of dds.
:default: ``~/.deepdataspace``
.. data:: DDS_DJANGO_DIR
The runtime directory of django which includes django log files.
:default: ``$DDS_RUNTIME_DIR/django``
Expand Down
102 changes: 51 additions & 51 deletions samples/coco_dataset_meta.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
This file is a coco meta file instructing DDS how to import a coco dataset.
Put it under the DATA_DIR directory specified when starting DDS, DDS will recognize file and import the dataset.
You can also use the ddsop command to import or delete the dataset:
This is a coco dataset meta file instructing DDS to import a coco dataset.
Put it under the DATA_DIR directory specified when starting DDS, DDS will recognize it and import the dataset.
You can also use the `ddsop` command to import or delete the dataset:
```shell
ddsop import_one /path/to/this/meta/file.py
ddsop delete_one /path/to/this/meta/file.py
```
"""

is_coco_meta = True # Mandatory.
# You must declare this variable, otherwise DDS will ignore it.
# Must declare this variable and set it to `True`, otherwise DDS will ignore this file.

dataset_name = "instances_val2017" # Mandatory.
# The name of the dataset.
Expand All @@ -27,67 +27,67 @@
}
] # Optional.
# The prediction sets of this dataset.
# If you don't have any prediction set for this dataset, you can leave it out or set it to None/[].
# Otherwise, it must be a list of dict, each dict must contain a "name" and a "file" key.
# Set it to None or [] if you don't have any prediction set for this dataset.

image_root = None # Optional.
# The DDS will try to locate the image file under this directory, according to the "file_name" field.

dynamic_caption = False # Optional.


# Indicating whether the caption is dynamic or not.
# If it is True, DDS will call the `caption_generator` function to generate the caption for every image
# while you are browsing the dataset.


def caption_generator(image):
def caption_generator(image: dict) -> str:
"""
This function is used to generate a caption for an image dynamically while browsing the dataset.
It only works when `dynamic_caption = True` in this meta file.
| This function is used to generate a caption for an image dynamically while browsing the dataset.
| It only works when `dynamic_caption = True` in this meta file.
:param image: The image object.
:param image: The image object. The data structure is as follows:
```json
{
"idx": 0,
"id": 179765,
"width": 640,
"height": 480,
"objects": [
{
"label_name": "GroundTruth",
"label_id": "aa",
"category_id": "bb",
"category_name": "",
"conf": 1.0,
"is_group": null,
"bounding_box": {
"xmin": 0.0,
"ymin": 0.0,
"xmax": 1.0,
"ymax": 1.0
},
"segmentation": "",
"points": [x1, y1, x2, y2, x3, y3...],
"lines": [l1_beg, l1_end, l2_beg, l2_end, l3_beg, l3_end...],
"point_colors": [r1, g1, b1, r2, b2, g2, r3, g3, b3...],
"point_names": ["point1", "point2", "point3"...],
"caption": "A black Honda motorcycle parked in front of a garage."
}
],
"url": "https://example.com/thumb.jpg",
"url_full_res": "https://example.com/picture.jpg",
"desc": "image description",
"metadata": {
"license": 3,
"date_captured": "2013-11-15 14:02:51",
"flickr_url": "http://farm3.staticflickr.com/2824/10213933686_6936eb402b_z.jpg",
"id": 179765
}
}
```
.. code-block:: python
{
"idx": 0,
"id": 179765,
"width": 640,
"height": 480,
"url": "https://example.com/thumb.jpg",
"url_full_res": "https://example.com/picture.jpg",
"desc": "image description",
"metadata": {
"license": 3,
"date_captured": "2013-11-15 14:02:51",
"flickr_url": "http://farm3.staticflickr.com/2824/10213933686_6936eb402b_z.jpg",
"id": 179765
},
"objects": [
{
"label_name": "GroundTruth",
"label_id": "aa",
"category_id": "bb",
"category_name": "",
"conf": 1.0,
"is_group": null,
"bounding_box": {
"xmin": 0.0,
"ymin": 0.0,
"xmax": 1.0,
"ymax": 1.0
},
"segmentation": "x1,y1,x2,y2,x3,y3/x1,y1,x2,y2,x3,y3/x1,y1,x2,y2,x3,y3...",
"points": [x1, y1, x2, y2, x3, y3...],
"lines": [l1_beg, l1_end, l2_beg, l2_end, l3_beg, l3_end...],
"point_colors": [r1, g1, b1, r2, b2, g2, r3, g3, b3...],
"point_names": ["point1", "point2", "point3"...],
"caption": "A black Honda motorcycle parked in front of a garage."
}
]
}
:return: The caption string.
"""

objects = image["objects"]
if objects:
return objects[0]["caption"]
Expand Down

0 comments on commit 28a4e85

Please sign in to comment.