Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
0e59c939
Unverified
Commit
0e59c939
authored
Aug 29, 2023
by
Susnato Dhar
Committed by
GitHub
Aug 29, 2023
Browse files
update remaining `Pop2Piano` checkpoints (#25827)
update checkpoints
parent
245dcc49
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
20 deletions
+14
-20
src/transformers/models/pop2piano/tokenization_pop2piano.py
src/transformers/models/pop2piano/tokenization_pop2piano.py
+1
-2
tests/models/pop2piano/test_modeling_pop2piano.py
tests/models/pop2piano/test_modeling_pop2piano.py
+3
-3
tests/models/pop2piano/test_processor_pop2piano.py
tests/models/pop2piano/test_processor_pop2piano.py
+3
-5
tests/models/pop2piano/test_tokenization_pop2piano.py
tests/models/pop2piano/test_tokenization_pop2piano.py
+7
-10
No files found.
src/transformers/models/pop2piano/tokenization_pop2piano.py
View file @
0e59c939
...
@@ -30,7 +30,6 @@ if is_pretty_midi_available():
...
@@ -30,7 +30,6 @@ if is_pretty_midi_available():
logger
=
logging
.
get_logger
(
__name__
)
logger
=
logging
.
get_logger
(
__name__
)
## TODO : changing checkpoints from `susnato/pop2piano_dev` to `sweetcocoa/pop2piano` after the PR is approved
VOCAB_FILES_NAMES
=
{
VOCAB_FILES_NAMES
=
{
"vocab"
:
"vocab.json"
,
"vocab"
:
"vocab.json"
,
...
@@ -38,7 +37,7 @@ VOCAB_FILES_NAMES = {
...
@@ -38,7 +37,7 @@ VOCAB_FILES_NAMES = {
PRETRAINED_VOCAB_FILES_MAP
=
{
PRETRAINED_VOCAB_FILES_MAP
=
{
"vocab"
:
{
"vocab"
:
{
"s
usnato
/pop2piano
_dev
"
:
"https://huggingface.co/s
usnato
/pop2piano
_dev
/blob/main/vocab.json"
,
"s
weetcocoa
/pop2piano"
:
"https://huggingface.co/s
weetcocoa
/pop2piano/blob/main/vocab.json"
,
},
},
}
}
...
...
tests/models/pop2piano/test_modeling_pop2piano.py
View file @
0e59c939
...
@@ -734,10 +734,10 @@ class Pop2PianoModelIntegrationTests(unittest.TestCase):
...
@@ -734,10 +734,10 @@ class Pop2PianoModelIntegrationTests(unittest.TestCase):
if
is_librosa_available
()
and
is_scipy_available
()
and
is_essentia_available
()
and
is_torch_available
():
if
is_librosa_available
()
and
is_scipy_available
()
and
is_essentia_available
()
and
is_torch_available
():
from
transformers
import
Pop2PianoFeatureExtractor
,
Pop2PianoTokenizer
from
transformers
import
Pop2PianoFeatureExtractor
,
Pop2PianoTokenizer
model
=
Pop2PianoForConditionalGeneration
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
)
model
=
Pop2PianoForConditionalGeneration
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
)
model
.
eval
()
model
.
eval
()
feature_extractor
=
Pop2PianoFeatureExtractor
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
)
feature_extractor
=
Pop2PianoFeatureExtractor
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
)
tokenizer
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
)
tokenizer
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
)
ds
=
load_dataset
(
"sweetcocoa/pop2piano_ci"
,
split
=
"test"
)
ds
=
load_dataset
(
"sweetcocoa/pop2piano_ci"
,
split
=
"test"
)
output_fe
=
feature_extractor
(
output_fe
=
feature_extractor
(
...
...
tests/models/pop2piano/test_processor_pop2piano.py
View file @
0e59c939
...
@@ -55,8 +55,6 @@ if requirements_available:
...
@@ -55,8 +55,6 @@ if requirements_available:
Pop2PianoTokenizer
,
Pop2PianoTokenizer
,
)
)
## TODO : changing checkpoints from `susnato/pop2piano_dev` to `sweetcocoa/pop2piano` after the PR is approved
@
require_scipy
@
require_scipy
@
require_torch
@
require_torch
...
@@ -67,8 +65,8 @@ class Pop2PianoProcessorTest(unittest.TestCase):
...
@@ -67,8 +65,8 @@ class Pop2PianoProcessorTest(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
tmpdirname
=
tempfile
.
mkdtemp
()
self
.
tmpdirname
=
tempfile
.
mkdtemp
()
feature_extractor
=
Pop2PianoFeatureExtractor
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
)
feature_extractor
=
Pop2PianoFeatureExtractor
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
)
tokenizer
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
)
tokenizer
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
)
processor
=
Pop2PianoProcessor
(
feature_extractor
,
tokenizer
)
processor
=
Pop2PianoProcessor
(
feature_extractor
,
tokenizer
)
processor
.
save_pretrained
(
self
.
tmpdirname
)
processor
.
save_pretrained
(
self
.
tmpdirname
)
...
@@ -121,7 +119,7 @@ class Pop2PianoProcessorTest(unittest.TestCase):
...
@@ -121,7 +119,7 @@ class Pop2PianoProcessorTest(unittest.TestCase):
feature_extractor_outputs
=
self
.
get_feature_extractor
()(
feature_extractor_outputs
=
self
.
get_feature_extractor
()(
audio
=
input_speech
,
sampling_rate
=
sampling_rate
,
return_tensors
=
"pt"
audio
=
input_speech
,
sampling_rate
=
sampling_rate
,
return_tensors
=
"pt"
)
)
model
=
Pop2PianoForConditionalGeneration
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
)
model
=
Pop2PianoForConditionalGeneration
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
)
token_ids
=
model
.
generate
(
input_features
=
feature_extractor_outputs
[
"input_features"
],
composer
=
"composer1"
)
token_ids
=
model
.
generate
(
input_features
=
feature_extractor_outputs
[
"input_features"
],
composer
=
"composer1"
)
dummy_notes
=
[
dummy_notes
=
[
[
[
...
...
tests/models/pop2piano/test_tokenization_pop2piano.py
View file @
0e59c939
...
@@ -43,15 +43,12 @@ if requirements_available:
...
@@ -43,15 +43,12 @@ if requirements_available:
from
transformers
import
Pop2PianoTokenizer
from
transformers
import
Pop2PianoTokenizer
## TODO : changing checkpoints from `susnato/pop2piano_dev` to `sweetcocoa/pop2piano` after the PR is approved
@
require_torch
@
require_torch
@
require_pretty_midi
@
require_pretty_midi
class
Pop2PianoTokenizerTest
(
unittest
.
TestCase
):
class
Pop2PianoTokenizerTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
super
().
setUp
()
super
().
setUp
()
self
.
tokenizer
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
)
self
.
tokenizer
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
)
def
get_input_notes
(
self
):
def
get_input_notes
(
self
):
notes
=
[
notes
=
[
...
@@ -246,30 +243,30 @@ class Pop2PianoTokenizerTest(unittest.TestCase):
...
@@ -246,30 +243,30 @@ class Pop2PianoTokenizerTest(unittest.TestCase):
self
.
assertListEqual
(
subwords
,
subwords_loaded
)
self
.
assertListEqual
(
subwords
,
subwords_loaded
)
def
test_padding_side_in_kwargs
(
self
):
def
test_padding_side_in_kwargs
(
self
):
tokenizer_p
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
,
padding_side
=
"left"
)
tokenizer_p
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
,
padding_side
=
"left"
)
self
.
assertEqual
(
tokenizer_p
.
padding_side
,
"left"
)
self
.
assertEqual
(
tokenizer_p
.
padding_side
,
"left"
)
tokenizer_p
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
,
padding_side
=
"right"
)
tokenizer_p
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
,
padding_side
=
"right"
)
self
.
assertEqual
(
tokenizer_p
.
padding_side
,
"right"
)
self
.
assertEqual
(
tokenizer_p
.
padding_side
,
"right"
)
self
.
assertRaises
(
self
.
assertRaises
(
ValueError
,
ValueError
,
Pop2PianoTokenizer
.
from_pretrained
,
Pop2PianoTokenizer
.
from_pretrained
,
"s
usnato
/pop2piano
_dev
"
,
"s
weetcocoa
/pop2piano"
,
padding_side
=
"unauthorized"
,
padding_side
=
"unauthorized"
,
)
)
def
test_truncation_side_in_kwargs
(
self
):
def
test_truncation_side_in_kwargs
(
self
):
tokenizer_p
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
,
truncation_side
=
"left"
)
tokenizer_p
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
,
truncation_side
=
"left"
)
self
.
assertEqual
(
tokenizer_p
.
truncation_side
,
"left"
)
self
.
assertEqual
(
tokenizer_p
.
truncation_side
,
"left"
)
tokenizer_p
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
usnato
/pop2piano
_dev
"
,
truncation_side
=
"right"
)
tokenizer_p
=
Pop2PianoTokenizer
.
from_pretrained
(
"s
weetcocoa
/pop2piano"
,
truncation_side
=
"right"
)
self
.
assertEqual
(
tokenizer_p
.
truncation_side
,
"right"
)
self
.
assertEqual
(
tokenizer_p
.
truncation_side
,
"right"
)
self
.
assertRaises
(
self
.
assertRaises
(
ValueError
,
ValueError
,
Pop2PianoTokenizer
.
from_pretrained
,
Pop2PianoTokenizer
.
from_pretrained
,
"s
usnato
/pop2piano
_dev
"
,
"s
weetcocoa
/pop2piano"
,
truncation_side
=
"unauthorized"
,
truncation_side
=
"unauthorized"
,
)
)
...
...
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