Created
May 29, 2025 17:22
-
-
Save elbruno/d87c7f48a0c2715913f56c95736709d2 to your computer and use it in GitHub Desktop.
alttextgenimage-run.cs
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
#:package [email protected] | |
using OllamaSharp; | |
// set up the client | |
var uri = new Uri("http://localhost:11434"); | |
var ollama = new OllamaApiClient(uri); | |
ollama.SelectedModel = "gemma3"; | |
var chat = new Chat(ollama); | |
// read the image | |
byte[] imageBytes = File.ReadAllBytes(args[0]); | |
var imageBytesEnumerable = new List<IEnumerable<byte>> { imageBytes }; | |
// generate alt text0 | |
var message = "Generate a complete alt text description for the attached image."; | |
await foreach (var answerToken in chat.SendAsync(message: message, imagesAsBytes: imageBytesEnumerable)) | |
Console.Write(answerToken); | |
// done | |
Console.WriteLine($">> Ollama done"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment