Skip to content

Instantly share code, notes, and snippets.

@cdeil
Created October 29, 2025 19:11
Show Gist options
  • Select an option

  • Save cdeil/faecfb1c7bdc1d2d57db850c6cf29496 to your computer and use it in GitHub Desktop.

Select an option

Save cdeil/faecfb1c7bdc1d2d57db850c6cf29496 to your computer and use it in GitHub Desktop.
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