|
38 | 38 |
|
39 | 39 | using json = nlohmann::ordered_json; |
40 | 40 |
|
| 41 | +std::initializer_list<enum llama_example> mmproj_examples = { |
| 42 | + LLAMA_EXAMPLE_LLAVA, |
| 43 | + // TODO: add LLAMA_EXAMPLE_SERVER when it's ready |
| 44 | +}; |
| 45 | + |
41 | 46 | common_arg & common_arg::set_examples(std::initializer_list<enum llama_example> examples) { |
42 | 47 | this->examples = std::move(examples); |
43 | 48 | return *this; |
@@ -841,14 +846,20 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context |
841 | 846 |
|
842 | 847 | // handle model and download |
843 | 848 | { |
844 | | - auto res = common_params_handle_model(params.model, params.hf_token, DEFAULT_MODEL_PATH); |
| 849 | + auto res = common_params_handle_model(params.model, params.hf_token, DEFAULT_MODEL_PATH); |
845 | 850 | if (params.no_mmproj) { |
846 | 851 | params.mmproj = {}; |
847 | 852 | } else if (res.found_mmproj && params.mmproj.path.empty() && params.mmproj.url.empty()) { |
848 | 853 | // optionally, handle mmproj model when -hf is specified |
849 | 854 | params.mmproj = res.mmproj; |
850 | 855 | } |
851 | | - common_params_handle_model(params.mmproj, params.hf_token, ""); |
| 856 | + // only download mmproj if the current example is using it |
| 857 | + for (auto & ex : mmproj_examples) { |
| 858 | + if (ctx_arg.ex == ex) { |
| 859 | + common_params_handle_model(params.mmproj, params.hf_token, ""); |
| 860 | + break; |
| 861 | + } |
| 862 | + } |
852 | 863 | common_params_handle_model(params.speculative.model, params.hf_token, ""); |
853 | 864 | common_params_handle_model(params.vocoder.model, params.hf_token, ""); |
854 | 865 | } |
@@ -2114,21 +2125,21 @@ common_params_context common_params_parser_init(common_params & params, llama_ex |
2114 | 2125 | [](common_params & params, const std::string & value) { |
2115 | 2126 | params.mmproj.path = value; |
2116 | 2127 | } |
2117 | | - ).set_examples({LLAMA_EXAMPLE_LLAVA})); |
| 2128 | + ).set_examples(mmproj_examples)); |
2118 | 2129 | add_opt(common_arg( |
2119 | 2130 | {"--mmproj-url"}, "URL", |
2120 | 2131 | "URL to a multimodal projector file. see examples/llava/README.md", |
2121 | 2132 | [](common_params & params, const std::string & value) { |
2122 | 2133 | params.mmproj.url = value; |
2123 | 2134 | } |
2124 | | - ).set_examples({LLAMA_EXAMPLE_LLAVA})); |
| 2135 | + ).set_examples(mmproj_examples)); |
2125 | 2136 | add_opt(common_arg( |
2126 | 2137 | {"--no-mmproj"}, |
2127 | 2138 | "explicitly disable multimodal projector, useful when using -hf", |
2128 | 2139 | [](common_params & params) { |
2129 | 2140 | params.no_mmproj = true; |
2130 | 2141 | } |
2131 | | - ).set_examples({LLAMA_EXAMPLE_LLAVA})); |
| 2142 | + ).set_examples(mmproj_examples)); |
2132 | 2143 | add_opt(common_arg( |
2133 | 2144 | {"--image"}, "FILE", |
2134 | 2145 | "path to an image file. use with multimodal models. Specify multiple times for batching", |
|
0 commit comments