Last active
December 5, 2019 20:42
-
-
Save briantliao/3f64e02227f2fdc62ed23944a31e7681 to your computer and use it in GitHub Desktop.
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
open System | |
open System.IO | |
open System.Diagnostics | |
let getImageLinks file = | |
let text = File.ReadAllText file | |
let links = text.Split "\n" | |
links | |
let exec cmd = | |
// info for bash cmd to run | |
let startInfo = | |
ProcessStartInfo ( | |
FileName = "/bin/bash", | |
Arguments = "-c \"" + cmd + "\"", | |
UseShellExecute = false, | |
RedirectStandardOutput = true | |
) | |
// run cmd | |
let proc = new Process(StartInfo = startInfo) | |
match proc.Start () with | |
| true -> | |
let result = proc.StandardOutput.ReadToEnd () | |
proc.WaitForExit () | |
(true, result) | |
| false -> | |
(false, "terminal call went wrong!") | |
let download link location = | |
let cmd = "cd " + location + "; wget " + link | |
let _, msg = exec cmd | |
() | |
let run () = | |
let links = getImageLinks "data/spiders.txt" | |
let location = "/Users/btl787/00-local/07-datasets/micro-robot-imagenet/spiders" | |
links |> Array.iter (fun link -> download link location) | |
[<EntryPoint>] | |
let main argv = | |
run () | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment