Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
58ef8fb6
You need to sign in or sign up before continuing.
Unverified
Commit
58ef8fb6
authored
Dec 23, 2020
by
Aziz
Committed by
GitHub
Dec 23, 2020
Browse files
Remove deprecated transform from Dataset (#1120)
parent
47c2040e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
51 deletions
+16
-51
torchaudio/datasets/vctk.py
torchaudio/datasets/vctk.py
+11
-28
torchaudio/datasets/yesno.py
torchaudio/datasets/yesno.py
+5
-23
No files found.
torchaudio/datasets/vctk.py
View file @
58ef8fb6
import
os
import
os
import
warnings
import
warnings
from
typing
import
Any
,
Tuple
,
Union
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Tuple
,
Union
import
torchaudio
from
torch
import
Tensor
from
torch
import
Tensor
from
torch.utils.data
import
Dataset
from
torch.utils.data
import
Dataset
import
torchaudio
from
torchaudio.datasets.utils
import
(
from
torchaudio.datasets.utils
import
(
download_url
,
download_url
,
extract_archive
,
extract_archive
,
...
@@ -66,8 +67,6 @@ class VCTK(Dataset):
...
@@ -66,8 +67,6 @@ class VCTK(Dataset):
Giving ``download=True`` will result in error as the dataset is no longer
Giving ``download=True`` will result in error as the dataset is no longer
publicly available.
publicly available.
downsample (bool, optional): Not used.
downsample (bool, optional): Not used.
transform (callable, optional): Optional transform applied on waveform. (default: ``None``)
target_transform (callable, optional): Optional transform applied on utterance. (default: ``None``)
"""
"""
_folder_txt
=
"txt"
_folder_txt
=
"txt"
...
@@ -81,9 +80,7 @@ class VCTK(Dataset):
...
@@ -81,9 +80,7 @@ class VCTK(Dataset):
url
:
str
=
URL
,
url
:
str
=
URL
,
folder_in_archive
:
str
=
FOLDER_IN_ARCHIVE
,
folder_in_archive
:
str
=
FOLDER_IN_ARCHIVE
,
download
:
bool
=
False
,
download
:
bool
=
False
,
downsample
:
bool
=
False
,
downsample
:
bool
=
False
)
->
None
:
transform
:
Any
=
None
,
target_transform
:
Any
=
None
)
->
None
:
if
downsample
:
if
downsample
:
warnings
.
warn
(
warnings
.
warn
(
...
@@ -92,17 +89,7 @@ class VCTK(Dataset):
...
@@ -92,17 +89,7 @@ class VCTK(Dataset):
"and suppress this warning."
"and suppress this warning."
)
)
if
transform
is
not
None
or
target_transform
is
not
None
:
warnings
.
warn
(
"In the next version, transforms will not be part of the dataset. "
"Please remove the option `transform=True` and "
"`target_transform=True` to suppress this warning."
)
self
.
downsample
=
downsample
self
.
downsample
=
downsample
self
.
transform
=
transform
self
.
target_transform
=
target_transform
# Get string representation of 'root' in case Path object is passed
# Get string representation of 'root' in case Path object is passed
root
=
os
.
fspath
(
root
)
root
=
os
.
fspath
(
root
)
...
@@ -149,10 +136,6 @@ class VCTK(Dataset):
...
@@ -149,10 +136,6 @@ class VCTK(Dataset):
# return item
# return item
waveform
,
sample_rate
,
utterance
,
speaker_id
,
utterance_id
=
item
waveform
,
sample_rate
,
utterance
,
speaker_id
,
utterance_id
=
item
if
self
.
transform
is
not
None
:
waveform
=
self
.
transform
(
waveform
)
if
self
.
target_transform
is
not
None
:
utterance
=
self
.
target_transform
(
utterance
)
return
waveform
,
sample_rate
,
utterance
,
speaker_id
,
utterance_id
return
waveform
,
sample_rate
,
utterance
,
speaker_id
,
utterance_id
def
__len__
(
self
)
->
int
:
def
__len__
(
self
)
->
int
:
...
@@ -182,12 +165,12 @@ class VCTK_092(Dataset):
...
@@ -182,12 +165,12 @@ class VCTK_092(Dataset):
"""
"""
def
__init__
(
def
__init__
(
self
,
self
,
root
:
str
,
root
:
str
,
mic_id
:
str
=
"mic2"
,
mic_id
:
str
=
"mic2"
,
download
:
bool
=
False
,
download
:
bool
=
False
,
url
:
str
=
URL
,
url
:
str
=
URL
,
audio_ext
=
".flac"
,
audio_ext
=
".flac"
,
):
):
if
mic_id
not
in
[
"mic1"
,
"mic2"
]:
if
mic_id
not
in
[
"mic1"
,
"mic2"
]:
raise
RuntimeError
(
raise
RuntimeError
(
...
@@ -233,7 +216,7 @@ class VCTK_092(Dataset):
...
@@ -233,7 +216,7 @@ class VCTK_092(Dataset):
continue
continue
utterance_dir
=
os
.
path
.
join
(
self
.
_txt_dir
,
speaker_id
)
utterance_dir
=
os
.
path
.
join
(
self
.
_txt_dir
,
speaker_id
)
for
utterance_file
in
sorted
(
for
utterance_file
in
sorted
(
f
for
f
in
os
.
listdir
(
utterance_dir
)
if
f
.
endswith
(
".txt"
)
f
for
f
in
os
.
listdir
(
utterance_dir
)
if
f
.
endswith
(
".txt"
)
):
):
utterance_id
=
os
.
path
.
splitext
(
utterance_file
)[
0
]
utterance_id
=
os
.
path
.
splitext
(
utterance_file
)[
0
]
audio_path_mic
=
os
.
path
.
join
(
audio_path_mic
=
os
.
path
.
join
(
...
...
torchaudio/datasets/yesno.py
View file @
58ef8fb6
import
os
import
os
import
warnings
from
typing
import
Any
,
List
,
Tuple
,
Union
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
List
,
Tuple
,
Union
import
torchaudio
from
torch
import
Tensor
from
torch
import
Tensor
from
torch.utils.data
import
Dataset
from
torch.utils.data
import
Dataset
import
torchaudio
from
torchaudio.datasets.utils
import
(
from
torchaudio.datasets.utils
import
(
download_url
,
download_url
,
extract_archive
,
extract_archive
,
...
@@ -15,7 +15,7 @@ URL = "http://www.openslr.org/resources/1/waves_yesno.tar.gz"
...
@@ -15,7 +15,7 @@ URL = "http://www.openslr.org/resources/1/waves_yesno.tar.gz"
FOLDER_IN_ARCHIVE
=
"waves_yesno"
FOLDER_IN_ARCHIVE
=
"waves_yesno"
_CHECKSUMS
=
{
_CHECKSUMS
=
{
"http://www.openslr.org/resources/1/waves_yesno.tar.gz"
:
"http://www.openslr.org/resources/1/waves_yesno.tar.gz"
:
"962ff6e904d2df1126132ecec6978786"
"962ff6e904d2df1126132ecec6978786"
}
}
...
@@ -41,8 +41,6 @@ class YESNO(Dataset):
...
@@ -41,8 +41,6 @@ class YESNO(Dataset):
The top-level directory of the dataset. (default: ``"waves_yesno"``)
The top-level directory of the dataset. (default: ``"waves_yesno"``)
download (bool, optional):
download (bool, optional):
Whether to download the dataset if it is not found at root path. (default: ``False``).
Whether to download the dataset if it is not found at root path. (default: ``False``).
transform (callable, optional): Optional transform applied on waveform. (default: ``None``)
target_transform (callable, optional): Optional transform applied on utterance. (default: ``None``)
"""
"""
_ext_audio
=
".wav"
_ext_audio
=
".wav"
...
@@ -51,19 +49,7 @@ class YESNO(Dataset):
...
@@ -51,19 +49,7 @@ class YESNO(Dataset):
root
:
Union
[
str
,
Path
],
root
:
Union
[
str
,
Path
],
url
:
str
=
URL
,
url
:
str
=
URL
,
folder_in_archive
:
str
=
FOLDER_IN_ARCHIVE
,
folder_in_archive
:
str
=
FOLDER_IN_ARCHIVE
,
download
:
bool
=
False
,
download
:
bool
=
False
)
->
None
:
transform
:
Any
=
None
,
target_transform
:
Any
=
None
)
->
None
:
if
transform
is
not
None
or
target_transform
is
not
None
:
warnings
.
warn
(
"In the next version, transforms will not be part of the dataset. "
"Please remove the option `transform=True` and "
"`target_transform=True` to suppress this warning."
)
self
.
transform
=
transform
self
.
target_transform
=
target_transform
# Get string representation of 'root' in case Path object is passed
# Get string representation of 'root' in case Path object is passed
root
=
os
.
fspath
(
root
)
root
=
os
.
fspath
(
root
)
...
@@ -102,10 +88,6 @@ class YESNO(Dataset):
...
@@ -102,10 +88,6 @@ class YESNO(Dataset):
# return item
# return item
waveform
,
sample_rate
,
labels
=
item
waveform
,
sample_rate
,
labels
=
item
if
self
.
transform
is
not
None
:
waveform
=
self
.
transform
(
waveform
)
if
self
.
target_transform
is
not
None
:
labels
=
self
.
target_transform
(
labels
)
return
waveform
,
sample_rate
,
labels
return
waveform
,
sample_rate
,
labels
def
__len__
(
self
)
->
int
:
def
__len__
(
self
)
->
int
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment