Update
Browse files- app.py +3 -4
- gradio_helpers.py +4 -5
- models.py +2 -3
app.py
CHANGED
@@ -161,7 +161,7 @@ def create_app():
|
|
161 |
gr.on(
|
162 |
[run.click, prompt.submit],
|
163 |
compute,
|
164 |
-
[image, prompt, model
|
165 |
[highlighted_text, image, annotated_image],
|
166 |
)
|
167 |
clear.click(
|
@@ -244,8 +244,7 @@ if __name__ == '__main__':
|
|
244 |
logging.info('environ["%s"] = %r', k, v)
|
245 |
|
246 |
gradio_helpers.set_warmup_function(warmup)
|
247 |
-
for name, (repo,
|
248 |
-
gradio_helpers.register_download(name
|
249 |
-
gradio_helpers.register_download(name + "-mmproj-f16.gguf", repo, filename + "-mmproj-f16.gguf")
|
250 |
|
251 |
create_app().queue().launch()
|
|
|
161 |
gr.on(
|
162 |
[run.click, prompt.submit],
|
163 |
compute,
|
164 |
+
[image, prompt, model, sampler],
|
165 |
[highlighted_text, image, annotated_image],
|
166 |
)
|
167 |
clear.click(
|
|
|
244 |
logging.info('environ["%s"] = %r', k, v)
|
245 |
|
246 |
gradio_helpers.set_warmup_function(warmup)
|
247 |
+
for name, (repo, filenames) in models.MODELS.items():
|
248 |
+
gradio_helpers.register_download(name, repo, filenames)
|
|
|
249 |
|
250 |
create_app().queue().launch()
|
gradio_helpers.py
CHANGED
@@ -74,7 +74,7 @@ def _do_download():
|
|
74 |
time.sleep(1)
|
75 |
continue
|
76 |
|
77 |
-
name, (repo,
|
78 |
logging.info('Downloading "%s" %s/%s/%s...', name, repo, filename, revision)
|
79 |
with timed(f'downloading {name}', True) as t:
|
80 |
if should_mock():
|
@@ -83,8 +83,7 @@ def _do_download():
|
|
83 |
_done[name] = None
|
84 |
else:
|
85 |
try:
|
86 |
-
_done[name] = huggingface_hub.hf_hub_download(
|
87 |
-
repo_id=repo, filename=filename, revision=revision)
|
88 |
except Exception as e: # pylint: disable=broad-exception-caught
|
89 |
logging.exception('Could not download "%s" from hub!', name)
|
90 |
_failed[name] = str(e)
|
@@ -109,11 +108,11 @@ def _do_download():
|
|
109 |
_scheduled.pop(name)
|
110 |
|
111 |
|
112 |
-
def register_download(name, repo,
|
113 |
"""Will cause download of `filename` from HF `repo` in background thread."""
|
114 |
with _lock:
|
115 |
if name not in _scheduled:
|
116 |
-
_scheduled[name] = (repo,
|
117 |
|
118 |
|
119 |
def _hms(secs):
|
|
|
74 |
time.sleep(1)
|
75 |
continue
|
76 |
|
77 |
+
name, (repo, filenames, revision) = next(iter(_scheduled.items()))
|
78 |
logging.info('Downloading "%s" %s/%s/%s...', name, repo, filename, revision)
|
79 |
with timed(f'downloading {name}', True) as t:
|
80 |
if should_mock():
|
|
|
83 |
_done[name] = None
|
84 |
else:
|
85 |
try:
|
86 |
+
_done[name] = (huggingface_hub.hf_hub_download(repo_id=repo, filename=filename, revision=revision) for filename in filenames)
|
|
|
87 |
except Exception as e: # pylint: disable=broad-exception-caught
|
88 |
logging.exception('Could not download "%s" from hub!', name)
|
89 |
_failed[name] = str(e)
|
|
|
108 |
_scheduled.pop(name)
|
109 |
|
110 |
|
111 |
+
def register_download(name, repo, filenames, revision='main'):
|
112 |
"""Will cause download of `filename` from HF `repo` in background thread."""
|
113 |
with _lock:
|
114 |
if name not in _scheduled:
|
115 |
+
_scheduled[name] = (repo, filenames, revision)
|
116 |
|
117 |
|
118 |
def _hms(secs):
|
models.py
CHANGED
@@ -20,7 +20,7 @@ MODELS = {
|
|
20 |
**{
|
21 |
model_name: (
|
22 |
f'{ORGANIZATION}/{repo}',
|
23 |
-
f'{model_name}',
|
24 |
)
|
25 |
for repo, model_name in BASE_MODELS
|
26 |
},
|
@@ -78,8 +78,7 @@ def generate(
|
|
78 |
# with gradio_helpers.timed('computation', start_message=True):
|
79 |
# tokens = model.predict(params, batch, sampler=sampler)
|
80 |
|
81 |
-
model_path = gradio_helpers.get_paths()[model_name
|
82 |
-
clip_path = gradio_helpers.get_paths()[model_name + "-mmproj-f16.gguf"]
|
83 |
print(model_path)
|
84 |
print(gradio_helpers.get_paths())
|
85 |
model = llama_cpp.Llama(
|
|
|
20 |
**{
|
21 |
model_name: (
|
22 |
f'{ORGANIZATION}/{repo}',
|
23 |
+
(f'{model_name}-text-model-q4_k_m.gguf', f'{model_name}-mmproj-f16.gguf'),
|
24 |
)
|
25 |
for repo, model_name in BASE_MODELS
|
26 |
},
|
|
|
78 |
# with gradio_helpers.timed('computation', start_message=True):
|
79 |
# tokens = model.predict(params, batch, sampler=sampler)
|
80 |
|
81 |
+
model_path, clip_path = gradio_helpers.get_paths()[model_name]
|
|
|
82 |
print(model_path)
|
83 |
print(gradio_helpers.get_paths())
|
84 |
model = llama_cpp.Llama(
|