Skip to content

Instantly share code, notes, and snippets.

@kunal732
Created December 22, 2024 23:51
Show Gist options
  • Save kunal732/94641d4b11e872f6dcc7e32e664f1d51 to your computer and use it in GitHub Desktop.
Save kunal732/94641d4b11e872f6dcc7e32e664f1d51 to your computer and use it in GitHub Desktop.
//
// ContentView.swift
// Mac-PaliGemma2
//
// Created by KUNAL BATRA on 12/22/24.
//
import SwiftUI
import MLXModelManager
struct ContentView: View {
@StateObject var manager = ModelManager(modelPath: "mlx-community/paligemma2-3b-ft-docci-448-8bit")
var body: some View {
VStack {
Button("Describe Image"){
Task {
//load model
try await manager.loadModel()
//inference
await manager.generate(
prompt: "Describe this image.",
imagePath:"/Users/kunalbatra/Downloads/classic.png"
)
}
}
Text(manager.output)
}
.padding()
}
}
#Preview {
ContentView()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment