Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tff2020
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
skmad-suite
tff2020
Commits
b384d014
Commit
b384d014
authored
5 years ago
by
valentin.emiya
Browse files
Options
Downloads
Patches
Plain Diff
add notebook create_subregions
parent
efea0db2
Branches
cms/general/lorem
No related tags found
No related merge requests found
Pipeline
#5124
failed
5 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/doc/_notebooks/create_subregions.ipynb
+134
-0
134 additions, 0 deletions
python/doc/_notebooks/create_subregions.ipynb
with
134 additions
and
0 deletions
python/doc/_notebooks/create_subregions.ipynb
0 → 100644
+
134
−
0
View file @
b384d014
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Demo for `tffpy.create_subregions.create_subregions`\n",
"\n",
"A simple demonstration for creating sub-regions from a boolean time-frequency mask"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%javascript\n",
"IPython.OutputArea.prototype._should_scroll = function(lines) {\n",
" return false;\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib as mpl\n",
"mpl.rcParams['figure.figsize'] = [15.0, 7.0]\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from tffpy.datasets import get_mix\n",
"from tffpy.create_subregions import create_subregions"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig_dir = 'fig_create_subregions'\n",
"x_mix, dgt_params, signal_params, mask, x_loc, x_wb = \\\n",
" get_mix(loc_source='bird',\n",
" wideband_src='car',\n",
" crop=8192,\n",
" win_dur=256/8000,\n",
" win_type='gauss',\n",
" hop_ratio=1/4,\n",
" n_bins_ratio=4,\n",
" n_iter_closing=3,\n",
" n_iter_opening=3,\n",
" closing_first=True,\n",
" delta_mix_db=0,\n",
" delta_loc_db=20,\n",
" wb_to_loc_ratio_db=16,\n",
" or_mask=True,\n",
" fig_dir=None)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tol = 1e-9\n",
"mask_with_subregions, norms = create_subregions(mask_bool=mask, \n",
" dgt_params=dgt_params, signal_params=signal_params, \n",
" tol=tol, fig_dir=fig_dir, return_norms=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('Values in mask:', np.unique(mask_with_subregions))\n",
"print('Number of sub-regions:', np.max(mask_with_subregions))\n",
"plt.semilogy(np.sort(np.unique(norms)))\n",
"plt.title('Distances between sub-regions (sorted norm coefficients without duplicates)')\n",
"plt.grid()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
%% Cell type:markdown id: tags:
# Demo for `tffpy.create_subregions.create_subregions`
A simple demonstration for creating sub-regions from a boolean time-frequency mask
%% Cell type:code id: tags:
```
python
%
load_ext
autoreload
%
autoreload
2
%
matplotlib
inline
```
%% Cell type:code id: tags:
```
python
%%
javascript
IPython
.
OutputArea
.
prototype
.
_should_scroll
=
function
(
lines
)
{
return
false
;
}
```
%% Cell type:code id: tags:
```
python
import
numpy
as
np
import
matplotlib
as
mpl
mpl
.
rcParams
[
'
figure.figsize
'
]
=
[
15.0
,
7.0
]
import
matplotlib.pyplot
as
plt
from
tffpy.datasets
import
get_mix
from
tffpy.create_subregions
import
create_subregions
```
%% Cell type:code id: tags:
```
python
fig_dir
=
'
fig_create_subregions
'
x_mix
,
dgt_params
,
signal_params
,
mask
,
x_loc
,
x_wb
=
\
get_mix
(
loc_source
=
'
bird
'
,
wideband_src
=
'
car
'
,
crop
=
8192
,
win_dur
=
256
/
8000
,
win_type
=
'
gauss
'
,
hop_ratio
=
1
/
4
,
n_bins_ratio
=
4
,
n_iter_closing
=
3
,
n_iter_opening
=
3
,
closing_first
=
True
,
delta_mix_db
=
0
,
delta_loc_db
=
20
,
wb_to_loc_ratio_db
=
16
,
or_mask
=
True
,
fig_dir
=
None
)
```
%% Cell type:code id: tags:
```
python
tol
=
1e-9
mask_with_subregions
,
norms
=
create_subregions
(
mask_bool
=
mask
,
dgt_params
=
dgt_params
,
signal_params
=
signal_params
,
tol
=
tol
,
fig_dir
=
fig_dir
,
return_norms
=
True
)
```
%% Cell type:code id: tags:
```
python
print
(
'
Values in mask:
'
,
np
.
unique
(
mask_with_subregions
))
print
(
'
Number of sub-regions:
'
,
np
.
max
(
mask_with_subregions
))
plt
.
semilogy
(
np
.
sort
(
np
.
unique
(
norms
)))
plt
.
title
(
'
Distances between sub-regions (sorted norm coefficients without duplicates)
'
)
plt
.
grid
()
```
%% Cell type:code id: tags:
```
python
```
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