Skip to content

Commit

Permalink
Use CPUOnly when using VisionKit VNCoreMLRequest on Simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
makkina committed Aug 18, 2024
1 parent 5beac79 commit 9f290be
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions NSFWDetector/Classes/NSFWDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ private extension NSFWDetector {
completion(.success(nsfwConfidence: observation.confidence))
})

/**
* `@Required`:
* Set to true on Simulator or VisionKit will attempt to use GPU and fail
*
* `@Important`:
* Running on Simulator results in `significantly reduced accuracy`.
* Run on physical device for acurate results
*/
#if targetEnvironment(simulator)
request.usesCPUOnly = true
#endif

/// Start the actual detection
do {
try requestHandler.perform([request])
Expand Down

0 comments on commit 9f290be

Please sign in to comment.