fixed a decode bug

This commit is contained in:
bssrdf
2024-02-16 14:17:00 -05:00
parent 62b0a9b9f8
commit 6064b0e28b
3 changed files with 10 additions and 7 deletions

View File

@@ -303,9 +303,14 @@ public:
continue;
std::u32string ts = decoder[t];
// 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){
// bytes.push_back(byte_decoder[c]);
// }

View File

@@ -547,7 +547,7 @@ struct PhotoMakerIDEncoder : public GGMLModule {
#define PM_LORA_GRAPH_SIZE 10240
struct PhotoMakerLoraModel : public GGMLModule {
float multiplier = 1.0f;
float multiplier = 1.f;
std::map<std::string, struct ggml_tensor*> lora_tensors;
std::vector<std::string> lora_tensors_to_be_ignored;
std::string file_path;

View File

@@ -493,14 +493,12 @@ public:
auto image_tokens = cond_stage_model.convert_token_to_id(trigger_word);
GGML_ASSERT(image_tokens.size() == 1);
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]);
GGML_ASSERT(it != tokens.end()); // prompt must have trigger word
tokens.erase(it);
return cond_stage_model.decode(tokens);
}
std::tuple<ggml_tensor*, ggml_tensor*, std::vector<bool>>
@@ -1583,7 +1581,7 @@ sd_image_t* txt2img(sd_ctx_t* sd_ctx,
t0 = ggml_time_ms();
t0 = ggml_time_ms();
auto cond_pair = sd_ctx->sd->get_learned_condition(work_ctx, prompt, clip_skip, width, height);
ggml_tensor* c = cond_pair.first;
ggml_tensor* c_vector = cond_pair.second; // [adm_in_channels, ]