2024-09-16 22:58:55 +00:00
|
|
|
From ae2b188a679c83ce105aa1e823499441dfab3c57 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Michael Yang <mxyng@pm.me>
|
|
|
|
Date: Mon, 16 Sep 2024 15:53:15 -0700
|
|
|
|
Subject: [PATCH] 07-clip-unicode.diff
|
|
|
|
|
|
|
|
---
|
|
|
|
examples/llava/clip.cpp | 23 +++++++++++++++++++++++
|
|
|
|
1 file changed, 23 insertions(+)
|
|
|
|
|
2024-07-03 19:37:40 +00:00
|
|
|
diff --git a/examples/llava/clip.cpp b/examples/llava/clip.cpp
|
2024-09-16 22:58:55 +00:00
|
|
|
index cb51793d..8716472b 100644
|
2024-07-03 19:37:40 +00:00
|
|
|
--- a/examples/llava/clip.cpp
|
|
|
|
+++ b/examples/llava/clip.cpp
|
2024-09-16 22:58:55 +00:00
|
|
|
@@ -41,6 +41,14 @@
|
2024-07-03 19:37:40 +00:00
|
|
|
#include <cinttypes>
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
+#if defined(_WIN32)
|
|
|
|
+#define WIN32_LEAN_AND_MEAN
|
|
|
|
+#ifndef NOMINMAX
|
|
|
|
+ #define NOMINMAX
|
|
|
|
+#endif
|
|
|
|
+#include <windows.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
//#define CLIP_DEBUG_FUNCTIONS
|
|
|
|
|
|
|
|
// RGB uint8 image
|
2024-09-16 22:58:55 +00:00
|
|
|
@@ -1223,7 +1231,22 @@ struct clip_ctx * clip_model_load(const char * fname, const int verbosity = 1) {
|
2024-07-03 19:37:40 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef _WIN32
|
|
|
|
+ int wlen = MultiByteToWideChar(CP_UTF8, 0, fname, -1, NULL, 0);
|
|
|
|
+ if (!wlen) {
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+ wchar_t * wbuf = (wchar_t *) malloc(wlen * sizeof(wchar_t));
|
|
|
|
+ wlen = MultiByteToWideChar(CP_UTF8, 0, fname, -1, wbuf, wlen);
|
|
|
|
+ if (!wlen) {
|
|
|
|
+ free(wbuf);
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+ auto fin = std::ifstream(wbuf, std::ios::binary);
|
|
|
|
+ free(wbuf);
|
|
|
|
+#else
|
|
|
|
auto fin = std::ifstream(fname, std::ios::binary);
|
|
|
|
+#endif
|
|
|
|
if (!fin) {
|
|
|
|
LOG_TEE("cannot open model file for loading tensors\n");
|
|
|
|
clip_free(new_clip);
|
2024-09-16 22:58:55 +00:00
|
|
|
--
|
|
|
|
2.46.0
|
|
|
|
|