diff options
Diffstat (limited to 'latest.pl')
| -rwxr-xr-x | latest.pl | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/latest.pl b/latest.pl new file mode 100755 index 0000000..1bb7932 --- /dev/null +++ b/latest.pl @@ -0,0 +1,106 @@ +#!/usr/bin/perl + +use strict; +use Getopt::Std; + +our $opt_l; # mix and upload files +our $opt_v; # print log for all files +our $opt_n; # name/tag for file +getopts('lavn:'); + +our $matches = 0; +if (scalar @ARGV) { + $matches = {}; + for (@ARGV) { + my ($name, $ep) = split("-", $_, 2); + $matches->{$name} = 1; + } +} +# my $s = "results/exp:03_responses-frame_sizes:8,2-n_rnn:2-dataset:03_responses/checkpoints/best-ep1-it1035"; +sub process($){ + my ($dir) = @_; + my @exp = split(":", $dir); + my $name = $exp[4]; + my $ep; + my $path = "results/" . $dir . "/"; + my $chex = $path . "checkpoints/"; + my $log = $path . 'log'; + return 0 unless -e $chex; + opendir DIR, $chex or die $!; + while (readdir DIR) { + next unless /^ep/; + $ep = $_; + last; + } + closedir DIR; + + my $sampz = $path . "samples/"; + return 0 unless -e $sampz; + my $c = 0; + opendir DIR, $sampz or die $!; + while (readdir DIR) { + next unless /wav$/; + $c += 1; + } + closedir DIR; + + if ($matches && ! exists $matches->{$name}) { + return 0; + } + + if ($opt_v) { + print $name . "\n"; + print `grep valid $log`; + print "\n"; + } + + if ($c == 0) { + return 0; + } + + my @epoch = split("-", $ep); + $name .= "-" . $epoch[0]; + + if (! $epoch[0]) { + return 0; + } + + if (! $opt_l) { + print $name . ", $c samples\n"; + } + + $epoch[0] =~ /(\d+)/; + #if ($1 < 4) { + # return 0; + #} + + if ($opt_l && $opt_n) { + $name .= '-' . $opt_n; + } + + if (-e "output/" . $name . ".mp3") { + return 1; + } + + if (!$opt_l) { + return 0; + } + print "\n"; + print "_______________________________________________________________\n"; + print "\n"; + print $name . ", $c samples\n"; + print "\n"; + system('/bin/bash', 'mix.sh', $path, $name); + return 0; +} + +opendir RESULTS, ("results/") or die $!; +# my @results = sort {(stat $a)[9] <=> (stat $b)[9]} readdir(RESULTS); +my @results = sort {$a cmp $b} readdir(RESULTS); +closedir RESULTS; + +for my $result (@results) { + next if $result !~ /exp:/; + my $rv = process($result); + #last if $rv; +} |
