fixed a decode bug

This commit is contained in:
bssrdf committed 2024-02-16 14:17:00 -05:00
1 parent 62b0a9b9f8
commit 6064b0e28b
3 files changed
+8 -5

No files matched your search

+7 -2
View File
@@ -303,9 +303,14 @@ public:
continue; continue;
std::u32string ts = decoder[t]; std::u32string ts = decoder[t];
// printf("%d, %s \n", t, utf32_to_utf8(ts).c_str()); // printf("%d, %s \n", t, utf32_to_utf8(ts).c_str());
text += " "+utf32_to_utf8(ts).replace(ts.length()-4, ts.length()-1, "") ; std::string s = utf32_to_utf8(ts);
if(s.length() >= 4 && ends_with(s, "</w>")){
text += " "+s.replace(s.length()-4, s.length()-1, "") ;
}else{
text += " "+s;
} }
std::vector<unsigned char> bytes; }
// std::vector<unsigned char> bytes;
// for (auto c : text){ // for (auto c : text){
// bytes.push_back(byte_decoder[c]); // bytes.push_back(byte_decoder[c]);
// } // }
+1 -1
View File
@@ -547,7 +547,7 @@ struct PhotoMakerIDEncoder : public GGMLModule {
#define PM_LORA_GRAPH_SIZE 10240 #define PM_LORA_GRAPH_SIZE 10240
struct PhotoMakerLoraModel : public GGMLModule { struct PhotoMakerLoraModel : public GGMLModule {
float multiplier = 1.0f; float multiplier = 1.f;
std::map<std::string, struct ggml_tensor*> lora_tensors; std::map<std::string, struct ggml_tensor*> lora_tensors;
std::vector<std::string> lora_tensors_to_be_ignored; std::vector<std::string> lora_tensors_to_be_ignored;
std::string file_path; std::string file_path;
-2
View File
@@ -493,14 +493,12 @@ public:
auto image_tokens = cond_stage_model.convert_token_to_id(trigger_word); auto image_tokens = cond_stage_model.convert_token_to_id(trigger_word);
GGML_ASSERT(image_tokens.size() == 1); GGML_ASSERT(image_tokens.size() == 1);
auto tokens_and_weights = cond_stage_model.tokenize(prompt, false); auto tokens_and_weights = cond_stage_model.tokenize(prompt, false);
std::vector<int> &tokens = tokens_and_weights.first; std::vector<int> &tokens = tokens_and_weights.first;
auto it = std::find(tokens.begin(), tokens.end(), image_tokens[0]); auto it = std::find(tokens.begin(), tokens.end(), image_tokens[0]);
GGML_ASSERT(it != tokens.end()); // prompt must have trigger word GGML_ASSERT(it != tokens.end()); // prompt must have trigger word
tokens.erase(it); tokens.erase(it);
return cond_stage_model.decode(tokens); return cond_stage_model.decode(tokens);
} }
std::tuple<ggml_tensor*, ggml_tensor*, std::vector<bool>> std::tuple<ggml_tensor*, ggml_tensor*, std::vector<bool>>