├── .editorconfig ├── .flake8 ├── .gitattributes ├── .gitignore ├── .pre-commit-config.yaml ├── .pylintrc ├── DeepSeek_VL2_paper.pdf ├── LICENSE-CODE ├── LICENSE-MODEL ├── Makefile ├── README.md ├── deepseek_vl2 ├── __init__.py ├── models │ ├── __init__.py │ ├── configuration_deepseek.py │ ├── conversation.py │ ├── modeling_deepseek.py │ ├── modeling_deepseek_vl_v2.py │ ├── processing_deepseek_vl_v2.py │ └── siglip_vit.py ├── serve │ ├── __init__.py │ ├── app_modules │ │ ├── __init__.py │ │ ├── gradio_utils.py │ │ ├── overwrites.py │ │ ├── presets.py │ │ └── utils.py │ ├── assets │ │ ├── Kelpy-Codos.js │ │ ├── avatar.png │ │ ├── custom.css │ │ ├── custom.js │ │ ├── favicon.ico │ │ └── simsun.ttc │ └── inference.py └── utils │ ├── __init__.py │ └── io.py ├── images ├── badge.svg ├── grounding_conversation_1.jpeg ├── icl_vg_2.jpeg ├── incontext_visual_grounding_1.jpeg ├── logo.png ├── logo.svg ├── monday.jpg ├── multi_image_1.jpeg ├── multi_image_2.jpeg ├── multi_image_3.jpeg ├── qr.jpeg ├── sample.jpg ├── vg_2.jpeg ├── visual_grounding_1.jpeg ├── visual_grounding_2.jpg ├── visual_grounding_3.png ├── vl2_teaser.jpeg └── vqa_1.jpg ├── inference.py ├── pyproject.toml ├── requirements.txt └── web_demo.py /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org/ 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | indent_style = space 9 | indent_size = 4 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | [*.py] 14 | indent_size = 4 15 | src_paths=evaluation 16 | 17 | [*.{yaml,yml,json}] 18 | indent_size = 2 19 | 20 | [*.md] 21 | indent_size = 2 22 | x-soft-wrap-text = true 23 | 24 | [*.rst] 25 | indent_size = 4 26 | x-soft-wrap-text = true 27 | 28 | [*.{bib,tex}] 29 | indent_size = 2 30 | 31 | [Makefile] 32 | indent_style = tab 33 | 34 | [*.sh] 35 | indent_style = tab 36 | 37 | [*.bat] 38 | end_of_line = crlf 39 | indent_style = tab 40 | 41 | [*.{cpp,h,cu,cuh}] 42 | indent_size = 2 43 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 120 3 | max-doc-length = 100 4 | select = B,C,E,F,W,Y,SIM 5 | ignore = 6 | # E203: whitespace before ':' 7 | # W503: line break before binary operator 8 | # W504: line break after binary operator 9 | # format by black 10 | E203,W503,W504, 11 | # E501: line too long 12 | # W505: doc line too long 13 | # too long docstring due to long example blocks 14 | E501,W505, 15 | per-file-ignores = 16 | # F401: module imported but unused 17 | # intentionally unused imports 18 | __init__.py: F401 19 | # F401: module imported but unused 20 | # F403: unable to detect undefined names 21 | # F405: member mey be undefined, or defined from star imports 22 | # members populated from optree 23 | # E301: expected 1 blank line 24 | # E302: expected 2 blank lines 25 | # E305: expected 2 blank lines after class or function definition 26 | # E701: multiple statements on one line (colon) 27 | # E704: multiple statements on one line (def) 28 | # format by black 29 | *.pyi: E301,E302,E305,E701,E704 30 | exclude = 31 | .git, 32 | .vscode, 33 | venv, 34 | third-party, 35 | __pycache__, 36 | docs/source/conf.py, 37 | build, 38 | dist, 39 | examples, 40 | tests 41 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | *.ipynb linguist-detectable=false 3 | 4 | *.png binary 5 | *.jpg binary 6 | *.jpeg binary 7 | *.gif binary 8 | *.pdf binary 9 | *.ttc binary 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ##### Python.gitignore ##### 2 | # Byte-compiled / optimized / DLL files 3 | __pycache__/ 4 | *.py[cod] 5 | *$py.class 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Distribution / packaging 11 | .Python 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | wheelhouse/ 25 | share/python-wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | *.whl 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .nox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *.cover 52 | *.py,cover 53 | .hypothesis/ 54 | .pytest_cache/ 55 | cover/ 56 | 57 | # Translations 58 | *.mo 59 | *.pot 60 | 61 | # Django stuff: 62 | *.log 63 | local_settings.py 64 | db.sqlite3 65 | db.sqlite3-journal 66 | 67 | # Flask stuff: 68 | instance/ 69 | .webassets-cache 70 | 71 | # Scrapy stuff: 72 | .scrapy 73 | 74 | # Sphinx documentation 75 | docs/_build/ 76 | docs/source/_build/ 77 | _autosummary/ 78 | 79 | # PyBuilder 80 | .pybuilder/ 81 | target/ 82 | 83 | # Jupyter Notebook 84 | .ipynb_checkpoints 85 | 86 | # IPython 87 | profile_default/ 88 | ipython_config.py 89 | 90 | # pyenv 91 | # For a library or package, you might want to ignore these files since the code is 92 | # intended to run in multiple environments; otherwise, check them in: 93 | .python-version 94 | 95 | # pipenv 96 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 97 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 98 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 99 | # install all needed dependencies. 100 | #Pipfile.lock 101 | 102 | # poetry 103 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 104 | # This is especially recommended for binary packages to ensure reproducibility, and is more 105 | # commonly ignored for libraries. 106 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 107 | #poetry.lock 108 | 109 | # pdm 110 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 111 | #pdm.lock 112 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 113 | # in version control. 114 | # https://pdm.fming.dev/#use-with-ide 115 | .pdm.toml 116 | 117 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 118 | __pypackages__/ 119 | 120 | # Celery stuff 121 | celerybeat-schedule 122 | celerybeat.pid 123 | 124 | # SageMath parsed files 125 | *.sage.py 126 | 127 | # Environments 128 | .env 129 | .venv 130 | env/ 131 | venv/ 132 | ENV/ 133 | env.bak/ 134 | venv.bak/ 135 | 136 | # Spyder project settings 137 | .spyderproject 138 | .spyproject 139 | 140 | # Rope project settings 141 | .ropeproject 142 | 143 | # mkdocs documentation 144 | /site 145 | 146 | # ruff 147 | .ruff_cache/ 148 | 149 | # mypy 150 | .mypy_cache/ 151 | .dmypy.json 152 | dmypy.json 153 | 154 | # Pyre type checker 155 | .pyre/ 156 | 157 | # pytype static type analyzer 158 | .pytype/ 159 | 160 | # Cython debug symbols 161 | cython_debug/ 162 | 163 | # PyCharm 164 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 165 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 166 | # and can be added to the global gitignore or merged into this file. For a more nuclear 167 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 168 | .idea/ 169 | 170 | 171 | ##### macOS.gitignore ##### 172 | # General 173 | .DS_Store 174 | .AppleDouble 175 | .LSOverride 176 | 177 | # Icon must end with two \r 178 | Icon 179 | 180 | # Thumbnails 181 | ._* 182 | 183 | # Files that might appear in the root of a volume 184 | .DocumentRevisions-V100 185 | .fseventsd 186 | .Spotlight-V100 187 | .TemporaryItems 188 | .Trashes 189 | .VolumeIcon.icns 190 | .com.apple.timemachine.donotpresent 191 | 192 | # Directories potentially created on remote AFP share 193 | .AppleDB 194 | .AppleDesktop 195 | Network Trash Folder 196 | Temporary Items 197 | .apdisk 198 | 199 | 200 | ##### Linux.gitignore ##### 201 | *~ 202 | 203 | # Temporary files which can be created if a process still has a handle open of a deleted file 204 | .fuse_hidden* 205 | 206 | # KDE directory preferences 207 | .directory 208 | 209 | # Linux trash folder which might appear on any partition or disk 210 | .Trash-* 211 | 212 | # .nfs files are created when an open file is removed but is still being accessed 213 | .nfs* 214 | 215 | 216 | ##### Windows.gitignore ##### 217 | # Windows thumbnail cache files 218 | Thumbs.db 219 | Thumbs.db:encryptable 220 | ehthumbs.db 221 | ehthumbs_vista.db 222 | 223 | # Dump file 224 | *.stackdump 225 | 226 | # Folder config file 227 | [Dd]esktop.ini 228 | 229 | # Recycle Bin used on file shares 230 | $RECYCLE.BIN/ 231 | 232 | # Windows Installer files 233 | *.cab 234 | *.msi 235 | *.msix 236 | *.msm 237 | *.msp 238 | 239 | # Windows shortcuts 240 | *.lnk 241 | 242 | 243 | ##### Archives.gitignore ##### 244 | # It's better to unpack these files and commit the raw source because 245 | # git has its own built in compression methods. 246 | *.7z 247 | *.jar 248 | *.rar 249 | *.zip 250 | *.gz 251 | *.gzip 252 | *.tgz 253 | *.bzip 254 | *.bzip2 255 | *.bz2 256 | *.xz 257 | *.lzma 258 | *.cab 259 | *.xar 260 | 261 | # Packing-only formats 262 | *.iso 263 | *.tar 264 | 265 | # Package management formats 266 | *.dmg 267 | *.xpi 268 | *.gem 269 | *.egg 270 | *.deb 271 | *.rpm 272 | *.msi 273 | *.msm 274 | *.msp 275 | *.txz 276 | 277 | 278 | ##### Xcode.gitignore ##### 279 | # Xcode 280 | # 281 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 282 | 283 | ## User settings 284 | xcuserdata/ 285 | 286 | ## Compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 287 | *.xcscmblueprint 288 | *.xccheckout 289 | 290 | ## Compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 291 | build/ 292 | DerivedData/ 293 | *.moved-aside 294 | *.pbxuser 295 | !default.pbxuser 296 | *.mode1v3 297 | !default.mode1v3 298 | *.mode2v3 299 | !default.mode2v3 300 | *.perspectivev3 301 | !default.perspectivev3 302 | 303 | ## Gcc Patch 304 | /*.gcno 305 | 306 | 307 | ##### JetBrains.gitignore ##### 308 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 309 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 310 | 311 | # User settings 312 | .idea/* 313 | 314 | # User-specific stuff 315 | .idea/**/workspace.xml 316 | .idea/**/tasks.xml 317 | .idea/**/usage.statistics.xml 318 | .idea/**/dictionaries 319 | .idea/**/shelf 320 | 321 | # Generated files 322 | .idea/**/contentModel.xml 323 | 324 | # Sensitive or high-churn files 325 | .idea/**/dataSources/ 326 | .idea/**/dataSources.ids 327 | .idea/**/dataSources.local.xml 328 | .idea/**/sqlDataSources.xml 329 | .idea/**/dynamic.xml 330 | .idea/**/uiDesigner.xml 331 | .idea/**/dbnavigator.xml 332 | 333 | # Gradle 334 | .idea/**/gradle.xml 335 | .idea/**/libraries 336 | 337 | # Gradle and Maven with auto-import 338 | # When using Gradle or Maven with auto-import, you should exclude module files, 339 | # since they will be recreated, and may cause churn. Uncomment if using 340 | # auto-import. 341 | # .idea/artifacts 342 | # .idea/compiler.xml 343 | # .idea/jarRepositories.xml 344 | # .idea/modules.xml 345 | # .idea/*.iml 346 | # .idea/modules 347 | # *.iml 348 | # *.ipr 349 | 350 | # CMake 351 | cmake-build-*/ 352 | 353 | # Mongo Explorer plugin 354 | .idea/**/mongoSettings.xml 355 | 356 | # File-based project format 357 | *.iws 358 | 359 | # IntelliJ 360 | out/ 361 | 362 | # mpeltonen/sbt-idea plugin 363 | .idea_modules/ 364 | 365 | # JIRA plugin 366 | atlassian-ide-plugin.xml 367 | 368 | # Cursive Clojure plugin 369 | .idea/replstate.xml 370 | 371 | # Crashlytics plugin (for Android Studio and IntelliJ) 372 | com_crashlytics_export_strings.xml 373 | crashlytics.properties 374 | crashlytics-build.properties 375 | fabric.properties 376 | 377 | # Editor-based Rest Client 378 | .idea/httpRequests 379 | 380 | # Android studio 3.1+ serialized cache file 381 | .idea/caches/build_file_checksums.ser 382 | 383 | 384 | ##### VisualStudioCode.gitignore ##### 385 | .vscode/* 386 | # !.vscode/settings.json 387 | # !.vscode/tasks.json 388 | # !.vscode/launch.json 389 | !.vscode/extensions.json 390 | *.code-workspace 391 | 392 | # Local History for Visual Studio Code 393 | .history/ 394 | 395 | 396 | ##### Vim.gitignore ##### 397 | # Swap 398 | .*.s[a-v][a-z] 399 | !*.svg # comment out if you don't need vector files 400 | .*.sw[a-p] 401 | .s[a-rt-v][a-z] 402 | .ss[a-gi-z] 403 | .sw[a-p] 404 | 405 | # Session 406 | Session.vim 407 | Sessionx.vim 408 | 409 | # Temporary 410 | .netrwhist 411 | *~ 412 | # Auto-generated tag files 413 | tags 414 | # Persistent undo 415 | [._]*.un~ 416 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See https://pre-commit.com for more information 2 | # See https://pre-commit.com/hooks.html for more hooks 3 | ci: 4 | skip: [pylint] 5 | autofix_prs: true 6 | autofix_commit_msg: "fix: [pre-commit.ci] auto fixes [...]" 7 | autoupdate_commit_msg: "chore(pre-commit): [pre-commit.ci] autoupdate" 8 | autoupdate_schedule: monthly 9 | default_stages: [commit, push, manual] 10 | repos: 11 | - repo: https://github.com/pre-commit/pre-commit-hooks 12 | rev: v4.5.0 13 | hooks: 14 | - id: check-symlinks 15 | - id: destroyed-symlinks 16 | - id: trailing-whitespace 17 | - id: end-of-file-fixer 18 | - id: check-yaml 19 | - id: check-toml 20 | - id: check-ast 21 | - id: check-added-large-files 22 | - id: check-merge-conflict 23 | - id: check-executables-have-shebangs 24 | - id: check-shebang-scripts-are-executable 25 | - id: detect-private-key 26 | - id: debug-statements 27 | - id: double-quote-string-fixer 28 | - repo: https://github.com/astral-sh/ruff-pre-commit 29 | rev: v0.1.5 30 | hooks: 31 | - id: ruff 32 | args: [--fix, --exit-non-zero-on-fix] 33 | - repo: https://github.com/PyCQA/isort 34 | rev: 5.12.0 35 | hooks: 36 | - id: isort 37 | - repo: https://github.com/psf/black 38 | rev: 23.11.0 39 | hooks: 40 | - id: black-jupyter 41 | - repo: https://github.com/asottile/pyupgrade 42 | rev: v3.15.0 43 | hooks: 44 | - id: pyupgrade 45 | args: [--py38-plus] # sync with requires-python 46 | exclude: | 47 | (?x)( 48 | ^images/ 49 | ) 50 | - repo: https://github.com/pycqa/flake8 51 | rev: 6.1.0 52 | hooks: 53 | - id: flake8 54 | additional_dependencies: 55 | - flake8-bugbear 56 | - flake8-comprehensions 57 | - flake8-docstrings 58 | - flake8-pyi 59 | - flake8-simplify 60 | exclude: | 61 | (?x)( 62 | ^images/ 63 | ) 64 | - repo: local 65 | hooks: 66 | - id: pylint 67 | name: pylint 68 | entry: pylint 69 | language: system 70 | types: [python] 71 | require_serial: true 72 | exclude: | 73 | (?x)( 74 | ^images/ 75 | ) 76 | -------------------------------------------------------------------------------- /.pylintrc: -------------------------------------------------------------------------------- 1 | [MAIN] 2 | 3 | # Analyse import fallback blocks. This can be used to support both Python 2 and 4 | # 3 compatible code, which means that the block might have code that exists 5 | # only in one or another interpreter, leading to false positives when analysed. 6 | analyse-fallback-blocks=no 7 | 8 | # Load and enable all available extensions. Use --list-extensions to see a list 9 | # all available extensions. 10 | #enable-all-extensions= 11 | 12 | # In error mode, messages with a category besides ERROR or FATAL are 13 | # suppressed, and no reports are done by default. Error mode is compatible with 14 | # disabling specific errors. 15 | #errors-only= 16 | 17 | # Always return a 0 (non-error) status code, even if lint errors are found. 18 | # This is primarily useful in continuous integration scripts. 19 | #exit-zero= 20 | 21 | # A comma-separated list of package or module names from where C extensions may 22 | # be loaded. Extensions are loading into the active Python interpreter and may 23 | # run arbitrary code. 24 | extension-pkg-allow-list= 25 | 26 | # A comma-separated list of package or module names from where C extensions may 27 | # be loaded. Extensions are loading into the active Python interpreter and may 28 | # run arbitrary code. (This is an alternative name to extension-pkg-allow-list 29 | # for backward compatibility.) 30 | extension-pkg-whitelist= 31 | 32 | # Return non-zero exit code if any of these messages/categories are detected, 33 | # even if score is above --fail-under value. Syntax same as enable. Messages 34 | # specified are enabled, while categories only check already-enabled messages. 35 | fail-on= 36 | 37 | # Specify a score threshold under which the program will exit with error. 38 | fail-under=10 39 | 40 | # Interpret the stdin as a python script, whose filename needs to be passed as 41 | # the module_or_package argument. 42 | #from-stdin= 43 | 44 | # Files or directories to be skipped. They should be base names, not paths. 45 | ignore=CVS,.vscode,.history 46 | 47 | # Add files or directories matching the regular expressions patterns to the 48 | # ignore-list. The regex matches against paths and can be in Posix or Windows 49 | # format. Because '\' represents the directory delimiter on Windows systems, it 50 | # can't be used as an escape character. 51 | ignore-paths=^images/$ 52 | 53 | # Files or directories matching the regular expression patterns are skipped. 54 | # The regex matches against base names, not paths. The default value ignores 55 | # Emacs file locks 56 | ignore-patterns=^\.# 57 | 58 | # List of module names for which member attributes should not be checked 59 | # (useful for modules/projects where namespaces are manipulated during runtime 60 | # and thus existing member attributes cannot be deduced by static analysis). It 61 | # supports qualified module names, as well as Unix pattern matching. 62 | ignored-modules= 63 | 64 | # Python code to execute, usually for sys.path manipulation such as 65 | # pygtk.require(). 66 | #init-hook= 67 | 68 | # Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the 69 | # number of processors available to use, and will cap the count on Windows to 70 | # avoid hangs. 71 | jobs=0 72 | 73 | # Control the amount of potential inferred values when inferring a single 74 | # object. This can help the performance when dealing with large functions or 75 | # complex, nested conditions. 76 | limit-inference-results=100 77 | 78 | # List of plugins (as comma separated values of python module names) to load, 79 | # usually to register additional checkers. 80 | load-plugins= 81 | 82 | # Pickle collected data for later comparisons. 83 | persistent=yes 84 | 85 | # Minimum Python version to use for version dependent checks. Will default to 86 | # the version used to run pylint. 87 | py-version=3.8 # the lowest version we support (sync with requires-python in pyproject.toml) 88 | 89 | # Discover python modules and packages in the file system subtree. 90 | recursive=no 91 | 92 | # When enabled, pylint would attempt to guess common misconfiguration and emit 93 | # user-friendly hints instead of false-positive error messages. 94 | suggestion-mode=yes 95 | 96 | # Allow loading of arbitrary C extensions. Extensions are imported into the 97 | # active Python interpreter and may run arbitrary code. 98 | unsafe-load-any-extension=no 99 | 100 | # In verbose mode, extra non-checker-related info will be displayed. 101 | #verbose= 102 | 103 | 104 | [BASIC] 105 | 106 | # Naming style matching correct argument names. 107 | argument-naming-style=snake_case 108 | 109 | # Regular expression matching correct argument names. Overrides argument- 110 | # naming-style. If left empty, argument names will be checked with the set 111 | # naming style. 112 | #argument-rgx= 113 | 114 | # Naming style matching correct attribute names. 115 | attr-naming-style=snake_case 116 | 117 | # Regular expression matching correct attribute names. Overrides attr-naming- 118 | # style. If left empty, attribute names will be checked with the set naming 119 | # style. 120 | #attr-rgx= 121 | 122 | # Bad variable names which should always be refused, separated by a comma. 123 | bad-names=foo, 124 | bar, 125 | baz, 126 | toto, 127 | tutu, 128 | tata 129 | 130 | # Bad variable names regexes, separated by a comma. If names match any regex, 131 | # they will always be refused 132 | bad-names-rgxs= 133 | 134 | # Naming style matching correct class attribute names. 135 | class-attribute-naming-style=any 136 | 137 | # Regular expression matching correct class attribute names. Overrides class- 138 | # attribute-naming-style. If left empty, class attribute names will be checked 139 | # with the set naming style. 140 | #class-attribute-rgx= 141 | 142 | # Naming style matching correct class constant names. 143 | class-const-naming-style=UPPER_CASE 144 | 145 | # Regular expression matching correct class constant names. Overrides class- 146 | # const-naming-style. If left empty, class constant names will be checked with 147 | # the set naming style. 148 | #class-const-rgx= 149 | 150 | # Naming style matching correct class names. 151 | class-naming-style=PascalCase 152 | 153 | # Regular expression matching correct class names. Overrides class-naming- 154 | # style. If left empty, class names will be checked with the set naming style. 155 | #class-rgx= 156 | 157 | # Naming style matching correct constant names. 158 | const-naming-style=UPPER_CASE 159 | 160 | # Regular expression matching correct constant names. Overrides const-naming- 161 | # style. If left empty, constant names will be checked with the set naming 162 | # style. 163 | #const-rgx= 164 | 165 | # Minimum line length for functions/classes that require docstrings, shorter 166 | # ones are exempt. 167 | docstring-min-length=-1 168 | 169 | # Naming style matching correct function names. 170 | function-naming-style=snake_case 171 | 172 | # Regular expression matching correct function names. Overrides function- 173 | # naming-style. If left empty, function names will be checked with the set 174 | # naming style. 175 | #function-rgx= 176 | 177 | # Good variable names which should always be accepted, separated by a comma. 178 | good-names=i, 179 | j, 180 | k, 181 | ex, 182 | Run, 183 | _, 184 | op, 185 | fn, 186 | f, 187 | g, 188 | p, 189 | u, 190 | t, 191 | lr, 192 | mu, 193 | nu, 194 | x, 195 | y 196 | 197 | # Good variable names regexes, separated by a comma. If names match any regex, 198 | # they will always be accepted 199 | good-names-rgxs= 200 | 201 | # Include a hint for the correct naming format with invalid-name. 202 | include-naming-hint=no 203 | 204 | # Naming style matching correct inline iteration names. 205 | inlinevar-naming-style=any 206 | 207 | # Regular expression matching correct inline iteration names. Overrides 208 | # inlinevar-naming-style. If left empty, inline iteration names will be checked 209 | # with the set naming style. 210 | #inlinevar-rgx= 211 | 212 | # Naming style matching correct method names. 213 | method-naming-style=snake_case 214 | 215 | # Regular expression matching correct method names. Overrides method-naming- 216 | # style. If left empty, method names will be checked with the set naming style. 217 | #method-rgx= 218 | 219 | # Naming style matching correct module names. 220 | module-naming-style=snake_case 221 | 222 | # Regular expression matching correct module names. Overrides module-naming- 223 | # style. If left empty, module names will be checked with the set naming style. 224 | #module-rgx= 225 | 226 | # Colon-delimited sets of names that determine each other's naming style when 227 | # the name regexes allow several styles. 228 | name-group= 229 | 230 | # Regular expression which should only match function or class names that do 231 | # not require a docstring. 232 | no-docstring-rgx=^_ 233 | 234 | # List of decorators that produce properties, such as abc.abstractproperty. Add 235 | # to this list to register other decorators that produce valid properties. 236 | # These decorators are taken in consideration only for invalid-name. 237 | property-classes=abc.abstractproperty 238 | 239 | # Regular expression matching correct type variable names. If left empty, type 240 | # variable names will be checked with the set naming style. 241 | #typevar-rgx= 242 | 243 | # Naming style matching correct variable names. 244 | variable-naming-style=snake_case 245 | 246 | # Regular expression matching correct variable names. Overrides variable- 247 | # naming-style. If left empty, variable names will be checked with the set 248 | # naming style. 249 | #variable-rgx= 250 | 251 | 252 | [CLASSES] 253 | 254 | # Warn about protected attribute access inside special methods 255 | check-protected-access-in-special-methods=no 256 | 257 | # List of method names used to declare (i.e. assign) instance attributes. 258 | defining-attr-methods=__init__, 259 | __new__, 260 | setUp, 261 | __post_init__ 262 | 263 | # List of member names, which should be excluded from the protected access 264 | # warning. 265 | exclude-protected=_asdict, 266 | _fields, 267 | _replace, 268 | _source, 269 | _make 270 | 271 | # List of valid names for the first argument in a class method. 272 | valid-classmethod-first-arg=cls 273 | 274 | # List of valid names for the first argument in a metaclass class method. 275 | valid-metaclass-classmethod-first-arg=cls 276 | 277 | 278 | [DESIGN] 279 | 280 | # List of regular expressions of class ancestor names to ignore when counting 281 | # public methods (see R0903) 282 | exclude-too-few-public-methods= 283 | 284 | # List of qualified class names to ignore when counting class parents (see 285 | # R0901) 286 | ignored-parents= 287 | 288 | # Maximum number of arguments for function / method. 289 | max-args=5 290 | 291 | # Maximum number of attributes for a class (see R0902). 292 | max-attributes=7 293 | 294 | # Maximum number of boolean expressions in an if statement (see R0916). 295 | max-bool-expr=5 296 | 297 | # Maximum number of branch for function / method body. 298 | max-branches=12 299 | 300 | # Maximum number of locals for function / method body. 301 | max-locals=15 302 | 303 | # Maximum number of parents for a class (see R0901). 304 | max-parents=7 305 | 306 | # Maximum number of public methods for a class (see R0904). 307 | max-public-methods=20 308 | 309 | # Maximum number of return / yield for function / method body. 310 | max-returns=6 311 | 312 | # Maximum number of statements in function / method body. 313 | max-statements=50 314 | 315 | # Minimum number of public methods for a class (see R0903). 316 | min-public-methods=2 317 | 318 | 319 | [EXCEPTIONS] 320 | 321 | # Exceptions that will emit a warning when caught. 322 | overgeneral-exceptions=builtins.BaseException, 323 | builtins.Exception 324 | 325 | 326 | [FORMAT] 327 | 328 | # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. 329 | expected-line-ending-format= 330 | 331 | # Regexp for a line that is allowed to be longer than the limit. 332 | ignore-long-lines=^\s*(# )??$ 333 | 334 | # Number of spaces of indent required inside a hanging or continued line. 335 | indent-after-paren=4 336 | 337 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 338 | # tab). 339 | indent-string=' ' 340 | 341 | # Maximum number of characters on a single line. 342 | max-line-length=120 343 | 344 | # Maximum number of lines in a module. 345 | max-module-lines=1000 346 | 347 | # Allow the body of a class to be on the same line as the declaration if body 348 | # contains single statement. 349 | single-line-class-stmt=no 350 | 351 | # Allow the body of an if to be on the same line as the test if there is no 352 | # else. 353 | single-line-if-stmt=no 354 | 355 | 356 | [IMPORTS] 357 | 358 | # List of modules that can be imported at any level, not just the top level 359 | # one. 360 | allow-any-import-level= 361 | 362 | # Allow wildcard imports from modules that define __all__. 363 | allow-wildcard-with-all=no 364 | 365 | # Deprecated modules which should not be used, separated by a comma. 366 | deprecated-modules= 367 | 368 | # Output a graph (.gv or any supported image format) of external dependencies 369 | # to the given file (report RP0402 must not be disabled). 370 | ext-import-graph= 371 | 372 | # Output a graph (.gv or any supported image format) of all (i.e. internal and 373 | # external) dependencies to the given file (report RP0402 must not be 374 | # disabled). 375 | import-graph= 376 | 377 | # Output a graph (.gv or any supported image format) of internal dependencies 378 | # to the given file (report RP0402 must not be disabled). 379 | int-import-graph= 380 | 381 | # Force import order to recognize a module as part of the standard 382 | # compatibility libraries. 383 | known-standard-library= 384 | 385 | # Force import order to recognize a module as part of a third party library. 386 | known-third-party=enchant 387 | 388 | # Couples of modules and preferred modules, separated by a comma. 389 | preferred-modules= 390 | 391 | 392 | [LOGGING] 393 | 394 | # The type of string formatting that logging methods do. `old` means using % 395 | # formatting, `new` is for `{}` formatting. 396 | logging-format-style=old 397 | 398 | # Logging modules to check that the string format arguments are in logging 399 | # function parameter format. 400 | logging-modules=logging 401 | 402 | 403 | [MESSAGES CONTROL] 404 | 405 | # Only show warnings with the listed confidence levels. Leave empty to show 406 | # all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, 407 | # UNDEFINED. 408 | confidence=HIGH, 409 | CONTROL_FLOW, 410 | INFERENCE, 411 | INFERENCE_FAILURE, 412 | UNDEFINED 413 | 414 | # Disable the message, report, category or checker with the given id(s). You 415 | # can either give multiple identifiers separated by comma (,) or put this 416 | # option multiple times (only on the command line, not in the configuration 417 | # file where it should appear only once). You can also use "--disable=all" to 418 | # disable everything first and then re-enable specific checks. For example, if 419 | # you want to run only the similarities checker, you can use "--disable=all 420 | # --enable=similarities". If you want to run only the classes checker, but have 421 | # no Warning level messages displayed, use "--disable=all --enable=classes 422 | # --disable=W". 423 | disable=duplicate-code, 424 | consider-using-from-import 425 | 426 | # Enable the message, report, category or checker with the given id(s). You can 427 | # either give multiple identifier separated by comma (,) or put this option 428 | # multiple time (only on the command line, not in the configuration file where 429 | # it should appear only once). See also the "--disable" option for examples. 430 | enable=c-extension-no-member 431 | 432 | 433 | [METHOD_ARGS] 434 | 435 | # List of qualified names (i.e., library.method) which require a timeout 436 | # parameter e.g. 'requests.api.get,requests.api.post' 437 | timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request 438 | 439 | 440 | [MISCELLANEOUS] 441 | 442 | # List of note tags to take in consideration, separated by a comma. 443 | notes=FIXME, 444 | XXX, 445 | TODO 446 | 447 | # Regular expression of note tags to take in consideration. 448 | notes-rgx= 449 | 450 | 451 | [REFACTORING] 452 | 453 | # Maximum number of nested blocks for function / method body 454 | max-nested-blocks=5 455 | 456 | # Complete name of functions that never returns. When checking for 457 | # inconsistent-return-statements if a never returning function is called then 458 | # it will be considered as an explicit return statement and no message will be 459 | # printed. 460 | never-returning-functions=sys.exit,argparse.parse_error 461 | 462 | 463 | [REPORTS] 464 | 465 | # Python expression which should return a score less than or equal to 10. You 466 | # have access to the variables 'fatal', 'error', 'warning', 'refactor', 467 | # 'convention', and 'info' which contain the number of messages in each 468 | # category, as well as 'statement' which is the total number of statements 469 | # analyzed. This score is used by the global evaluation report (RP0004). 470 | evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)) 471 | 472 | # Template used to display messages. This is a python new-style format string 473 | # used to format the message information. See doc for all details. 474 | msg-template= 475 | 476 | # Set the output format. Available formats are text, parseable, colorized, json 477 | # and msvs (visual studio). You can also give a reporter class, e.g. 478 | # mypackage.mymodule.MyReporterClass. 479 | #output-format= 480 | 481 | # Tells whether to display a full report or only the messages. 482 | reports=no 483 | 484 | # Activate the evaluation score. 485 | score=yes 486 | 487 | 488 | [SIMILARITIES] 489 | 490 | # Comments are removed from the similarity computation 491 | ignore-comments=yes 492 | 493 | # Docstrings are removed from the similarity computation 494 | ignore-docstrings=yes 495 | 496 | # Imports are removed from the similarity computation 497 | ignore-imports=yes 498 | 499 | # Signatures are removed from the similarity computation 500 | ignore-signatures=yes 501 | 502 | # Minimum lines number of a similarity. 503 | min-similarity-lines=4 504 | 505 | 506 | [SPELLING] 507 | 508 | # Limits count of emitted suggestions for spelling mistakes. 509 | max-spelling-suggestions=4 510 | 511 | # Spelling dictionary name. Available dictionaries: en_AU (hunspell), en_CA 512 | # (hunspell), en_GB (hunspell), en_US (hunspell), en_ZA (hunspell). 513 | spelling-dict= 514 | 515 | # List of comma separated words that should be considered directives if they 516 | # appear at the beginning of a comment and should not be checked. 517 | spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy: 518 | 519 | # List of comma separated words that should not be checked. 520 | spelling-ignore-words= 521 | 522 | # A path to a file that contains the private dictionary; one word per line. 523 | spelling-private-dict-file=docs/source/spelling_wordlist.txt 524 | 525 | # Tells whether to store unknown words to the private dictionary (see the 526 | # --spelling-private-dict-file option) instead of raising a message. 527 | spelling-store-unknown-words=no 528 | 529 | 530 | [STRING] 531 | 532 | # This flag controls whether inconsistent-quotes generates a warning when the 533 | # character used as a quote delimiter is used inconsistently within a module. 534 | check-quote-consistency=no 535 | 536 | # This flag controls whether the implicit-str-concat should generate a warning 537 | # on implicit string concatenation in sequences defined over several lines. 538 | check-str-concat-over-line-jumps=no 539 | 540 | 541 | [TYPECHECK] 542 | 543 | # List of decorators that produce context managers, such as 544 | # contextlib.contextmanager. Add to this list to register other decorators that 545 | # produce valid context managers. 546 | contextmanager-decorators=contextlib.contextmanager 547 | 548 | # List of members which are set dynamically and missed by pylint inference 549 | # system, and so shouldn't trigger E1101 when accessed. Python regular 550 | # expressions are accepted. 551 | generated-members=numpy.*, 552 | torch.* 553 | 554 | # Tells whether missing members accessed in mixin class should be ignored. A 555 | # class is considered mixin if its name matches the mixin-class-rgx option. 556 | ignore-mixin-members=yes 557 | 558 | # Tells whether to warn about missing members when the owner of the attribute 559 | # is inferred to be None. 560 | ignore-none=yes 561 | 562 | # This flag controls whether pylint should warn about no-member and similar 563 | # checks whenever an opaque object is returned when inferring. The inference 564 | # can return multiple potential results while evaluating a Python object, but 565 | # some branches might not be evaluated, which results in partial inference. In 566 | # that case, it might be useful to still emit no-member and other checks for 567 | # the rest of the inferred objects. 568 | ignore-on-opaque-inference=yes 569 | 570 | # List of symbolic message names to ignore for Mixin members. 571 | ignored-checks-for-mixins=no-member, 572 | not-async-context-manager, 573 | not-context-manager, 574 | attribute-defined-outside-init 575 | 576 | # List of class names for which member attributes should not be checked (useful 577 | # for classes with dynamically set attributes). This supports the use of 578 | # qualified names. 579 | ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace 580 | 581 | # Show a hint with possible names when a member name was not found. The aspect 582 | # of finding the hint is based on edit distance. 583 | missing-member-hint=yes 584 | 585 | # The minimum edit distance a name should have in order to be considered a 586 | # similar match for a missing member name. 587 | missing-member-hint-distance=1 588 | 589 | # The total number of similar names that should be taken in consideration when 590 | # showing a hint for a missing member. 591 | missing-member-max-choices=1 592 | 593 | # Regex pattern to define which classes are considered mixins. 594 | mixin-class-rgx=.*[Mm]ixin 595 | 596 | # List of decorators that change the signature of a decorated function. 597 | signature-mutators= 598 | 599 | 600 | [VARIABLES] 601 | 602 | # List of additional names supposed to be defined in builtins. Remember that 603 | # you should avoid defining new builtins when possible. 604 | additional-builtins= 605 | 606 | # Tells whether unused global variables should be treated as a violation. 607 | allow-global-unused-variables=yes 608 | 609 | # List of names allowed to shadow builtins 610 | allowed-redefined-builtins= 611 | 612 | # List of strings which can identify a callback function by name. A callback 613 | # name must start or end with one of those strings. 614 | callbacks=cb_, 615 | _cb 616 | 617 | # A regular expression matching the name of dummy variables (i.e. expected to 618 | # not be used). 619 | dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ 620 | 621 | # Argument names that match this expression will be ignored. 622 | ignored-argument-names=_.*|^ignored_|^unused_ 623 | 624 | # Tells whether we should check for unused import in __init__ files. 625 | init-import=no 626 | 627 | # List of qualified module names which can have objects that can redefine 628 | # builtins. 629 | redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io 630 | -------------------------------------------------------------------------------- /DeepSeek_VL2_paper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepseek-ai/DeepSeek-VL2/ef9f91e2b6426536b83294c11742c27be66361b1/DeepSeek_VL2_paper.pdf -------------------------------------------------------------------------------- /LICENSE-CODE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 DeepSeek 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE-MODEL: -------------------------------------------------------------------------------- 1 | DEEPSEEK LICENSE AGREEMENT 2 | 3 | Version 1.0, 23 October 2023 4 | 5 | Copyright (c) 2023 DeepSeek 6 | 7 | Section I: PREAMBLE 8 | 9 | Large generative models are being widely adopted and used, and have the potential to transform the way individuals conceive and benefit from AI or ML technologies. 10 | 11 | Notwithstanding the current and potential benefits that these artifacts can bring to society at large, there are also concerns about potential misuses of them, either due to their technical limitations or ethical considerations. 12 | 13 | In short, this license strives for both the open and responsible downstream use of the accompanying model. When it comes to the open character, we took inspiration from open source permissive licenses regarding the grant of IP rights. Referring to the downstream responsible use, we added use-based restrictions not permitting the use of the model in very specific scenarios, in order for the licensor to be able to enforce the license in case potential misuses of the Model may occur. At the same time, we strive to promote open and responsible research on generative models for content generation. 14 | 15 | Even though downstream derivative versions of the model could be released under different licensing terms, the latter will always have to include - at minimum - the same use-based restrictions as the ones in the original license (this license). We believe in the intersection between open and responsible AI development; thus, this agreement aims to strike a balance between both in order to enable responsible open-science in the field of AI. 16 | 17 | This License governs the use of the model (and its derivatives) and is informed by the model card associated with the model. 18 | 19 | NOW THEREFORE, You and DeepSeek agree as follows: 20 | 21 | 1. Definitions 22 | "License" means the terms and conditions for use, reproduction, and Distribution as defined in this document. 23 | "Data" means a collection of information and/or content extracted from the dataset used with the Model, including to train, pretrain, or otherwise evaluate the Model. The Data is not licensed under this License. 24 | "Output" means the results of operating a Model as embodied in informational content resulting therefrom. 25 | "Model" means any accompanying machine-learning based assemblies (including checkpoints), consisting of learnt weights, parameters (including optimizer states), corresponding to the model architecture as embodied in the Complementary Material, that have been trained or tuned, in whole or in part on the Data, using the Complementary Material. 26 | "Derivatives of the Model" means all modifications to the Model, works based on the Model, or any other model which is created or initialized by transfer of patterns of the weights, parameters, activations or output of the Model, to the other model, in order to cause the other model to perform similarly to the Model, including - but not limited to - distillation methods entailing the use of intermediate data representations or methods based on the generation of synthetic data by the Model for training the other model. 27 | "Complementary Material" means the accompanying source code and scripts used to define, run, load, benchmark or evaluate the Model, and used to prepare data for training or evaluation, if any. This includes any accompanying documentation, tutorials, examples, etc, if any. 28 | "Distribution" means any transmission, reproduction, publication or other sharing of the Model or Derivatives of the Model to a third party, including providing the Model as a hosted service made available by electronic or other remote means - e.g. API-based or web access. 29 | "DeepSeek" (or "we") means Beijing DeepSeek Artificial Intelligence Fundamental Technology Research Co., Ltd., Hangzhou DeepSeek Artificial Intelligence Fundamental Technology Research Co., Ltd. and/or any of their affiliates. 30 | "You" (or "Your") means an individual or Legal Entity exercising permissions granted by this License and/or making use of the Model for whichever purpose and in any field of use, including usage of the Model in an end-use application - e.g. chatbot, translator, etc. 31 | "Third Parties" means individuals or legal entities that are not under common control with DeepSeek or You. 32 | 33 | Section II: INTELLECTUAL PROPERTY RIGHTS 34 | 35 | Both copyright and patent grants apply to the Model, Derivatives of the Model and Complementary Material. The Model and Derivatives of the Model are subject to additional terms as described in Section III. 36 | 37 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, DeepSeek hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare, publicly display, publicly perform, sublicense, and distribute the Complementary Material, the Model, and Derivatives of the Model. 38 | 39 | 3. Grant of Patent License. Subject to the terms and conditions of this License and where and as applicable, DeepSeek hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this paragraph) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Model and the Complementary Material, where such license applies only to those patent claims licensable by DeepSeek that are necessarily infringed by its contribution(s). If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Model and/or Complementary Material constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for the Model and/or works shall terminate as of the date such litigation is asserted or filed. 40 | 41 | 42 | Section III: CONDITIONS OF USAGE, DISTRIBUTION AND REDISTRIBUTION 43 | 44 | 4. Distribution and Redistribution. You may host for Third Party remote access purposes (e.g. software-as-a-service), reproduce and distribute copies of the Model or Derivatives of the Model thereof in any medium, with or without modifications, provided that You meet the following conditions: 45 | a. Use-based restrictions as referenced in paragraph 5 MUST be included as an enforceable provision by You in any type of legal agreement (e.g. a license) governing the use and/or distribution of the Model or Derivatives of the Model, and You shall give notice to subsequent users You Distribute to, that the Model or Derivatives of the Model are subject to paragraph 5. This provision does not apply to the use of Complementary Material. 46 | b. You must give any Third Party recipients of the Model or Derivatives of the Model a copy of this License; 47 | c. You must cause any modified files to carry prominent notices stating that You changed the files; 48 | d. You must retain all copyright, patent, trademark, and attribution notices excluding those notices that do not pertain to any part of the Model, Derivatives of the Model. 49 | e. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions - respecting paragraph 4.a. – for use, reproduction, or Distribution of Your modifications, or for any such Derivatives of the Model as a whole, provided Your use, reproduction, and Distribution of the Model otherwise complies with the conditions stated in this License. 50 | 51 | 5. Use-based restrictions. The restrictions set forth in Attachment A are considered Use-based restrictions. Therefore You cannot use the Model and the Derivatives of the Model for the specified restricted uses. You may use the Model subject to this License, including only for lawful purposes and in accordance with the License. Use may include creating any content with, finetuning, updating, running, training, evaluating and/or reparametrizing the Model. You shall require all of Your users who use the Model or a Derivative of the Model to comply with the terms of this paragraph (paragraph 5). 52 | 53 | 6. The Output You Generate. Except as set forth herein, DeepSeek claims no rights in the Output You generate using the Model. You are accountable for the Output you generate and its subsequent uses. No use of the output can contravene any provision as stated in the License. 54 | 55 | Section IV: OTHER PROVISIONS 56 | 57 | 7. Updates and Runtime Restrictions. To the maximum extent permitted by law, DeepSeek reserves the right to restrict (remotely or otherwise) usage of the Model in violation of this License. 58 | 59 | 8. Trademarks and related. Nothing in this License permits You to make use of DeepSeek’ trademarks, trade names, logos or to otherwise suggest endorsement or misrepresent the relationship between the parties; and any rights not expressly granted herein are reserved by DeepSeek. 60 | 61 | 9. Personal information, IP rights and related. This Model may contain personal information and works with IP rights. You commit to complying with applicable laws and regulations in the handling of personal information and the use of such works. Please note that DeepSeek's license granted to you to use the Model does not imply that you have obtained a legitimate basis for processing the related information or works. As an independent personal information processor and IP rights user, you need to ensure full compliance with relevant legal and regulatory requirements when handling personal information and works with IP rights that may be contained in the Model, and are willing to assume solely any risks and consequences that may arise from that. 62 | 63 | 10. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, DeepSeek provides the Model and the Complementary Material on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Model, Derivatives of the Model, and the Complementary Material and assume any risks associated with Your exercise of permissions under this License. 64 | 65 | 11. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall DeepSeek be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Model and the Complementary Material (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if DeepSeek has been advised of the possibility of such damages. 66 | 67 | 12. Accepting Warranty or Additional Liability. While redistributing the Model, Derivatives of the Model and the Complementary Material thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of DeepSeek, and only if You agree to indemnify, defend, and hold DeepSeek harmless for any liability incurred by, or claims asserted against, DeepSeek by reason of your accepting any such warranty or additional liability. 68 | 69 | 13. If any provision of this License is held to be invalid, illegal or unenforceable, the remaining provisions shall be unaffected thereby and remain valid as if such provision had not been set forth herein. 70 | 71 | 14. Governing Law and Jurisdiction. This agreement will be governed and construed under PRC laws without regard to choice of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this agreement. The courts located in the domicile of Hangzhou DeepSeek Artificial Intelligence Fundamental Technology Research Co., Ltd. shall have exclusive jurisdiction of any dispute arising out of this agreement. 72 | 73 | END OF TERMS AND CONDITIONS 74 | 75 | Attachment A 76 | 77 | Use Restrictions 78 | 79 | You agree not to use the Model or Derivatives of the Model: 80 | 81 | - In any way that violates any applicable national or international law or regulation or infringes upon the lawful rights and interests of any third party; 82 | - For military use in any way; 83 | - For the purpose of exploiting, harming or attempting to exploit or harm minors in any way; 84 | - To generate or disseminate verifiably false information and/or content with the purpose of harming others; 85 | - To generate or disseminate inappropriate content subject to applicable regulatory requirements; 86 | - To generate or disseminate personal identifiable information without due authorization or for unreasonable use; 87 | - To defame, disparage or otherwise harass others; 88 | - For fully automated decision making that adversely impacts an individual’s legal rights or otherwise creates or modifies a binding, enforceable obligation; 89 | - For any use intended to or which has the effect of discriminating against or harming individuals or groups based on online or offline social behavior or known or predicted personal or personality characteristics; 90 | - To exploit any of the vulnerabilities of a specific group of persons based on their age, social, physical or mental characteristics, in order to materially distort the behavior of a person pertaining to that group in a manner that causes or is likely to cause that person or another person physical or psychological harm; 91 | - For any use intended to or which has the effect of discriminating against individuals or groups based on legally protected characteristics or categories. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | print-% : ; @echo $* = $($*) 2 | PROJECT_NAME = DeepSeek-VL 3 | COPYRIGHT = "DeepSeek." 4 | PROJECT_PATH = deepseek_vl 5 | SHELL = /bin/bash 6 | SOURCE_FOLDERS = deepseek_vl 7 | PYTHON_FILES = $(shell find $(SOURCE_FOLDERS) -type f -name "*.py" -o -name "*.pyi") cli_chat.py inference.py 8 | COMMIT_HASH = $(shell git log -1 --format=%h) 9 | PATH := $(HOME)/go/bin:$(PATH) 10 | PYTHON ?= $(shell command -v python3 || command -v python) 11 | PYTESTOPTS ?= 12 | 13 | .PHONY: default 14 | default: install 15 | 16 | # Tools Installation 17 | 18 | check_pip_install = $(PYTHON) -m pip show $(1) &>/dev/null || (cd && $(PYTHON) -m pip install $(1) --upgrade) 19 | check_pip_install_extra = $(PYTHON) -m pip show $(1) &>/dev/null || (cd && $(PYTHON) -m pip install $(2) --upgrade) 20 | 21 | pylint-install: 22 | $(call check_pip_install_extra,pylint,pylint[spelling]) 23 | $(call check_pip_install,pyenchant) 24 | 25 | flake8-install: 26 | $(call check_pip_install,flake8) 27 | $(call check_pip_install,flake8-bugbear) 28 | $(call check_pip_install,flake8-comprehensions) 29 | $(call check_pip_install,flake8-docstrings) 30 | $(call check_pip_install,flake8-pyi) 31 | $(call check_pip_install,flake8-simplify) 32 | 33 | py-format-install: 34 | $(call check_pip_install,isort) 35 | $(call check_pip_install_extra,black,black[jupyter]) 36 | 37 | ruff-install: 38 | $(call check_pip_install,ruff) 39 | 40 | mypy-install: 41 | $(call check_pip_install,mypy) 42 | 43 | pre-commit-install: 44 | $(call check_pip_install,pre-commit) 45 | $(PYTHON) -m pre_commit install --install-hooks 46 | 47 | go-install: 48 | # requires go >= 1.16 49 | command -v go || (sudo apt-get install -y golang && sudo ln -sf /usr/lib/go/bin/go /usr/bin/go) 50 | 51 | addlicense-install: go-install 52 | command -v addlicense || go install github.com/google/addlicense@latest 53 | 54 | addlicense: addlicense-install 55 | addlicense -c $(COPYRIGHT) -ignore tests/coverage.xml -l mit -y 2023-$(shell date +"%Y") -check $(SOURCE_FOLDERS) 56 | 57 | # Python linters 58 | 59 | pylint: pylint-install 60 | $(PYTHON) -m pylint $(PROJECT_PATH) 61 | 62 | flake8: flake8-install 63 | $(PYTHON) -m flake8 --count --show-source --statistics 64 | 65 | py-format: py-format-install 66 | $(PYTHON) -m isort --project $(PROJECT_PATH) --check $(PYTHON_FILES) && \ 67 | $(PYTHON) -m black --check $(PYTHON_FILES) 68 | 69 | ruff: ruff-install 70 | $(PYTHON) -m ruff check . 71 | 72 | ruff-fix: ruff-install 73 | $(PYTHON) -m ruff check . --fix --exit-non-zero-on-fix 74 | 75 | mypy: mypy-install 76 | $(PYTHON) -m mypy $(PROJECT_PATH) --install-types --non-interactive 77 | 78 | pre-commit: pre-commit-install 79 | $(PYTHON) -m pre_commit run --all-files 80 | 81 | # Utility functions 82 | 83 | lint: ruff flake8 py-format mypy pylint addlicense 84 | 85 | format: py-format-install ruff-install addlicense-install 86 | $(PYTHON) -m isort --project $(PROJECT_PATH) $(PYTHON_FILES) 87 | $(PYTHON) -m black $(PYTHON_FILES) 88 | $(PYTHON) -m ruff check . --fix --exit-zero 89 | addlicense -c $(COPYRIGHT) -ignore tests/coverage.xml -l mit -y 2023-$(shell date +"%Y") $(SOURCE_FOLDERS) cli_chat.py inference.py 90 | 91 | clean-py: 92 | find . -type f -name '*.py[co]' -delete 93 | find . -depth -type d -name "__pycache__" -exec rm -r "{}" + 94 | find . -depth -type d -name ".ruff_cache" -exec rm -r "{}" + 95 | find . -depth -type d -name ".mypy_cache" -exec rm -r "{}" + 96 | 97 | clean: clean-py 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
50 | 📥 Model Download |
51 | ⚡ Quick Start |
52 | 📜 License |
53 | 📖 Citation
54 | 📄 Paper Link |
55 | 📄 Arxiv Paper Link |
56 | 👁️ Demo
57 |
DeepSeek-VL2-tiny
, DeepSeek-VL2-small
, DeepSeek-VL2
.
77 |
78 | ## 3. Model Download
79 |
80 | We release the DeepSeek-VL2 family, including DeepSeek-VL2-tiny
, DeepSeek-VL2-small
, DeepSeek-VL2
.
81 | To support a broader and more diverse range of research within both academic and commercial communities.
82 | Please note that the use of this model is subject to the terms outlined in [License section](#5-license).
83 |
84 | ### Huggingface
85 |
86 | | Model | Sequence Length | Download |
87 | |--------------|-----------------|-----------------------------------------------------------------------------|
88 | | DeepSeek-VL2-tiny | 4096 | [🤗 Hugging Face](https://huggingface.co/deepseek-ai/deepseek-vl2-tiny) |
89 | | DeepSeek-VL2-small | 4096 | [🤗 Hugging Face](https://huggingface.co/deepseek-ai/deepseek-vl2-small) |
90 | | DeepSeek-VL2 | 4096 | [🤗 Hugging Face](https://huggingface.co/deepseek-ai/deepseek-vl2) |
91 |
92 |
93 | ## 4. Quick Start
94 |
95 | ### Installation
96 |
97 | On the basis of `Python >= 3.8` environment, install the necessary dependencies by running the following command:
98 |
99 | ```shell
100 | pip install -e .
101 | ```
102 |
103 | ### Simple Inference Example with One Image
104 |
105 | **Note: You may need 80GB GPU memory to run this script with deepseek-vl2-small and even larger for deepseek-vl2.**
106 |
107 | ```python
108 | import torch
109 | from transformers import AutoModelForCausalLM
110 |
111 | from deepseek_vl2.models import DeepseekVLV2Processor, DeepseekVLV2ForCausalLM
112 | from deepseek_vl2.utils.io import load_pil_images
113 |
114 |
115 | # specify the path to the model
116 | model_path = "deepseek-ai/deepseek-vl2-tiny"
117 | vl_chat_processor: DeepseekVLV2Processor = DeepseekVLV2Processor.from_pretrained(model_path)
118 | tokenizer = vl_chat_processor.tokenizer
119 |
120 | vl_gpt: DeepseekVLV2ForCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)
121 | vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()
122 |
123 | ## single image conversation example
124 | ## Please note that <|ref|> and <|/ref|> are designed specifically for the object localization feature. These special tokens are not required for normal conversations.
125 | ## If you would like to experience the grounded captioning functionality (responses that include both object localization and reasoning), you need to add the special token <|grounding|> at the beginning of the prompt. Examples could be found in Figure 9 of our paper.
126 | conversation = [
127 | {
128 | "role": "<|User|>",
129 | "content": "