add google gemma-4-e2b and gemma-4-e4b support

- add to prompt enhance models, img2img, and models_cls
- add to vlm/caption models
- update _load_gemma class selection for gemma 4
- bump transformers pin to 5.5.0.dev for gemma4 architecture support
This commit is contained in:
CalamitousFelicitousness
2026-04-09 03:21:50 +01:00
parent 13fcbd1112
commit 0e5d351099
4 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -513,7 +513,7 @@ def check_transformers():
pkg_tokenizers = package_spec('tokenizers')
# target_commit = '753d61104116eefc8ffc977327b441ee0c8d599f' # transformers commit hash == 4.57.6
# target_commit = "aad13b87ed59f2afcfaebc985f403301887a35fc" # transformers commit hash == 5.3.0
target_commit = "2dba8e0495974930af02274d75bd182d22cc1686" # transformers commit hash == 5.3.0.dev-0331
target_commit = "380e3cc5d59912a48508cb6d4959a31cd460e12e" # transformers commit hash == 5.5.0.dev-0409
if args.use_directml:
target_transformers = '4.52.4'
target_tokenizers = '0.21.4'
+2
View File
@@ -5,6 +5,8 @@ vlm_models = {
"Google Gemma 3 4B": "google/gemma-3-4b-it",
"Google Gemma 3n E2B": "google/gemma-3n-E2B-it", # 1.5GB
"Google Gemma 3n E4B": "google/gemma-3n-E4B-it", # 1.5GB
"Google Gemma 4 E2B": "google/gemma-4-E2B-it",
"Google Gemma 4 E4B": "google/gemma-4-E4B-it",
"Nidum Gemma 3 4B Uncensored": "nidum/Nidum-Gemma-3-4B-it-Uncensored",
"Allura Gemma 3 Glitter 4B": "allura-org/Gemma-3-Glitter-4B",
# Qwen3.5
+4 -2
View File
@@ -619,11 +619,13 @@ class VQA:
return response
def _load_gemma(self, repo: str):
"""Load Gemma 3 model and processor."""
"""Load Gemma model and processor."""
if self.model is None or self.loaded != repo:
log.debug(f'Caption load: vlm="{repo}"')
self._unload_current()
if '3n' in repo:
if 'gemma-4' in repo.lower():
cls = transformers.Gemma4ForConditionalGeneration
elif '3n' in repo:
cls = transformers.Gemma3nForConditionalGeneration # pylint: disable=no-member
else:
cls = transformers.Gemma3ForConditionalGeneration
+5
View File
@@ -109,6 +109,8 @@ class Options:
'google/gemma-3-4b-it',
'google/gemma-3n-E2B-it',
'google/gemma-3n-E4B-it',
'google/gemma-4-E2B-it',
'google/gemma-4-E4B-it',
# Gemma Finetunes
'nidum/Nidum-Gemma-3-4B-it-Uncensored',
'allura-org/Gemma-3-Glitter-4B',
@@ -173,6 +175,8 @@ class Options:
'google/gemma-3-4b-it': {},
'google/gemma-3n-E2B-it': {},
'google/gemma-3n-E4B-it': {},
'google/gemma-4-E2B-it': {},
'google/gemma-4-E4B-it': {},
# Gemma Finetunes
'nidum/Nidum-Gemma-3-4B-it-Uncensored': {},
'allura-org/Gemma-3-Glitter-4B': {},
@@ -267,6 +271,7 @@ class Options:
'qwen2_5_vl': 'Qwen2_5_VLForConditionalGeneration',
'qwen2_vl': 'Qwen2VLForConditionalGeneration',
'mistral3': 'Mistral3ForConditionalGeneration',
'gemma4': 'Gemma4ForConditionalGeneration',
}
# default = list(models)[1] # gemma-3-4b-it