Spaces:
Running
on
Zero
Running
on
Zero
Update
Browse files
app.py
CHANGED
@@ -7,21 +7,21 @@ import spaces
|
|
7 |
from llama_cpp import Llama
|
8 |
from llama_cpp.llama_chat_format import NanoLlavaChatHandler
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
@spaces.GPU(duration=
|
12 |
def answer_question(img, prompt):
|
13 |
-
chat_handler = NanoLlavaChatHandler.from_pretrained(
|
14 |
-
repo_id="abetlen/nanollava-gguf",
|
15 |
-
filename="*mmproj*",
|
16 |
-
)
|
17 |
-
llm = Llama.from_pretrained(
|
18 |
-
repo_id="abetlen/nanollava-gguf",
|
19 |
-
filename="*text-model*",
|
20 |
-
chat_handler=chat_handler,
|
21 |
-
n_ctx=2048, # n_ctx should be increased to accommodate the image embedding
|
22 |
-
n_gpu_layers=-1,
|
23 |
-
)
|
24 |
-
|
25 |
img_bytes = BytesIO()
|
26 |
img.save(img_bytes, format='JPEG')
|
27 |
|
|
|
7 |
from llama_cpp import Llama
|
8 |
from llama_cpp.llama_chat_format import NanoLlavaChatHandler
|
9 |
|
10 |
+
chat_handler = NanoLlavaChatHandler.from_pretrained(
|
11 |
+
repo_id="abetlen/nanollava-gguf",
|
12 |
+
filename="*mmproj*",
|
13 |
+
)
|
14 |
+
llm = Llama.from_pretrained(
|
15 |
+
repo_id="abetlen/nanollava-gguf",
|
16 |
+
filename="*text-model*",
|
17 |
+
chat_handler=chat_handler,
|
18 |
+
n_ctx=2048, # n_ctx should be increased to accommodate the image embedding
|
19 |
+
n_gpu_layers=-1,
|
20 |
+
flash_attn=True,
|
21 |
+
)
|
22 |
|
23 |
+
@spaces.GPU(duration=30)
|
24 |
def answer_question(img, prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
img_bytes = BytesIO()
|
26 |
img.save(img_bytes, format='JPEG')
|
27 |
|