Spaces:
Running
Running
keep model in ram and reduce jpg quality
Browse files
app.py
CHANGED
@@ -95,7 +95,8 @@ def update_llm(size, model_file, clip_file, verbose_mode, n_threads):
|
|
95 |
chat_handler=handler,
|
96 |
n_ctx=512,
|
97 |
verbose=verbose_mode,
|
98 |
-
n_threads=n_threads
|
|
|
99 |
)
|
100 |
model_cache.update({'size': size, 'model_file': mf, 'clip_file': cf, 'verbose': verbose_mode, 'n_threads': n_threads, 'llm': llm})
|
101 |
return None
|
@@ -133,7 +134,7 @@ def caption_frame(frame, size, model_file, clip_file, interval_ms, sys_prompt, u
|
|
133 |
time.sleep(interval_ms / 1000)
|
134 |
|
135 |
t_enc = time.time()
|
136 |
-
params = [int(cv2.IMWRITE_JPEG_QUALITY),
|
137 |
success, jpeg = cv2.imencode('.jpg', img, params)
|
138 |
elapsed = (time.time() - t_enc) * 1000
|
139 |
timestamp = time.strftime('%H:%M:%S')
|
|
|
95 |
chat_handler=handler,
|
96 |
n_ctx=512,
|
97 |
verbose=verbose_mode,
|
98 |
+
n_threads=n_threads,
|
99 |
+
use_mlock=True,
|
100 |
)
|
101 |
model_cache.update({'size': size, 'model_file': mf, 'clip_file': cf, 'verbose': verbose_mode, 'n_threads': n_threads, 'llm': llm})
|
102 |
return None
|
|
|
134 |
time.sleep(interval_ms / 1000)
|
135 |
|
136 |
t_enc = time.time()
|
137 |
+
params = [int(cv2.IMWRITE_JPEG_QUALITY), 25]
|
138 |
success, jpeg = cv2.imencode('.jpg', img, params)
|
139 |
elapsed = (time.time() - t_enc) * 1000
|
140 |
timestamp = time.strftime('%H:%M:%S')
|