Created
October 29, 2025 19:11
-
-
Save cdeil/faecfb1c7bdc1d2d57db850c6cf29496 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import YOLO | |
| struct StocadroYOLOView: View { | |
| @State private var inputImage: UIImage = UIImage(named: "bus") ?? UIImage() | |
| @State private var isYoloLoading: Bool = true; | |
| @State private var yoloResult: YOLOResult? | |
| let yolo = YOLO("yolo11n", task: .detect) | |
| var body: some View { | |
| print("Running StocadroYOLOView.body") | |
| return VStack { | |
| Text("YOLO view") | |
| .font(.title) | |
| .padding() | |
| Spacer() | |
| Image(uiImage: inputImage) | |
| .resizable() | |
| .scaledToFit() | |
| .frame(height: 700) | |
| Spacer() | |
| Button("Predict!") { | |
| print("Button callback") | |
| do { | |
| yoloResult = try yolo(inputImage) | |
| debugPrint(yoloResult as Any) | |
| } catch { | |
| print("Error: \(error)") | |
| } | |
| } | |
| } | |
| .onAppear { | |
| print("Running StocadroYOLOView.onAppear") | |
| // print(inputImage) | |
| // let ciImage = CIImage(image: inputImage)! | |
| // print(ciImage) | |
| // let orientedImage = getCorrectOrientationUIImage( | |
| // uiImage: inputImage | |
| // ) | |
| // print(orientedImage) | |
| // yoloResult = yolo(orientedImage) | |
| // | |
| // yoloResult = yolo.callAsFunction( | |
| // inputImage, | |
| // returnAnnotatedImage: true | |
| // ) | |
| // debugPrint(yoloResult ?? "No results") | |
| // debugPrint(yoloResult) | |
| // debugPrint(yoloResult?.boxes) | |
| } | |
| } | |
| } | |
| #Preview { | |
| StocadroYOLOView() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment