summaryrefslogtreecommitdiff
path: root/latest.pl
blob: b135e1df9ba229ab48ebde7567f1711292db2c80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/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`;
    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+)/;
  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;
}