Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICV-mmengine_basecode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schiffel
ICV-mmengine_basecode
Commits
7fc0a51a
Unverified
Commit
7fc0a51a
authored
2 years ago
by
Tao Gong
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Doc]: Update the tutorials of basedataset (#445)
* modify the tutorials of basedataset * tmp commit
parent
ca282aee
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/zh_cn/tutorials/basedataset.md
+43
-22
43 additions, 22 deletions
docs/zh_cn/tutorials/basedataset.md
with
43 additions
and
22 deletions
docs/zh_cn/tutorials/basedataset.md
+
43
−
22
View file @
7fc0a51a
...
...
@@ -138,10 +138,22 @@ class ToyDataset(BaseDataset):
在定义了数据集类后,就可以通过如下配置实例化
`ToyDataset`
:
```
python
class
LoadImage
:
def
__call__
(
self
,
results
):
results
[
'
img
'
]
=
cv2
.
imread
(
results
[
'
img_path
'
])
return
results
class
ParseImage
:
def
__call__
(
self
,
results
):
results
[
'
img_shape
'
]
=
results
[
'
img
'
].
shape
return
results
pipeline
=
[
dict
(
type
=
'
xxx
'
,
...),
dict
(
type
=
'
yyy
'
,
...),
...
LoadImage
(),
ParseImage
(),
]
toy_dataset
=
ToyDataset
(
...
...
@@ -154,7 +166,7 @@ toy_dataset = ToyDataset(
同时可以使用数据集类提供的对外接口访问具体的样本信息:
```
python
toy_dataset
.
meta
toy_dataset
.
meta
info
# dict(classes=('cat', 'dog'))
toy_dataset
.
get_data_info
(
0
)
...
...
@@ -168,7 +180,13 @@ len(toy_dataset)
# 2
toy_dataset
[
0
]
# dict(img=xxx, label=0)
# {
# 'img_path': "data/train/xxx/xxx_0.jpg",
# 'img_label': 0,
# 'img': a ndarray with shape (H, W, 3), which denotes the value of the image,
# 'img_shape': (H, W, 3) ,
# ...
# }
# `get_subset` 接口不对原数据集类做修改,即完全复制一份新的
sub_toy_dataset
=
toy_dataset
.
get_subset
(
1
)
...
...
@@ -231,9 +249,8 @@ class ToyVideoDataset(BaseDataset):
```
python
pipeline
=
[
dict
(
type
=
'
xxx
'
,
...),
dict
(
type
=
'
yyy
'
,
...),
...
LoadImage
(),
ParseImage
(),
]
toy_dataset
=
ToyDataset
(
...
...
@@ -254,8 +271,16 @@ toy_dataset = ToyDataset(
toy_dataset
.
full_init
()
# 初始化完毕,现在可以访问具体数据
len
(
toy_dataset
)
# 2
toy_dataset
[
0
]
# dict(img=xxx, label=0)
len
(
toy_dataset
)
# 2
toy_dataset
[
0
]
# {
# 'img_path': "data/train/xxx/xxx_0.jpg",
# 'img_label': 0,
# 'img': a ndarray with shape (H, W, 3), which denotes the value the image,
# 'img_shape': (H, W, 3) ,
# ...
# }
```
**注意:**
...
...
@@ -272,9 +297,8 @@ toy_dataset[0] # dict(img=xxx, label=0)
```
python
pipeline
=
[
dict
(
type
=
'
xxx
'
,
...),
dict
(
type
=
'
yyy
'
,
...),
...
LoadImage
(),
ParseImage
(),
]
toy_dataset
=
ToyDataset
(
...
...
@@ -300,9 +324,8 @@ MMEngine 提供了 `ConcatDataset` 包装来拼接多个数据集,使用方法
from
mmengine.dataset
import
ConcatDataset
pipeline
=
[
dict
(
type
=
'
xxx
'
,
...),
dict
(
type
=
'
yyy
'
,
...),
...
LoadImage
(),
ParseImage
(),
]
toy_dataset_1
=
ToyDataset
(
...
...
@@ -331,9 +354,8 @@ MMEngine 提供了 `RepeatDataset` 包装来重复采样某个数据集若干次
from
mmengine.dataset
import
RepeatDataset
pipeline
=
[
dict
(
type
=
'
xxx
'
,
...),
dict
(
type
=
'
yyy
'
,
...),
...
LoadImage
(),
ParseImage
(),
]
toy_dataset
=
ToyDataset
(
...
...
@@ -375,9 +397,8 @@ class ToyDataset(BaseDataset):
return
[
int
(
data_info
[
'
img_label
'
])]
pipeline
=
[
dict
(
type
=
'
xxx
'
,
...),
dict
(
type
=
'
yyy
'
,
...),
...
LoadImage
(),
ParseImage
(),
]
toy_dataset
=
ToyDataset
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment