0

I have a sample codebase in Scala where I use OpenCV and ScalaPy for doing some image classification. Here is the codebit:

def loadImage(imagePath: String): Image = {
  // 0. Load the image and extract class label where a path to the image is assumed to be
  // /path/to/dataset/{class}/{image}.jpg
  val matrix: Mat = imread(imagePath)
  val label = imagePath.split("")

  // 1. Run the loaded image through the preprocessors, resulting in a feature vector
  //val preProcessedImagesWithLabels = Seq(new ImageResizePreProcessor(appCfg)).map(preProcessor => (preProcessor.preProcess(matrix), label))
  val preProcessedImagesWithLabels = Seq(new ImageResizePreProcessor(appCfg)).map(preProcessor => preProcessor.preProcess(matrix))
  np.asarray(preProcessedImagesWithLabels)
}

It fails however for the reason that it cannot find an implicit converter for NumPy:

[error] /home/joesan/Projects/Private/ml-projects/object-classifier/src/main/scala/com/bigelectrons/animalclassifier/ImageLoader.scala:10:34: not found: type NumPy
[error]   val np = py.module("numpy").as[NumPy]

What is to be expected in addition to the imports?

  "me.shadaj" %% "scalapy-numpy" % "0.1.0",
"me.shadaj" %% "scalapy-core" % "0.5.0",

1 Answer 1

1

Try with latest "dev" version of scalapy-numpy: 0.1.0+6-14ca0424

So change the sbt build in:

libraryDependencies += "me.shadaj" %% "scalapy-numpy" % "0.1.0+6-14ca0424"

I try in ammonite this script:

import me.shadaj.scalapy.numpy.NumPy 
import me.shadaj.scalapy.py 

val np = py.module("numpy").as[NumPy] 

An it seems to find the NumPy as expected

Sign up to request clarification or add additional context in comments.

1 Comment

With that out of the way, I face another error now as documented here in this new post, but somehow related to this: stackoverflow.com/questions/69794545/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.