Ezaldeen99 / BackgroundRemoval

Background Removal written with swift using u2net model
Apache License 2.0
203 stars 34 forks source link

Example project compilation error #11

Closed sidan5 closed 6 months ago

sidan5 commented 10 months ago

Screenshot 2023-09-03 at 14 00 17

Didami commented 9 months ago

Issue #8 led to #10. @Ezaldeen99 merged pull request, but didn't update the example. These changes were meant to make optional unwrapping safer. The only missing parts in the example are the do, try, and catch statements. Replace them with the following code:

let image = UIImage(named: "child")
inputImage.image = image

let backgroundRemoval = BackgroundRemoval()
do {
    outputImage.image = try backgroundRemoval.removeBackground(image: image!)
    segmentedImage.image = try backgroundRemoval.removeBackground(image: image!, maskOnly: true)
} catch {
    print(error)
}