Write an iOS app that runs a saved TensorFlow model to classify images. The app should…
Jump to turn (52)
- 1Write an iOS app that runs a saved TensorFlow model to classify images. The app
- 2Can you implement the camera functionality for me please.
- 3Great! Can you write the code to call the image classifier?
- 4What if I need to resize the image to 384x384 for the model? Does that happen au
- 5By the way, how do I install this on my iPhone to test?
- 6Will image.resized scale the photo or crop it?
- 7No, I don't want to crop it. I want to rescale it (with interpolation), without
- 8Ok I'm creating a new Xcode project now. Interface is set to SwiftUI and Languag
- 9Oh, sorry, should I have selected UIKit? Is one better than the other? Previousl
- 10Ok, now I have two swift files in my project: Smart\Parking\TesterApp.swift Cont
- 11Ok, I tried to drag and drop my .mlmodel file, and it gives me a few options. Sh
- 12Ok, now I have the error "Value of type 'ContentView' has no member 'resultLabel
- 13New error: 'weak' may only be applied to class and class-bound protocol types, n
- 14I tried to run it the app on my computer and I think it broke: 2023-03-28 18:39:
- 152023-03-28 18:44:05.812869+0300 Smart Parking Tester[79849:4524639] [SceneConfig
- 16Ok, when I load this app on my personal iPhone, the app just closes (crashes) wh
- 17I checked the logs and it looks like a permissions thing. Incident Identifier: 2
- 18In build settings it has Generate Info.plist File set to Yes. Does that mean I d
- 19Cannot code sign because the target does not have an Info.plist file and one is
- 20Multiple commands produce '/Users/alomax/Library/Developer/Xcode/DerivedData/Sma
- 21Great! New error: “Smart Parking Tester” does not contain a valid Info.plist, so
- 22Wait, should I literally copy "$(EXECUTABLE\NAME)" or do I need to replace EXECU
- 23Unable to install "Smart Parking Tester" Domain: com.apple.dt.MobileDeviceErrorD
- 24Ok great. Now it works, kind of. I can install the app and take a picture, but n
- 25How do I add a breakpoint as described?
- 26Ok, it's just failing to load the model I think. "Failed to load the Core ML mod
- 27func classifyImage(\ image: UIImage) { // Resize the image to 384x384 pixels gua
- 28Great. Now we have a slightly more meaningful message. Failed to load the Core M
- 29Input says MultiArray (Float32 1 × 300 × 300 × 3). Can we transform our image to
- 30Remember, we're using SwiftUI not UIKit. Here's our ContentView.swift file: Plea
- 31did you cut off there?
- 32You cut off again.
- 33Value of type 'VNCoreMLModel' has no member 'model'
- 34Incorrect argument label in call (have 'from:', expected 'input:') I replaced fr
- 35Value of type 'NSNumber' has no member 'max'
- 36This doesn't fix "Value of type 'NSNumber' has no member 'max'"
- 37But you're still trying to access max here. This isn't going to work.
- 38prediction.Identity[0] does not have a member max! We need to change this
- 39Ok, I don't think this is going anywhere. Can we go back to using image type inp
- 40ell In[3], line 4 1 image\input = ct.ImageType(shape=(1, 300, 300, 3), scale=1/2
- 41I think this is what you want: This works. Can you show me the how to change the
- 42Ok, seems we were able to load the model. Now we get "Failed to classify image".
- 43"Failed to classify image, no results"
- 44Resized image size: (300.0, 300.0) 2023-03-29 10:34:44.760824+0300 Smart Parking
- 45It seems like we don't get to the "All classification results" print statement.
- 46Yeah the only message I get is "Failed to classify image, no results". Where sho
- 47'catch' block is unreachable because no errors are thrown in 'do' block
- 48Call can throw, but it is not marked with 'try' and the error is not handled
- 49Ok. Still no message after "Failed to classify image, no results". Must be that
- 50Before performing the classification request Failed to classify image, no result
- 51Model description: Before performing the classification request Completion handl
- 52Hm, my raw output always seems to be the same whatever image I take. Maybe the i
- User
Write an iOS app that runs a saved TensorFlow model to classify images. The app should allow you to take a photo with the iPhone camera, then show the output of the model prediction.
- Assistant