Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djrandom-py
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
ale
djrandom-py
Commits
ae835481
Commit
ae835481
authored
13 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
run the feature extractor in a separate process to avoid memory leaks
parent
29805bb8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/djrandom/mood/feature_extraction.py
+7
-19
7 additions, 19 deletions
server/djrandom/mood/feature_extraction.py
server/djrandom/mood/mood_scanner.py
+9
-4
9 additions, 4 deletions
server/djrandom/mood/mood_scanner.py
server/setup.py
+1
-0
1 addition, 0 deletions
server/setup.py
with
17 additions
and
23 deletions
server/djrandom/mood/feature_extraction.py
+
7
−
19
View file @
ae835481
...
...
@@ -76,6 +76,7 @@ def _vector_from_file(path):
tnet
.
updControl
(
'
mrs_natural/inSamples
'
,
factor
*
512
)
tnet
.
tick
()
return
tnet
.
getControl
(
'
mrs_realvec/processedData
'
).
to_realvec
()
...
...
@@ -84,26 +85,13 @@ def vector_from_file(path):
return
_vector_from_file
(
mp3_path
)
if
__name__
==
'
__
main
__
'
:
import
sys
,
time
,
marsyas_utils
def
main
()
:
import
sys
,
marsyas_utils
result
=
vector_from_file
(
sys
.
argv
[
1
])
print
str
(
result
)[:
512
]
print
'
serialization benchmark...
'
n
=
5000
start
=
time
.
time
()
for
i
in
xrange
(
n
):
rstr
=
marsyas_utils
.
serialize_realvec
(
result
)
end
=
time
.
time
()
print
'
serialization speed: %g iter/sec
'
%
(
n
/
(
end
-
start
))
start
=
time
.
time
()
for
i
in
xrange
(
n
):
result2
=
marsyas_utils
.
deserialize_realvec
(
rstr
)
end
=
time
.
time
()
print
'
deserialization speed: %g iter/sec
'
%
(
n
/
(
end
-
start
))
rstr
=
marsyas_utils
.
serialize_realvec
(
result
)
sys
.
stdout
.
write
(
rstr
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
server/djrandom/mood/mood_scanner.py
+
9
−
4
View file @
ae835481
...
...
@@ -9,19 +9,24 @@ from djrandom import utils
from
djrandom.model.mp3
import
MP3
from
djrandom.database
import
Session
,
init_db
from
djrandom.model
import
processor
from
djrandom.mood
import
feature_extraction
from
djrandom.mood
import
marsyas_utils
log
=
logging
.
getLogger
(
__name__
)
# We run extract_features as an external program because Marsyas has
# a nasty tendency to leak memory during analysis...
def
get_features
(
path
):
pipe
=
subprocess
.
Popen
([
'
djrandom-mood-extract-features
'
,
path
],
stdout
=
subprocess
.
PIPE
)
return
pipe
.
communicate
()[
0
]
class
TimbreFeatureExtractor
(
processor
.
Processor
):
def
process
(
self
,
mp3
):
log
.
info
(
'
extracting features from %s
'
%
mp3
.
sha1
)
try
:
timbre_vector
=
feature_extraction
.
vector_from_file
(
str
(
mp3
.
path
))
vector_str
=
marsyas_utils
.
serialize_realvec
(
timbre_vector
)
vector_str
=
get_features
(
mp3
.
path
)
except
Exception
,
e
:
log
.
error
(
'
error processing %s: %s
'
%
(
mp3
.
sha1
,
e
))
return
...
...
This diff is collapsed.
Click to expand it.
server/setup.py
+
1
−
0
View file @
ae835481
...
...
@@ -33,6 +33,7 @@ setup(
"
djrandom-metadata-fixer = djrandom.metadata_fixer.metadata_fixer:main
"
,
"
djrandom-solr-fixer = djrandom.model.verify:main
"
,
"
djrandom-mood-scanner = djrandom.mood.mood_scanner:main
"
,
"
djrandom-mood-extract-features = djrandom.mood.feature_extraction:main
"
,
],
},
)
...
...
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