Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop lx #36

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/tokenizers/Unigram/trie.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class TrieIterator {
node = next->second;
path.push_back(*iter);
if (node->is_leaf) {
iter++;
++iter;
return path;
}
}
iter++;
++iter;
}
return {};

Expand Down
15 changes: 12 additions & 3 deletions test/preprocess/UnigramTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ TEST_F(TokenizerTest, test) {
tokenizer->setSpecialToken("|ENDOFTEXT|");
std::string text = "Hello world";
// normalization text
// replace all " " to "_"
std::replace(text.begin(), text.end(), ' ', '_');
// replace all " " to "▁"
std::string text_ = "";
for (auto &ch : text) {
if (ch == ' ') {
text_ += "";
}else {
text_ += ch;
}

}
// std::replace(text.begin(), text.end(), ' ', L'▁');
// prepend "_" to text
std::string new_text = "_" + std::string(text);
std::string new_text = "" + std::string(text_);

tokenizer->tokenize(new_text, ids, true);
for (auto id : ids) {
Expand Down
10 changes: 5 additions & 5 deletions test/preprocess/fuyu_process_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

model_id = "adept/fuyu-8b"
processor = FuyuProcessor.from_pretrained(model_id)
text_prompt = "Generate a coco-style caption.\n"
text_prompt = "Hello world"
url = "https://huggingface.co/adept/fuyu-8b/resolve/main/bus.png"
image = Image.open(requests.get(url, stream=True).raw)
with open("bus.tmp", "wb") as f:
f.write(image.tobytes())
inputs = processor(text=text_prompt, images=image, return_tensors="pt")
# image = Image.open(requests.get(url, stream=True).raw)
# with open("bus.tmp", "wb") as f:
# f.write(image.tobytes())
inputs = processor(text=text_prompt, return_tensors="pt")
print(inputs)
Loading