Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
change the DownloadUtil to Util
Browse files Browse the repository at this point in the history
  • Loading branch information
lanking520 committed Jul 27, 2018
1 parent b581bbf commit 5d5ad84
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* limitations under the License.
*/

package org.apache.mxnet.util
package org.apache.mxnetexamples

import java.io.File
import java.net.URL

import org.apache.commons.io.FileUtils

object DownloadUtil {
object Util {

def downloadUrl(url: String, filePath: String, maxRetry: Option[Int] = None) : Unit = {
val tmpFile = new File(filePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import org.apache.mxnet.Context
import org.apache.mxnet.Xavier
import org.apache.mxnet.optimizer.RMSProp
import org.apache.mxnet.Executor
import org.apache.mxnet.util.DownloadUtil
import org.apache.mxnetexamples.Util

import scala.collection.immutable.ListMap
import scala.sys.process.Process
Expand Down Expand Up @@ -202,7 +202,7 @@ object ExampleMultiTask {
val baseUrl = "https://s3.us-east-2.amazonaws.com/mxnet-scala/scala-example-ci"
val tempDirPath = System.getProperty("java.io.tmpdir")
val modelDirPath = tempDirPath + File.separator + "multitask/"
DownloadUtil.downloadUrl(baseUrl + "/mnist/mnist.zip",
Util.downloadUrl(baseUrl + "/mnist/mnist.zip",
tempDirPath + "/multitask/mnist.zip")

// TODO: Need to confirm with Windows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.net.URL

import org.apache.commons.io.FileUtils
import org.apache.mxnet.Context
import org.apache.mxnet.util.DownloadUtil
import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

Expand All @@ -47,12 +47,12 @@ class CNNClassifierExampleSuite extends FunSuite with BeforeAndAfterAll {

logger.info("Downloading CNN text...")
val baseUrl = "https://s3.us-east-2.amazonaws.com/mxnet-scala"
DownloadUtil.downloadUrl(baseUrl + "/scala-example-ci/CNN/rt-polarity.pos",
Util.downloadUrl(baseUrl + "/scala-example-ci/CNN/rt-polarity.pos",
tempDirPath + "/CNN/rt-polarity.pos")
DownloadUtil.downloadUrl(baseUrl + "/scala-example-ci/CNN/rt-polarity.neg",
Util.downloadUrl(baseUrl + "/scala-example-ci/CNN/rt-polarity.neg",
tempDirPath + "/CNN/rt-polarity.neg")
logger.info("Downloading pretrianed Word2Vec Model, may take a while")
DownloadUtil.downloadUrl(baseUrl + "/scala-example-ci/CNN/" + w2vModelName,
Util.downloadUrl(baseUrl + "/scala-example-ci/CNN/" + w2vModelName,
tempDirPath + "/CNN/" + w2vModelName)

val modelDirPath = tempDirPath + File.separator + "CNN"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.net.URL

import org.apache.commons.io.FileUtils
import org.apache.mxnet.Context
import org.apache.mxnet.util.DownloadUtil
import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

Expand Down Expand Up @@ -65,7 +65,7 @@ class CustomOpExampleSuite extends FunSuite with BeforeAndAfterAll {
val baseUrl = "https://s3.us-east-2.amazonaws.com/mxnet-scala/scala-example-ci"
val tempDirPath = System.getProperty("java.io.tmpdir")
val modelDirPath = tempDirPath + File.separator + "mnist/"
DownloadUtil.downloadUrl(baseUrl + "/mnist/mnist.zip",
Util.downloadUrl(baseUrl + "/mnist/mnist.zip",
tempDirPath + "/mnist/mnist.zip")
// TODO: Need to confirm with Windows
Process("unzip " + tempDirPath + "/mnist/mnist.zip -d "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.net.URL

import org.apache.commons.io.FileUtils
import org.apache.mxnet.Context
import org.apache.mxnet.util.DownloadUtil
import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

Expand All @@ -39,7 +39,7 @@ class GanExampleSuite extends FunSuite with BeforeAndAfterAll{
val tempDirPath = System.getProperty("java.io.tmpdir")
val modelDirPath = tempDirPath + File.separator + "mnist/"
logger.info("tempDirPath: %s".format(tempDirPath))
DownloadUtil.downloadUrl(baseUrl + "/mnist/mnist.zip",
Util.downloadUrl(baseUrl + "/mnist/mnist.zip",
tempDirPath + "/mnist/mnist.zip")
// TODO: Need to confirm with Windows
Process("unzip " + tempDirPath + "/mnist/mnist.zip -d "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.net.URL

import org.apache.commons.io.FileUtils
import org.apache.mxnet.Context
import org.apache.mxnet.util.DownloadUtil
import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

Expand All @@ -42,7 +42,7 @@ class MNISTExampleSuite extends FunSuite with BeforeAndAfterAll {
val tempDirPath = System.getProperty("java.io.tmpdir")
val modelDirPath = tempDirPath + File.separator + "mnist/"
logger.info("tempDirPath: %s".format(tempDirPath))
DownloadUtil.downloadUrl(baseUrl + "/mnist/mnist.zip",
Util.downloadUrl(baseUrl + "/mnist/mnist.zip",
tempDirPath + "/mnist/mnist.zip")
// TODO: Need to confirm with Windows
Process("unzip " + tempDirPath + "/mnist/mnist.zip -d "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.net.URL

import org.apache.commons.io.FileUtils
import org.apache.mxnet.Context
import org.apache.mxnet.util.DownloadUtil
import org.apache.mxnetexamples.Util

import sys.process.Process

Expand All @@ -43,13 +43,13 @@ class ImageClassifierExampleSuite extends FunSuite with BeforeAndAfterAll {

val baseUrl = "https://s3.us-east-2.amazonaws.com/scala-infer-models"

DownloadUtil.downloadUrl(baseUrl + "/resnet-18/resnet-18-symbol.json",
Util.downloadUrl(baseUrl + "/resnet-18/resnet-18-symbol.json",
tempDirPath + "/resnet18/resnet-18-symbol.json")
DownloadUtil.downloadUrl(baseUrl + "/resnet-18/resnet-18-0000.params",
Util.downloadUrl(baseUrl + "/resnet-18/resnet-18-0000.params",
tempDirPath + "/resnet18/resnet-18-0000.params")
DownloadUtil.downloadUrl(baseUrl + "/resnet-18/synset.txt",
Util.downloadUrl(baseUrl + "/resnet-18/synset.txt",
tempDirPath + "/resnet18/synset.txt")
DownloadUtil.downloadUrl("https://s3.amazonaws.com/model-server/inputs/Pug-Cookie.jpg",
Util.downloadUrl("https://s3.amazonaws.com/model-server/inputs/Pug-Cookie.jpg",
tempDirPath + "/inputImages/resnet18/Pug-Cookie.jpg")

val modelDirPath = tempDirPath + File.separator + "resnet18/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.net.URL

import org.apache.commons.io.FileUtils
import org.apache.mxnet.Context
import org.apache.mxnet.util.DownloadUtil
import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

Expand All @@ -40,13 +40,13 @@ class ObjectDetectorExampleSuite extends FunSuite with BeforeAndAfterAll {
val modelBase = "https://s3.amazonaws.com/model-server/models/resnet50_ssd/"
val imageBase = "https://s3.amazonaws.com/model-server/inputs/"

DownloadUtil.downloadUrl(modelBase + "resnet50_ssd_model-symbol.json",
Util.downloadUrl(modelBase + "resnet50_ssd_model-symbol.json",
tempDirPath + "/resnetssd/resnet50_ssd_model-symbol.json")
DownloadUtil.downloadUrl(modelBase + "resnet50_ssd_model-0000.params",
Util.downloadUrl(modelBase + "resnet50_ssd_model-0000.params",
tempDirPath + "/resnetssd/resnet50_ssd_model-0000.params")
DownloadUtil.downloadUrl(modelBase + "synset.txt",
Util.downloadUrl(modelBase + "synset.txt",
tempDirPath + "/resnetssd/synset.txt")
DownloadUtil.downloadUrl(imageBase + "dog-ssd.jpg",
Util.downloadUrl(imageBase + "dog-ssd.jpg",
tempDirPath + "/inputImages/resnetssd/dog-ssd.jpg")

val modelDirPath = tempDirPath + File.separator + "resnetssd/"
Expand Down

0 comments on commit 5d5ad84

Please sign in to comment.