You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

LLavaWeights.cs 1.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using LLama.Native;
  3. namespace LLama;
  4. public sealed class LLavaWeights : IDisposable
  5. {
  6. public SafeLlavaModelHandle NativeHandle { get; }
  7. internal LLavaWeights(SafeLlavaModelHandle weights)
  8. {
  9. NativeHandle = weights;
  10. }
  11. public static LLavaWeights LoadFromFile(string mmProject)
  12. {
  13. var weights = SafeLlavaModelHandle.LoadFromFile(mmProject, 1);
  14. return new LLavaWeights(weights);
  15. }
  16. /// <summary>
  17. /// Embed the image from file into llama context
  18. /// </summary>
  19. /// <param name="ctxLlama"></param>
  20. /// <param name="Image"></param>
  21. /// <param name="n_past"></param>
  22. /// <returns></returns>
  23. public bool EmbedImage(LLamaContext ctxLlama, string Image, ref int n_past )
  24. {
  25. return NativeHandle.EmbedImage(ctxLlama, Image, ref n_past );
  26. }
  27. /// <summary>
  28. /// Embed the image from binary into llama context.
  29. /// </summary>
  30. /// <param name="ctxLlama"></param>
  31. /// <param name="Image"></param>
  32. /// <param name="n_past"></param>
  33. /// <returns></returns>
  34. public bool EmbedImage(LLamaContext ctxLlama, Byte[] Image, ref int n_past )
  35. {
  36. return NativeHandle.EmbedImage(ctxLlama, Image, ref n_past );
  37. }
  38. public void Dispose()
  39. {
  40. NativeHandle.Dispose();
  41. }
  42. }