forked from haotian-liu/LLaVA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Support for S^2 (haotian-liu#1376)
* add support for s2 * conditional import and exception handling on import error
- Loading branch information
Showing
2 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import os | ||
from .clip_encoder import CLIPVisionTower | ||
from .clip_encoder import CLIPVisionTower, CLIPVisionTowerS2 | ||
|
||
|
||
def build_vision_tower(vision_tower_cfg, **kwargs): | ||
vision_tower = getattr(vision_tower_cfg, 'mm_vision_tower', getattr(vision_tower_cfg, 'vision_tower', None)) | ||
is_absolute_path_exists = os.path.exists(vision_tower) | ||
use_s2 = getattr(vision_tower_cfg, 's2', False) | ||
if is_absolute_path_exists or vision_tower.startswith("openai") or vision_tower.startswith("laion") or "ShareGPT4V" in vision_tower: | ||
return CLIPVisionTower(vision_tower, args=vision_tower_cfg, **kwargs) | ||
if use_s2: | ||
return CLIPVisionTowerS2(vision_tower, args=vision_tower_cfg, **kwargs) | ||
else: | ||
return CLIPVisionTower(vision_tower, args=vision_tower_cfg, **kwargs) | ||
|
||
raise ValueError(f'Unknown vision tower: {vision_tower}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters