Skip to content

Commit

Permalink
Merge pull request pharmapsychotic#4 from justindujardin/main
Browse files Browse the repository at this point in the history
Bring over library packaging from justindujardin
  • Loading branch information
pharmapsychotic authored Jan 4, 2023
2 parents 84fb552 + f081d1b commit be1a472
Show file tree
Hide file tree
Showing 37 changed files with 90 additions and 34 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env/
build/
blip.egg-info/
dist/
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: build",
"type": "python",
"request": "launch",
"program": "setup.py",
"justMyCode": true,
"args": [
"sdist",
"bdist_wheel"
]
}
]
}
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include blip/configs/*.*
requirements.txt
requirements-dev.txt
README.md
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added blip/models/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions models/blip.py → blip/models/blip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import warnings
warnings.filterwarnings("ignore")

from models.vit import VisionTransformer, interpolate_pos_embed
from models.med import BertConfig, BertModel, BertLMHeadModel
from .vit import VisionTransformer, interpolate_pos_embed
from .med import BertConfig, BertModel, BertLMHeadModel
from transformers import BertTokenizer

import torch
Expand Down
4 changes: 2 additions & 2 deletions models/blip_itm.py → blip/models/blip_itm.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from models.med import BertConfig, BertModel
from .med import BertConfig, BertModel
from transformers import BertTokenizer

import torch
from torch import nn
import torch.nn.functional as F

from models.blip import create_vit, init_tokenizer, load_checkpoint
from .blip import create_vit, init_tokenizer, load_checkpoint

class BLIP_ITM(nn.Module):
def __init__(self,
Expand Down
8 changes: 4 additions & 4 deletions models/blip_nlvr.py → blip/models/blip_nlvr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from models.med import BertConfig
from models.nlvr_encoder import BertModel
from models.vit import interpolate_pos_embed
from models.blip import create_vit, init_tokenizer, is_url
from .med import BertConfig
from .nlvr_encoder import BertModel
from .vit import interpolate_pos_embed
from .blip import create_vit, init_tokenizer, is_url

from timm.models.hub import download_cached_file

Expand Down
4 changes: 2 additions & 2 deletions models/blip_pretrain.py → blip/models/blip_pretrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
from models.med import BertConfig, BertModel, BertLMHeadModel
from .med import BertConfig, BertModel, BertLMHeadModel
from transformers import BertTokenizer
import transformers
transformers.logging.set_verbosity_error()
Expand All @@ -14,7 +14,7 @@
from torch import nn
import torch.nn.functional as F

from models.blip import create_vit, init_tokenizer, load_checkpoint
from .blip import create_vit, init_tokenizer, load_checkpoint

class BLIP_Pretrain(nn.Module):
def __init__(self,
Expand Down
4 changes: 2 additions & 2 deletions models/blip_retrieval.py → blip/models/blip_retrieval.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from models.med import BertConfig, BertModel
from .med import BertConfig, BertModel
from transformers import BertTokenizer

import torch
from torch import nn
import torch.nn.functional as F

from models.blip import create_vit, init_tokenizer, load_checkpoint
from .blip import create_vit, init_tokenizer, load_checkpoint

class BLIP_Retrieval(nn.Module):
def __init__(self,
Expand Down
4 changes: 2 additions & 2 deletions models/blip_vqa.py → blip/models/blip_vqa.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from models.med import BertConfig, BertModel, BertLMHeadModel
from models.blip import create_vit, init_tokenizer, load_checkpoint
from .med import BertConfig, BertModel, BertLMHeadModel
from .blip import create_vit, init_tokenizer, load_checkpoint

import torch
from torch import nn
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
timm==0.4.12
transformers==4.15.0
transformers>=4.15.0
fairscale==0.4.4
pycocoevalcap
66 changes: 47 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,49 @@
import os

import pkg_resources
from pathlib import Path
from setuptools import setup, find_packages

setup(
name="blip",
py_modules=["blip"],
version="1.0",
description="",
author="salesforce",
packages=find_packages(exclude=["tests*"]),
install_requires=[
str(r)
for r in pkg_resources.parse_requirements(
open(os.path.join(os.path.dirname(__file__), "requirements.txt"))
)
],
include_package_data=True,
extras_require={'dev': ['pytest']},
)

def setup_package():

package_name = "blip"
root = Path(__file__).parent.resolve()
print("roo", root)

with open(root / "README.md", "r") as fh:
long_description = fh.read()

with open(root / "requirements.txt") as file:
REQUIRED_MODULES = [line.strip() for line in file]

with open(root / "requirements-dev.txt") as file:
DEVELOPMENT_MODULES = [line.strip()
for line in file if "-e" not in line]

extras = {"dev": DEVELOPMENT_MODULES}
extras["all"] = [item for group in extras.values() for item in group]

setup(
name=package_name,
description="",
author="salesforce",
author_email="",
url="",
version="",
license="",
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=REQUIRED_MODULES,
packages=find_packages(),
extras_require=extras,
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 2 - Pre-Alpha",
],
python_requires=">=3.6",
include_package_data=True,
)


if __name__ == "__main__":
setup_package()

0 comments on commit be1a472

Please sign in to comment.