Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The predict method should be thread safe #250

Open
asad-awadia opened this issue Oct 1, 2021 · 2 comments
Open

The predict method should be thread safe #250

asad-awadia opened this issue Oct 1, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@asad-awadia
Copy link

val modelHub =
   TFModelHub(cacheDirectory = File("cache/pretrainedModels"))

val model = modelHub[TFModels.CV.ResNet50]

model.use {
   for (i in 1..8) {
       val imageFile = getFileFromResource("datasets/vgg/image$i.jpg")

       val recognizedObject = it.predictObject(imageFile = imageFile)
       println(recognizedObject)
      
       val top5 = it.predictTopKObjects(imageFile = imageFile, topK = 5)
       println(top5.toString())
   }
}

Is the predict* function thread safe?

@asad-awadia
Copy link
Author

@zaleslaw

@zaleslaw
Copy link
Collaborator

zaleslaw commented Oct 4, 2021

I suggest thinking that this is not a thread-safe method and the whole model.
We are planning to work on it in the 0.5-0.6 releases and write in docs about thread-safety guarantees.

Also, we could use under the hood different runtimes with different thread-safety in the proposed low-level API and need to protect it against race conditions on the framework level.

@zaleslaw zaleslaw changed the title Thread safety The predict method should be thread safe Oct 4, 2021
@zaleslaw zaleslaw added the enhancement New feature or request label Oct 4, 2021
@zaleslaw zaleslaw modified the milestones: 0.4, 0.3 Oct 4, 2021
@zaleslaw zaleslaw modified the milestones: 0.4, 0.5 Oct 21, 2021
@ermolenkodev ermolenkodev removed this from the 0.5 milestone Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants