diff --git a/requirements.txt b/requirements.txt index 8dec427..867cabf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ timm==1.0.3 numpy==1.26.4 huggingface_hub==0.23.1 einops==0.8.0 -transformers==4.41.1 \ No newline at end of file +transformers==4.41.1 +open_clip_torch==2.24.0 \ No newline at end of file diff --git a/rshf/bioclip/__init__.py b/rshf/bioclip/__init__.py new file mode 100644 index 0000000..590c969 --- /dev/null +++ b/rshf/bioclip/__init__.py @@ -0,0 +1 @@ +from .model import BioCLIP \ No newline at end of file diff --git a/rshf/bioclip/model.py b/rshf/bioclip/model.py new file mode 100644 index 0000000..e199520 --- /dev/null +++ b/rshf/bioclip/model.py @@ -0,0 +1,9 @@ +import open_clip +import torch.nn as nn +from huggingface_hub import PyTorchModelHubMixin + +class BioCLIP(nn.Module, PyTorchModelHubMixin): + def __init__(self, model_name="hf-hub:imageomics/bioclip"): + super().__init__() + self.model, _, self.preprocess = open_clip.create_model_and_transforms(model_name) + self.tokenizer = open_clip.get_tokenizer(model_name) \ No newline at end of file diff --git a/rshf/clip/__init__.py b/rshf/clip/__init__.py new file mode 100644 index 0000000..9681527 --- /dev/null +++ b/rshf/clip/__init__.py @@ -0,0 +1 @@ +from transformers import CLIPProcessor, CLIPModel, CLIPTextModel, CLIPVisionModel \ No newline at end of file diff --git a/rshf/remoteclip/__init__.py b/rshf/remoteclip/__init__.py new file mode 100644 index 0000000..9193c5c --- /dev/null +++ b/rshf/remoteclip/__init__.py @@ -0,0 +1 @@ +from .model import RemoteCLIP \ No newline at end of file diff --git a/rshf/remoteclip/model.py b/rshf/remoteclip/model.py new file mode 100644 index 0000000..4d78504 --- /dev/null +++ b/rshf/remoteclip/model.py @@ -0,0 +1,9 @@ +import open_clip +import torch.nn as nn +from huggingface_hub import PyTorchModelHubMixin + +class RemoteCLIP(nn.Module, PyTorchModelHubMixin): + def __init__(self, model_name="ViT-B-32"): + super().__init__() + self.model, _, self.preprocess = open_clip.create_model_and_transforms(model_name) + self.tokenizer = open_clip.get_tokenizer(model_name) \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 5991441..4c77758 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = rshf -version = 0.0.4 +version = 0.0.5 author = Srikumar Sastry author_email = s.sastry@wustl.edu description = RS pretrained models in huggingface style