-
Notifications
You must be signed in to change notification settings - Fork 29
Add log_audio
, TBAudio
, tests, examples
#27
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
1a5e250
Merge pull request #1 from PhilipVinc/master
d3f50c6
Merge pull request #2 from PhilipVinc/master
d5fefa1
Merge pull request #5 from PhilipVinc/master
f9992b6
add matrix and list support to log_text
cf7c911
reverting test_TBLogger.jl
9ef5ff4
Merge pull request #7 from PhilipVinc/master
c3c8a6f
add support for 1-D images in `log_image`
8e276e1
add ImageFormat explanation
0e6f2b3
add seperate function for image objects
b53a4a9
add more formats
447c484
add preprocess function for image objects for automatic dispatch
8282a13
add TBImage, TBImages wrapper
c24dd63
add tests. more required. more will come
2884423
Merge pull request #8 from shashikdm/updateimage
c3773cc
minor bug fix
92c7d08
Merge pull request #9 from shashikdm/updateimage
8b6170d
refactoring
a3c90a5
add support for 3-d images such as mri
598aec6
bug fixes
dffb97f
add more tests
e048ddb
minor bug fix
544415b
add examples folder
71d79ee
Merge pull request #10 from shashikdm/examples
15a6250
syntax revision
92a1c10
Merge branch 'master' of github.com:shashikdm/TensorBoardLogger.jl
e4af898
change if else to function dispatch `image_summary`
7a4bef4
major revision `log_image` smart use of ImageFormats
ab7dda3
change throw message
8243d18
change dict to ternary. minor revision
773ff7a
add LogAudio.jl with dep WAV.jl
4c14f46
add test for `log_audio`
9f17ec2
add `TBAudios` and `TBAudio` and test
821b804
bugfix `log_text`
0e80fa5
add examples `Audios.jl` and `Texts.jl`
103d1dc
Merge branch 'master' into master
PhilipVinc 13180d1
Merge pull request #12 from shashikdm/master
60eb6f5
change SummaryCollection construction `log_audio`
ea81489
Merge pull request #11 from shashikdm/logaudio
ba3c284
Merge branch 'master' into master
d6d3285
update
b4a92dd
Merge branch 'master' of github.com:shashikdm/TensorBoardLogger.jl
5e315b9
change docstring
3c0993f
rm test data
700be47
chane SummaryCollection
f86a646
Merge branch 'master' into master
16d20e3
rm WAV dependency
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using TensorBoardLogger #import the TensorBoardLogger package | ||
using Logging #import Logging package | ||
|
||
logger = TBLogger("audiologs", tb_append) #create tensorboard logger | ||
|
||
################log audio example: cos wave ################ | ||
samplerate = 44100 | ||
x = collect(1:samplerate*2) | ||
x = cos.(440*pi*x/samplerate) | ||
#using logger interface | ||
with_logger(logger) do | ||
@info "cos/loggerinterface" x = TBAudio(x, samplerate) | ||
end | ||
#using explicit function interface | ||
log_audio(logger, "cos/explicitinterface", x, samplerate, step = 0) | ||
|
||
|
||
################log scalar example: sin+cos wave################ | ||
y = collect(1:samplerate*2) | ||
y = sin.(440*pi*y/samplerate) | ||
z = x+y | ||
#using logger interface | ||
with_logger(logger) do | ||
@info "sin+cos/loggerinterface" z = TBAudio(z, samplerate) | ||
end | ||
#using explicit function interface | ||
log_audio(logger, "sin+cos/explicitinterface", z, samplerate, step = 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using TensorBoardLogger #import the TensorBoardLogger package | ||
using Logging #import Logging package | ||
|
||
logger = TBLogger("textlogs", tb_append) #create tensorboard logger | ||
|
||
################log scalars example: String################ | ||
#using logger interface | ||
with_logger(logger) do | ||
@info "string/loggerinterface" str = "A computer once beat me at chess, but it was no match for me at kick boxing. *— Emo Philips*" | ||
end | ||
#using explicit function interface | ||
str = | ||
" | ||
All parts should go together without forcing. | ||
You must remember that the parts you are reassembling were disassembled by you. | ||
Therefore, if you can’t get them together again, there must be a reason. | ||
By all means, do not use a hammer.” | ||
*— IBM Manual, 1925* | ||
" | ||
log_text(logger, "string/explicitinterface", str, step = 0) | ||
|
||
|
||
################log scalar example: y = matrix################ | ||
squares = | ||
[["Number" "Square"]; | ||
[1 1]; [2 4]; [3 9]; [4 16]; [5 25]; [6 36]; [7 49]; [8 64]; [9 81]; [10 100]] | ||
|
||
#using explicit function interface | ||
log_text(logger, "table", squares, step = 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
log_audios(logger::TBLogger, name::AbstractString, samples::AbstractArray, samplerate::Real, step) | ||
|
||
Logs multiple audio clips at step `step` | ||
- samples: | ||
Array of audio clips which are Arrays of samples N*C where N = number of samples and C = number of channel | ||
- samplerate: Sampling rate or Sampling frequency: a Real value same for all clips | ||
""" | ||
function log_audios(logger::TBLogger, name::AbstractString, samplesArray::AbstractArray, samplerate::Real; step=nothing) | ||
for (n, sample) in enumerate(samplesArray) | ||
log_audio(logger, name*"/$n", sample, samplerate, step = step) | ||
end | ||
end | ||
""" | ||
log_audio(logger::TBLogger, name::AbstractString, samples::AbstractArray, samplerate::Real, step) | ||
|
||
Logs an audio clip with name `name` at step `step` | ||
- samples: Array of samples N*C where N = number of samples and C = number of channels | ||
- samplerate: Sampling rate or Sampling frequency: a Real value | ||
""" | ||
function log_audio(logger::TBLogger, name::AbstractString, samples::AbstractArray, samplerate::Real; step=nothing) | ||
summ = SummaryCollection(audio_summary(name, samples, samplerate)) | ||
write_event(logger.file, make_event(logger, summ, step=step)) | ||
end | ||
|
||
function audio_summary(name::AbstractString, samples::AbstractArray, samplerate::Real) | ||
@assert ndims(samples) <= 2 | ||
samples = samples./max(maximum(samples), 1) | ||
samples = Int16.(floor.(samples.*32767)) | ||
io = IOBuffer() | ||
save(Stream(format"WAV", io), samples) | ||
eas = io.data | ||
audio = Summary_Audio(sample_rate = samplerate, num_channels = ndims(samples), length_frames = size(samples, 1), encoded_audio_string = eas, content_type = "audio/wav") | ||
Summary_Value(tag=name, audio=audio) | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.