#!/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 our $opt_e; # endpoint for cortex upload getopts('lave:n:'); print STDERR "n: $opt_n\n"; print STDERR "v: $opt_v\n"; print STDERR "e: $opt_e\n"; print STDERR "l: $opt_l\n"; 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 $dataset = $name; 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 | head -n 85`; print "\n"; } if ($c == 0) { return 0; } my @epoch = split("-", $ep); $name .= "-" . $epoch[0]; if (! $epoch[0]) { return 0; } if (! $opt_l && ! $opt_v) { print $name . ", $c samples\n"; } $epoch[0] =~ /(\d+)/; my $epoch_num = $1; #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"; print "$path $name $opt_e $dataset $epoch_num\n"; system('/bin/bash', 'mix.sh', $path, $name, $opt_e, $dataset, $epoch_num); 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; }