summaryrefslogtreecommitdiff
path: root/scripts/builders/flat-dataset.pl
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-05-19 10:50:08 +0200
committerJules Laplace <julescarbon@gmail.com>2018-05-19 10:50:08 +0200
commit80026ffe3a4a71fa1530407e9fb58d90ef8ef2e6 (patch)
treeb78ec46da92f3c63fb95c7423d717bcdf1ead1d8 /scripts/builders/flat-dataset.pl
parent3ac5fa26a191dc27434c60a6fb48deae828b7c90 (diff)
parente617254facb9d5e0246a1ac35721ec245230783f (diff)
Merge branch 'master' of ghghgh.us:pix2pix
Diffstat (limited to 'scripts/builders/flat-dataset.pl')
-rwxr-xr-xscripts/builders/flat-dataset.pl58
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/builders/flat-dataset.pl b/scripts/builders/flat-dataset.pl
new file mode 100755
index 0000000..48479bd
--- /dev/null
+++ b/scripts/builders/flat-dataset.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+use strict;
+
+# Processing script for Adversarial Video Generation library
+# Images should all be 320x or similar
+
+our $images_dir = "/home/lens/Desktop/woods_videos/kaulsdorf_large/";
+our $thumbs_dir = "/home/lens/Desktop/thumbs/kaulsdorf_large/";
+
+mkdir($thumbs_dir);
+mkdir($thumbs_dir . "Train/");
+mkdir($thumbs_dir . "Test/");
+
+our $frames_per_dir = 64;
+our $test_split = 5; # 1/N videos will be for the test split
+
+our @files = ();
+
+opendir DIR, $images_dir;
+while (readdir DIR) {
+ next if /^\./;
+ push(@files, $_);
+}
+closedir DIR;
+
+our @images = sort @files;
+
+my $count = scalar(@images);
+
+my $i;
+my $j;
+my $dirid = -2;
+my $nextid;
+my $dir;
+for ($i = 0; $i < $count; $i++) {
+ $nextid = int($i / $frames_per_dir);
+ if ($nextid != $dirid) {
+ $dirid = $nextid;
+ if (($dirid % $test_split) != ($test_split-1)) {
+ $dir = $thumbs_dir . "Train/video" . $dirid . "/";
+ } else {
+ $dir = $thumbs_dir . "Test/video" . $dirid . "/";
+ }
+ print $dir . "\n";
+ mkdir($dir);
+ $j = 0;
+ } else {
+ $j += 1;
+ }
+
+ my $src = $images_dir . $images[$i];
+ my $dst = $dir . sprintf("frame%03d.png", $j);
+ system("cp", $src, $dst);
+ print $dst . "\n";
+}
+print $count . "\n";
+