Skip to content

Commit

Permalink
Refactor, cleanup, fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
yonigozlan committed Nov 14, 2024
1 parent 8c8c882 commit 93b1d19
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 737 deletions.
2 changes: 1 addition & 1 deletion docs/source/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Flax), PyTorch, and/or TensorFlow.
| [GIT](model_doc/git) ||||
| [GLM](model_doc/glm) ||||
| [GLPN](model_doc/glpn) ||||
| [GOT-OCR2](model_doc/got-ocr2) ||||
| [GOT-OCR2](model_doc/got_ocr2) ||||
| [GPT Neo](model_doc/gpt_neo) ||||
| [GPT NeoX](model_doc/gpt_neox) ||||
| [GPT NeoX Japanese](model_doc/gpt_neox_japanese) ||||
Expand Down
9 changes: 2 additions & 7 deletions docs/source/en/model_doc/got-ocr2.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@ The original code can be found [here](<INSERT LINK TO GITHUB REPO HERE>).

[[autodoc]] GotOcr2Config

## GotOcr2Tokenizer
## Qwen2VLProcessor

[[autodoc]] GotOcr2Tokenizer
- save_vocabulary

## GotOcr2TokenizerFast

[[autodoc]] GotOcr2TokenizerFast
[[autodoc]] Qwen2VLProcessor

## GotOcr2Model

Expand Down
6 changes: 2 additions & 4 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,8 @@
],
"models.got_ocr2": [
"GotOcr2Config",
"GotOcr2Processor",
"GotOcr2VisionConfig",
"GotOcr2Tokenizer",
],
"models.qwen2_audio": [
"Qwen2AudioConfig",
Expand Down Expand Up @@ -1107,7 +1107,6 @@
_import_structure["models.openai"].append("OpenAIGPTTokenizerFast")
_import_structure["models.pegasus"].append("PegasusTokenizerFast")
_import_structure["models.qwen2"].append("Qwen2TokenizerFast")
_import_structure["models.got_ocr2"].append("GotOcr2TokenizerFast")
_import_structure["models.reformer"].append("ReformerTokenizerFast")
_import_structure["models.rembert"].append("RemBertTokenizerFast")
_import_structure["models.roberta"].append("RobertaTokenizerFast")
Expand Down Expand Up @@ -5335,7 +5334,7 @@
)
from .models.glm import GlmConfig
from .models.glpn import GLPNConfig
from .models.got_ocr2 import GotOcr2Config, GotOcr2Tokenizer, GotOcr2VisionConfig
from .models.got_ocr2 import GotOcr2Config, GotOcr2Processor, GotOcr2VisionConfig
from .models.gpt2 import (
GPT2Config,
GPT2Tokenizer,
Expand Down Expand Up @@ -6012,7 +6011,6 @@
from .models.fnet import FNetTokenizerFast
from .models.funnel import FunnelTokenizerFast
from .models.gemma import GemmaTokenizerFast
from .models.got_ocr2 import GotOcr2TokenizerFast
from .models.gpt2 import GPT2TokenizerFast
from .models.gpt_neox import GPTNeoXTokenizerFast
from .models.gpt_neox_japanese import GPTNeoXJapaneseTokenizer
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/models/auto/configuration_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
("git", "GitConfig"),
("glm", "GlmConfig"),
("glpn", "GLPNConfig"),
("got-ocr2", "GotOcr2Config"),
("got_ocr2", "GotOcr2Config"),
("gpt-sw3", "GPT2Config"),
("gpt2", "GPT2Config"),
("gpt_bigcode", "GPTBigCodeConfig"),
Expand Down Expand Up @@ -420,7 +420,7 @@
("git", "GIT"),
("glm", "GLM"),
("glpn", "GLPN"),
("got-ocr2", "GOT-OCR2"),
("got_ocr2", "GOT-OCR2"),
("gpt-sw3", "GPT-Sw3"),
("gpt2", "OpenAI GPT-2"),
("gpt_bigcode", "GPTBigCode"),
Expand Down
5 changes: 3 additions & 2 deletions src/transformers/models/auto/modeling_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
("git", "GitModel"),
("glm", "GlmModel"),
("glpn", "GLPNModel"),
("got-ocr2", "GotOcr2Model"),
("got_ocr2", "GotOcr2Model"),
("gpt-sw3", "GPT2Model"),
("gpt2", "GPT2Model"),
("gpt_bigcode", "GPTBigCodeModel"),
Expand Down Expand Up @@ -489,7 +489,7 @@
("gemma2", "Gemma2ForCausalLM"),
("git", "GitForCausalLM"),
("glm", "GlmForCausalLM"),
("got-ocr2", "GotOcr2ForConditionalGeneration"),
("got_ocr2", "GotOcr2ForConditionalGeneration"),
("gpt-sw3", "GPT2LMHeadModel"),
("gpt2", "GPT2LMHeadModel"),
("gpt_bigcode", "GPTBigCodeForCausalLM"),
Expand Down Expand Up @@ -770,6 +770,7 @@
("chameleon", "ChameleonForConditionalGeneration"),
("fuyu", "FuyuForCausalLM"),
("git", "GitForCausalLM"),
("got_ocr2", "GotOcr2ForConditionalGeneration"),
("idefics", "IdeficsForVisionText2Text"),
("idefics2", "Idefics2ForConditionalGeneration"),
("idefics3", "Idefics3ForConditionalGeneration"),
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/auto/processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
("flava", "FlavaProcessor"),
("fuyu", "FuyuProcessor"),
("git", "GitProcessor"),
("got_ocr2", "GotOcr2Processor"),
("grounding-dino", "GroundingDinoProcessor"),
("groupvit", "CLIPProcessor"),
("hubert", "Wav2Vec2Processor"),
Expand Down
7 changes: 0 additions & 7 deletions src/transformers/models/auto/tokenization_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,6 @@
),
("git", ("BertTokenizer", "BertTokenizerFast" if is_tokenizers_available() else None)),
("glm", (None, "PreTrainedTokenizerFast" if is_tokenizers_available() else None)),
(
"got-ocr2",
(
"GotOcr2Tokenizer",
"GotOcr2TokenizerFast" if is_tokenizers_available() else None,
),
),
("gpt-sw3", ("GPTSw3Tokenizer" if is_sentencepiece_available() else None, None)),
("gpt2", ("GPT2Tokenizer", "GPT2TokenizerFast" if is_tokenizers_available() else None)),
("gpt_bigcode", ("GPT2Tokenizer", "GPT2TokenizerFast" if is_tokenizers_available() else None)),
Expand Down
20 changes: 2 additions & 18 deletions src/transformers/models/got_ocr2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,9 @@

_import_structure = {
"configuration_got_ocr2": ["GotOcr2Config", "GotOcr2VisionConfig"],
"tokenization_got_ocr2": ["GotOcr2Tokenizer"],
"processing_got_ocr2": ["GotOcr2Processor"],
}

try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_got_ocr2_fast"] = ["GotOcr2TokenizerFast"]

try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
Expand All @@ -49,15 +41,7 @@

if TYPE_CHECKING:
from .configuration_got_ocr2 import GotOcr2Config, GotOcr2VisionConfig
from .tokenization_got_ocr2 import GotOcr2Tokenizer

try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_got_ocr2_fast import GotOcr2TokenizerFast
from .processing_got_ocr2 import GotOcr2Processor

try:
if not is_torch_available():
Expand Down
Loading

0 comments on commit 93b1d19

Please sign in to comment.