Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,8 @@ import os
|
|
| 5 |
from huggingface_hub import hf_hub_download
|
| 6 |
import base64
|
| 7 |
from llama_cpp import Llama
|
| 8 |
-
from llama_cpp.
|
|
|
|
| 9 |
|
| 10 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
| 11 |
MODEL_LIST = ["openbmb/MiniCPM-Llama3-V-2_5","openbmb/MiniCPM-Llama3-V-2_5-int4"]
|
|
@@ -26,19 +27,34 @@ CSS = """
|
|
| 26 |
}
|
| 27 |
"""
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
llm = Llama.from_pretrained(
|
| 35 |
repo_id="openbmb/MiniCPM-Llama3-V-2_5-gguf",
|
| 36 |
-
filename="ggml-model-Q5_K_M.gguf",
|
| 37 |
-
tokenizer=tokenizer,
|
| 38 |
n_ctx=4096,
|
| 39 |
verbose=True
|
| 40 |
)
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
def image_to_base64_data_uri(file_path):
|
| 43 |
with open(file_path, "rb") as img_file:
|
| 44 |
base64_data = base64.b64encode(img_file.read()).decode('utf-8')
|
|
|
|
| 5 |
from huggingface_hub import hf_hub_download
|
| 6 |
import base64
|
| 7 |
from llama_cpp import Llama
|
| 8 |
+
# from llama_cpp.llama_chat_format import Llava15ChatHandler
|
| 9 |
+
# from llama_cpp.llama_tokenizer import LlamaHFTokenizer
|
| 10 |
|
| 11 |
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
|
| 12 |
MODEL_LIST = ["openbmb/MiniCPM-Llama3-V-2_5","openbmb/MiniCPM-Llama3-V-2_5-int4"]
|
|
|
|
| 27 |
}
|
| 28 |
"""
|
| 29 |
|
| 30 |
+
# chat_handler = Llava15ChatHandler.from_pretrained(
|
| 31 |
+
# repo_id="openbmb/MiniCPM-Llama3-V-2_5-gguf",
|
| 32 |
+
# filename="*mmproj*",
|
| 33 |
+
|
| 34 |
+
# )
|
| 35 |
|
| 36 |
llm = Llama.from_pretrained(
|
| 37 |
repo_id="openbmb/MiniCPM-Llama3-V-2_5-gguf",
|
| 38 |
+
filename=["ggml-model-Q5_K_M.gguf","*mmproj*"],
|
|
|
|
| 39 |
n_ctx=4096,
|
| 40 |
verbose=True
|
| 41 |
)
|
| 42 |
|
| 43 |
+
'''
|
| 44 |
+
filenames = [
|
| 45 |
+
"*mmproj*",
|
| 46 |
+
"ggml-model-Q5_K_M.gguf"
|
| 47 |
+
]
|
| 48 |
+
|
| 49 |
+
for filename in filenames:
|
| 50 |
+
downloaded_model_path = hf_hub_download(
|
| 51 |
+
repo_id="openbmb/MiniCPM-Llama3-V-2_5-gguf",
|
| 52 |
+
filename=filename,
|
| 53 |
+
local_dir="model"
|
| 54 |
+
)
|
| 55 |
+
'''
|
| 56 |
+
|
| 57 |
+
|
| 58 |
def image_to_base64_data_uri(file_path):
|
| 59 |
with open(file_path, "rb") as img_file:
|
| 60 |
base64_data = base64.b64encode(img_file.read()).decode('utf-8')
|