Spaces:
Runtime error
Runtime error
ubermenchh
commited on
Commit
β’
d0ead18
1
Parent(s):
55dcb80
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ def ensure_file(filename, src):
|
|
8 |
total_size = int(response.headers.get('content-length', 0))
|
9 |
|
10 |
with open(filename, 'wb') as file:
|
11 |
-
with tqdm(total=total_size, unit='
|
12 |
for data in response.iter_content(chunk_size=1024):
|
13 |
if data:
|
14 |
file.write(data)
|
@@ -27,7 +27,7 @@ llm = Llama(model_path="ggml-model-q4_k.gguf", n_ctx=2048)
|
|
27 |
def generate(image, ins='Describe the image'):
|
28 |
if len(ins) < 1:
|
29 |
ins = 'Describe the image'
|
30 |
-
image_embed = llava_image_embed_make_with_filename(ctx_clip=ctx_clip, n_threads=1, filename=image.encode('
|
31 |
|
32 |
n_past = ctypes.c_int(llm.n_tokens)
|
33 |
n_past_p = ctypes.byref(n_past)
|
@@ -35,13 +35,13 @@ def generate(image, ins='Describe the image'):
|
|
35 |
llm.n_tokens = n_past.value
|
36 |
llava_image_embed_free(image_embed)
|
37 |
|
38 |
-
llm.eval(llm.tokenize(ins.encode('
|
39 |
|
40 |
max_target_len = 256
|
41 |
res = ''
|
42 |
for i in range(max_target_len):
|
43 |
t_id = llm.sample(temp=0.3)
|
44 |
-
t = llm.detokenize([t_id]).decode('
|
45 |
if t == '</s>':
|
46 |
break
|
47 |
res += t
|
|
|
8 |
total_size = int(response.headers.get('content-length', 0))
|
9 |
|
10 |
with open(filename, 'wb') as file:
|
11 |
+
with tqdm(total=total_size, unit='B', unit_scale=True, desc=filename, ncols=80) as progress_bar:
|
12 |
for data in response.iter_content(chunk_size=1024):
|
13 |
if data:
|
14 |
file.write(data)
|
|
|
27 |
def generate(image, ins='Describe the image'):
|
28 |
if len(ins) < 1:
|
29 |
ins = 'Describe the image'
|
30 |
+
image_embed = llava_image_embed_make_with_filename(ctx_clip=ctx_clip, n_threads=1, filename=image.encode('utf8'))
|
31 |
|
32 |
n_past = ctypes.c_int(llm.n_tokens)
|
33 |
n_past_p = ctypes.byref(n_past)
|
|
|
35 |
llm.n_tokens = n_past.value
|
36 |
llava_image_embed_free(image_embed)
|
37 |
|
38 |
+
llm.eval(llm.tokenize(ins.encode('utf8')))
|
39 |
|
40 |
max_target_len = 256
|
41 |
res = ''
|
42 |
for i in range(max_target_len):
|
43 |
t_id = llm.sample(temp=0.3)
|
44 |
+
t = llm.detokenize([t_id]).decode('utf8')
|
45 |
if t == '</s>':
|
46 |
break
|
47 |
res += t
|