repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
bbmokhtari/django-translations
https://github.com/bbmokhtari/django-translations/blob/9dc21b3beff0a71a01663095f4ca7eb98b60b64e/sample/__init__.py
sample/__init__.py
python
BSD-3-Clause
9dc21b3beff0a71a01663095f4ca7eb98b60b64e
2026-01-05T07:08:43.795656Z
false
bbmokhtari/django-translations
https://github.com/bbmokhtari/django-translations/blob/9dc21b3beff0a71a01663095f4ca7eb98b60b64e/sample/apps.py
sample/apps.py
from django.apps import AppConfig class SampleConfig(AppConfig): name = 'sample'
python
BSD-3-Clause
9dc21b3beff0a71a01663095f4ca7eb98b60b64e
2026-01-05T07:08:43.795656Z
false
bbmokhtari/django-translations
https://github.com/bbmokhtari/django-translations/blob/9dc21b3beff0a71a01663095f4ca7eb98b60b64e/sample/urls.py
sample/urls.py
from django.urls import path from sample import views app_name = 'sample' urlpatterns = [ path( 'continent/list/', views.ContinentListView.as_view(), name='continent_list' ), path( 'continent/<str:pk>/', views.ContinentView.as_view(), name='continent_detail...
python
BSD-3-Clause
9dc21b3beff0a71a01663095f4ca7eb98b60b64e
2026-01-05T07:08:43.795656Z
false
bbmokhtari/django-translations
https://github.com/bbmokhtari/django-translations/blob/9dc21b3beff0a71a01663095f4ca7eb98b60b64e/sample/migrations/0001_initial.py
sample/migrations/0001_initial.py
# Generated by Django 2.1.7 on 2019-03-15 15:21 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='City', fields=[ ...
python
BSD-3-Clause
9dc21b3beff0a71a01663095f4ca7eb98b60b64e
2026-01-05T07:08:43.795656Z
false
bbmokhtari/django-translations
https://github.com/bbmokhtari/django-translations/blob/9dc21b3beff0a71a01663095f4ca7eb98b60b64e/sample/migrations/__init__.py
sample/migrations/__init__.py
python
BSD-3-Clause
9dc21b3beff0a71a01663095f4ca7eb98b60b64e
2026-01-05T07:08:43.795656Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/src/retrieval_graph/graph.py
src/retrieval_graph/graph.py
"""Main entrypoint for the conversational retrieval graph. This module defines the core structure and functionality of the conversational retrieval graph. It includes the main graph definition, state management, and key functions for processing user inputs, generating queries, retrieving relevant documents, and formul...
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/src/retrieval_graph/prompts.py
src/retrieval_graph/prompts.py
"""Default prompts.""" RESPONSE_SYSTEM_PROMPT = """You are a helpful AI assistant. Answer the user's questions based on the retrieved documents. {retrieved_docs} System time: {system_time}""" QUERY_SYSTEM_PROMPT = """Generate search queries to retrieve documents that may help answer the user's question. Previously, ...
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/src/retrieval_graph/state.py
src/retrieval_graph/state.py
"""State management for the retrieval graph. This module defines the state structures and reduction functions used in the retrieval graph. It includes definitions for document indexing, retrieval, and conversation management. Classes: IndexState: Represents the state for document indexing operations. Retrieva...
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/src/retrieval_graph/configuration.py
src/retrieval_graph/configuration.py
"""Define the configurable parameters for the agent.""" from __future__ import annotations from dataclasses import dataclass, field, fields from typing import Annotated, Any, Literal, Type, TypeVar from langchain_core.runnables import RunnableConfig, ensure_config from retrieval_graph import prompts @dataclass(kw...
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/src/retrieval_graph/retrieval.py
src/retrieval_graph/retrieval.py
"""Manage the configuration of various retrievers. This module provides functionality to create and manage retrievers for different vector store backends, specifically Elasticsearch, Pinecone, and MongoDB. The retrievers support filtering results by user_id to ensure data isolation between users. """ import os from ...
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/src/retrieval_graph/utils.py
src/retrieval_graph/utils.py
"""Utility functions for the retrieval graph. This module contains utility functions for handling messages, documents, and other common operations in project. Functions: get_message_text: Extract text content from various message formats. format_docs: Convert documents to an xml-formatted string. """ from l...
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/src/retrieval_graph/index_graph.py
src/retrieval_graph/index_graph.py
"""This "graph" simply exposes an endpoint for a user to upload docs to be indexed.""" from typing import Sequence from langchain_core.documents import Document from langchain_core.runnables import RunnableConfig from langgraph.graph import StateGraph from retrieval_graph import retrieval from retrieval_graph.config...
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/src/retrieval_graph/__init__.py
src/retrieval_graph/__init__.py
"""Retrieval Graph Module This module provides a conversational retrieval graph system that enables intelligent document retrieval and question answering based on user inputs. The main components of this system include: 1. A state management system for handling conversation context and document retrieval. 2. A query...
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/tests/conftest.py
tests/conftest.py
import pytest @pytest.fixture(scope="session") def anyio_backend(): return "asyncio"
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/tests/unit_tests/test_configuration.py
tests/unit_tests/test_configuration.py
from retrieval_graph.configuration import Configuration def test_configuration_from_none() -> None: Configuration.from_runnable_config({"user_id": "foo"})
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/tests/unit_tests/__init__.py
tests/unit_tests/__init__.py
"""Unit tests for your graph."""
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/tests/integration_tests/test_graph.py
tests/integration_tests/test_graph.py
import uuid import pytest from langchain_core.runnables import RunnableConfig from langsmith import expect, unit from retrieval_graph import graph, index_graph pytestmark = pytest.mark.anyio @unit async def test_retrieval_graph() -> None: simple_doc = "Cats have been observed performing synchronized swimming r...
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
langchain-ai/retrieval-agent-template
https://github.com/langchain-ai/retrieval-agent-template/blob/062c3400e51a3b25351a7dfe8f0446a1d4713fb8/tests/integration_tests/__init__.py
tests/integration_tests/__init__.py
"""Integration tests for your graph."""
python
MIT
062c3400e51a3b25351a7dfe8f0446a1d4713fb8
2026-01-05T07:08:44.673033Z
false
titu1994/keras-coordconv
https://github.com/titu1994/keras-coordconv/blob/6dfb03919bcddce545672a0cc10107322ca04fa9/coord_theano.py
coord_theano.py
from keras.engine import Layer, InputSpec from keras import backend as K from keras.utils.generic_utils import get_custom_objects class _CoordinateChannel(Layer): """ Adds Coordinate Channels to the input tensor. Due to Theano backend limitations, it is required to pass a static batch size when defining ...
python
MIT
6dfb03919bcddce545672a0cc10107322ca04fa9
2026-01-05T07:08:45.747682Z
false
titu1994/keras-coordconv
https://github.com/titu1994/keras-coordconv/blob/6dfb03919bcddce545672a0cc10107322ca04fa9/coord.py
coord.py
from tensorflow.python.keras.layers import Layer, InputSpec from tensorflow.keras import backend as K import tensorflow as tf from tensorflow.keras.utils import get_custom_objects class _CoordinateChannel(Layer): """ Adds Coordinate Channels to the input tensor. # Arguments rank: An integer, the rank...
python
MIT
6dfb03919bcddce545672a0cc10107322ca04fa9
2026-01-05T07:08:45.747682Z
false
titu1994/keras-coordconv
https://github.com/titu1994/keras-coordconv/blob/6dfb03919bcddce545672a0cc10107322ca04fa9/experiments/train_quadrant_classifier.py
experiments/train_quadrant_classifier.py
import os import sys import numpy as np import matplotlib.pyplot as plt from keras.layers import Input, Conv2D, Flatten, Softmax from keras.models import Model from keras.callbacks import ModelCheckpoint from keras.optimizers import Adam sys.path.append('..') from coord import CoordinateChannel2D if not os.path.exi...
python
MIT
6dfb03919bcddce545672a0cc10107322ca04fa9
2026-01-05T07:08:45.747682Z
false
titu1994/keras-coordconv
https://github.com/titu1994/keras-coordconv/blob/6dfb03919bcddce545672a0cc10107322ca04fa9/experiments/make_dataset.py
experiments/make_dataset.py
import os import numpy as np from sklearn.model_selection import train_test_split # Can be either `quadrant` or `uniform` type = 'quadrant' assert type in ['uniform', 'quadrant'] if not os.path.exists('data-uniform/'): os.makedirs('data-uniform/') if not os.path.exists('data-quadrant/'): os.makedirs('data-q...
python
MIT
6dfb03919bcddce545672a0cc10107322ca04fa9
2026-01-05T07:08:45.747682Z
false
titu1994/keras-coordconv
https://github.com/titu1994/keras-coordconv/blob/6dfb03919bcddce545672a0cc10107322ca04fa9/experiments/train_uniform_classifier.py
experiments/train_uniform_classifier.py
import os import sys import numpy as np import matplotlib.pyplot as plt from keras.layers import Input, Conv2D, Flatten, Softmax from keras.models import Model from keras.callbacks import ModelCheckpoint from keras.optimizers import Adam sys.path.append('..') from coord import CoordinateChannel2D if not os.path.exi...
python
MIT
6dfb03919bcddce545672a0cc10107322ca04fa9
2026-01-05T07:08:45.747682Z
false
titu1994/keras-coordconv
https://github.com/titu1994/keras-coordconv/blob/6dfb03919bcddce545672a0cc10107322ca04fa9/experiments/__init__.py
experiments/__init__.py
python
MIT
6dfb03919bcddce545672a0cc10107322ca04fa9
2026-01-05T07:08:45.747682Z
false
titu1994/keras-coordconv
https://github.com/titu1994/keras-coordconv/blob/6dfb03919bcddce545672a0cc10107322ca04fa9/checks/shape_check_1d.py
checks/shape_check_1d.py
import numpy as np ip_shape = (10, 5, 20) batch, d, c = ip_shape ip = np.ones(ip_shape, dtype='float32') # 1D conv xx_range = np.tile(np.expand_dims(np.arange(0, d), axis=0), [batch, 1]) print('xx range', xx_range.shape) xx_range = np.expand_dims(xx_range, axis=-1) print('xx range expand dims', xx...
python
MIT
6dfb03919bcddce545672a0cc10107322ca04fa9
2026-01-05T07:08:45.747682Z
false
titu1994/keras-coordconv
https://github.com/titu1994/keras-coordconv/blob/6dfb03919bcddce545672a0cc10107322ca04fa9/checks/shape_check_2d.py
checks/shape_check_2d.py
import numpy as np ip_shape = (10, 6, 5, 20) batch, w, h, c = ip_shape ip = np.ones(ip_shape, dtype='float32') # 2D conv xx_ones = np.ones([batch, h], dtype='int32') xx_ones = np.expand_dims(xx_ones, axis=-1) print('xx expand dims', xx_ones.shape) xx_range = np.tile(np.expand_dims(np.arange(0, w), axis=0), ...
python
MIT
6dfb03919bcddce545672a0cc10107322ca04fa9
2026-01-05T07:08:45.747682Z
false
titu1994/keras-coordconv
https://github.com/titu1994/keras-coordconv/blob/6dfb03919bcddce545672a0cc10107322ca04fa9/checks/shape_check_3d.py
checks/shape_check_3d.py
import numpy as np ip_shape = (10, 8, 5, 4, 20) batch, d, w, h, c = ip_shape ip = np.ones(ip_shape, dtype='float32') # 3D conv xx_ones = np.ones([batch, h], dtype='int32') xx_ones = np.expand_dims(xx_ones, axis=-1) print('xx expand dims', xx_ones.shape) xx_range = np.tile(np.expand_dims(np.arange(0, w), axis=0), ...
python
MIT
6dfb03919bcddce545672a0cc10107322ca04fa9
2026-01-05T07:08:45.747682Z
false
ZenithVal/OSCLeash
https://github.com/ZenithVal/OSCLeash/blob/0be678a33b43e8fc33dc529265704fcc3e5e0cdd/OSCLeash.py
OSCLeash.py
from threading import Thread import json import sys import os import time from Controllers.DataController import DefaultConfig, ConfigSettings, Leash from Controllers.PackageController import Package from Controllers.ThreadController import Program # Make sure to change this to the correct version number on releases....
python
MIT
0be678a33b43e8fc33dc529265704fcc3e5e0cdd
2026-01-05T07:08:44.736736Z
false
ZenithVal/OSCLeash
https://github.com/ZenithVal/OSCLeash/blob/0be678a33b43e8fc33dc529265704fcc3e5e0cdd/Controllers/ThreadController.py
Controllers/ThreadController.py
from pythonosc.udp_client import SimpleUDPClient from threading import Lock, Thread import time import os import ctypes #Required for colored error messages. from Controllers.DataController import ConfigSettings, Leash class Program: # Class variable to determine if the program is running on a thread (Prevents m...
python
MIT
0be678a33b43e8fc33dc529265704fcc3e5e0cdd
2026-01-05T07:08:44.736736Z
false
ZenithVal/OSCLeash
https://github.com/ZenithVal/OSCLeash/blob/0be678a33b43e8fc33dc529265704fcc3e5e0cdd/Controllers/DataController.py
Controllers/DataController.py
import time import os import ctypes #Required for colored error messages. DefaultConfig = { "IP": "127.0.0.1", "ListeningPort": 9001, "SendingPort": 9000, "RunDeadzone": 0.70, "WalkDeadzone": 0.15, "StrengthMultiplier": 1.2, "UpDownCompensation": 1.0, "Up...
python
MIT
0be678a33b43e8fc33dc529265704fcc3e5e0cdd
2026-01-05T07:08:44.736736Z
false
ZenithVal/OSCLeash
https://github.com/ZenithVal/OSCLeash/blob/0be678a33b43e8fc33dc529265704fcc3e5e0cdd/Controllers/PackageController.py
Controllers/PackageController.py
import time import ctypes #Required for colored error messages. from pythonosc.dispatcher import Dispatcher from pythonosc import osc_server from threading import Lock, Thread from Controllers.DataController import Leash from Controllers.ThreadController import Program from tinyoscquery.queryservice import OSCQuerySe...
python
MIT
0be678a33b43e8fc33dc529265704fcc3e5e0cdd
2026-01-05T07:08:44.736736Z
false
ZenithVal/OSCLeash
https://github.com/ZenithVal/OSCLeash/blob/0be678a33b43e8fc33dc529265704fcc3e5e0cdd/Testing/OSC_SimpleTestSender.py
Testing/OSC_SimpleTestSender.py
""" Small example OSC client """ import random import time from pythonosc import udp_client LeashNameString = "Leash_North" PORT = 9001 IP = "127.0.0.1" def sendData(): Directional = random.random() LeashZPos = 0.0 LeashZNeg = 0.0 LeashXPos = 0.0 LeashXNeg = 0.0 if Directional >= .75: # North ...
python
MIT
0be678a33b43e8fc33dc529265704fcc3e5e0cdd
2026-01-05T07:08:44.736736Z
false
ZenithVal/OSCLeash
https://github.com/ZenithVal/OSCLeash/blob/0be678a33b43e8fc33dc529265704fcc3e5e0cdd/Scripts/BuildInstaller.py
Scripts/BuildInstaller.py
#Installer using cx_freeze stable(6.15.x), and python 3.11 (3.12 should be supported in cx_freeze 6.16.x) from cx_Freeze import setup, Executable #Update version numbers on new releases. # Dependencies are automatically detected. build_options = {'packages': [], 'excludes': []} base = 'console' # Create EXE and 2 sh...
python
MIT
0be678a33b43e8fc33dc529265704fcc3e5e0cdd
2026-01-05T07:08:44.736736Z
false
provectus/swiss-army-kube
https://github.com/provectus/swiss-army-kube/blob/ae10efa45a12f0b1040bc8637e5f632734f3cfaa/.scripts/validate_variables.py
.scripts/validate_variables.py
#! /usr/bin/env python3 import hcl2 import glob import sys def get_variables(): variables = {} for file in glob.glob("**/variables.tf", recursive=True): with open(file, "r") as f: data = hcl2.load(f) for var in data['variable']: name = list(var.keys())[0] ...
python
Apache-2.0
ae10efa45a12f0b1040bc8637e5f632734f3cfaa
2026-01-05T07:08:46.819166Z
false
noobpk/auto-change-tor-ip
https://github.com/noobpk/auto-change-tor-ip/blob/1ff2f46c5c20437623437bfd707fa6c228bd8d6d/log.py
log.py
import logging from colorlog import ColoredFormatter def setup_logging(): logger = logging.getLogger() logger.setLevel(logging.INFO) color_formatter = ColoredFormatter( "%(log_color)s[%(asctime)s] [%(levelname)-4s]%(reset)s - %(message)s", datefmt='%d-%m-%y %H:%M:%S', r...
python
MIT
1ff2f46c5c20437623437bfd707fa6c228bd8d6d
2026-01-05T07:08:47.916098Z
false
noobpk/auto-change-tor-ip
https://github.com/noobpk/auto-change-tor-ip/blob/1ff2f46c5c20437623437bfd707fa6c228bd8d6d/autorip.py
autorip.py
#!/usr/local/bin/python3 import time import os import sys import ssl from python_socks.sync import Proxy import random from log import * import subprocess import gevent.monkey gevent.monkey.patch_all() print(r'''\033[1;31m \n _ _ | | (_) __ _ _ _| |_ _...
python
MIT
1ff2f46c5c20437623437bfd707fa6c228bd8d6d
2026-01-05T07:08:47.916098Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/setup.py
setup.py
""" Setup """ from setuptools import setup, find_packages from codecs import open from os import path here = path.abspath(path.dirname(__file__)) def _read_reqs(relpath): fullpath = path.join(path.dirname(__file__), relpath) with open(fullpath) as f: return [s.strip() for s in f.readlines() if (s.stri...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/demo.py
demo.py
import torch from PIL import Image from src.open_clip.factory import create_model from torchvision.transforms import Compose, ToTensor, Normalize, CenterCrop, Resize if __name__ == "__main__": with torch.no_grad(): img_path = "path_to_your_img" device = "cuda:0" output_dir = "vis" m...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/tools/generate_text_embeddings_siglip.py
tools/generate_text_embeddings_siglip.py
# Modified from [ViLD](https://github.com/tensorflow/tpu/tree/master/models/official/detection/projects/vild) import numpy as np import torch import torch.nn.functional as F from tqdm import tqdm import open_clip def article(name): return 'an' if name[0] in 'aeiou' else 'a' def processed_name(name, rm_dot=False): ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/tools/vis_k_means.py
tools/vis_k_means.py
from PIL import Image from featup.util import UnNormalize import matplotlib.pyplot as plt from open_clip.transform import det_image_transform import numpy as np import torch import os from tqdm import tqdm model_name="EVA02-CLIP-B-16" # model_name="EVA02-CLIP-L-14-336" ckpt="logs/exp34/checkpoints/epoch_6.pt" mean=[0...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/tools/k_means.py
tools/k_means.py
import logging import cv2 from sklearn.cluster import KMeans import torch import torch.nn.functional as F import numpy as np from tqdm import tqdm from open_clip.model import get_cast_dtype from training.distributed import is_master from training.precision import get_autocast from training.zero_shot import multi_gpu_sy...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/tools/generate_text_embeddings.py
tools/generate_text_embeddings.py
# Modified from [ViLD](https://github.com/tensorflow/tpu/tree/master/models/official/detection/projects/vild) import numpy as np import torch import torch.nn.functional as F from tqdm import tqdm import open_clip def article(name): return 'an' if name[0] in 'aeiou' else 'a' def processed_name(name, rm_dot=False): ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/tools/precompute_knns.py
tools/precompute_knns.py
import torch import torch.nn.functional as F import numpy as np from tqdm import tqdm from training.distributed import is_master from training.precision import get_autocast import os import json @torch.no_grad() def run_knns(model, data, args): """ 基于 vfm 的相似度, 计算每个训练集样本的 KNN 样本, 并建立 image_id -> KNN 映射 """ ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/tools/vis_featmap_corr.py
tools/vis_featmap_corr.py
import math import sys import os sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) import torch import torchvision.transforms as T from PIL import Image from featup.util import UnNormalize,remove_axes from featup.plotting import plot_feats, plot_lang_heatmaps from open_clip.factory import ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/tools/segmentation.py
tools/segmentation.py
import logging import math import torch import torch.nn.functional as F import numpy as np from tqdm import tqdm from open_clip import create_model from open_clip.model import get_cast_dtype from training.distributed import is_master from training.precision import get_autocast from training.zero_shot import multi_gpu_s...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/modified_resnet.py
src/open_clip/modified_resnet.py
from collections import OrderedDict import torch from torch import nn from torch.nn import functional as F from open_clip.utils import freeze_batch_norm_2d from torchvision.ops import roi_align class FrozenBatchNorm2d(nn.Module): _version = 3 def __init__(self, num_features, eps=1e-5): super().__ini...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/pretrained.py
src/open_clip/pretrained.py
import hashlib import os import urllib import warnings from functools import partial from typing import Dict, Union from tqdm import tqdm from .version import __version__ try: from huggingface_hub import hf_hub_download hf_hub_download = partial(hf_hub_download, library_name="open_clip", library_version=__ve...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/timm_model.py
src/open_clip/timm_model.py
""" timm model adapter Wraps timm (https://github.com/rwightman/pytorch-image-models) models for use as a vision tower in CLIP model. """ import logging from collections import OrderedDict import torch import torch.nn as nn from torchvision.ops import roi_align import torch.nn.functional as F try: import timm ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/transform.py
src/open_clip/transform.py
import warnings from dataclasses import dataclass, asdict from typing import Any, Dict, Optional, Sequence, Tuple, Union import torch import torch.nn as nn import torchvision.transforms.functional as F from torchvision.transforms.v2 import ScaleJitter from torchvision.transforms import Normalize, Compose, RandomResize...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/constants.py
src/open_clip/constants.py
OPENAI_DATASET_MEAN = (0.48145466, 0.4578275, 0.40821073) OPENAI_DATASET_STD = (0.26862954, 0.26130258, 0.27577711)
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/hf_configs.py
src/open_clip/hf_configs.py
# HF architecture dict: arch_dict = { # https://huggingface.co/docs/transformers/model_doc/roberta#roberta "roberta": { "config_names": { "context_length": "max_position_embeddings", "vocab_size": "vocab_size", "width": "hidden_size", "heads": "num_attenti...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/hf_model.py
src/open_clip/hf_model.py
""" huggingface model adapter Wraps HuggingFace transformers (https://github.com/huggingface/transformers) models for use as a text tower in CLIP model. """ import re import torch import torch.nn as nn from torch import TensorType try: import transformers from transformers import AutoModel, AutoTokenizer, A...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/model.py
src/open_clip/model.py
""" CLIP Model Adapted from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI. """ from dataclasses import dataclass import logging import math from typing import Optional, Tuple, Union import numpy as np import torch import torch.nn.functional as F from torch import nn from torch.util...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/version.py
src/open_clip/version.py
__version__ = '2.16.0'
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/utils.py
src/open_clip/utils.py
from itertools import repeat import collections.abc from torch import nn as nn from torchvision.ops.misc import FrozenBatchNorm2d def freeze_batch_norm_2d(module, module_match={}, name=''): """ Converts all `BatchNorm2d` and `SyncBatchNorm` layers of provided module into `FrozenBatchNorm2d`. If `module` is ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/factory.py
src/open_clip/factory.py
import json import logging import os import pathlib import re from copy import deepcopy from pathlib import Path from typing import Any, Dict, Optional, Tuple, Union import torchvision.transforms as T import torch from .constants import OPENAI_DATASET_MEAN, OPENAI_DATASET_STD from .model import CLIP, CustomTextCLIP, co...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/loss.py
src/open_clip/loss.py
import torch import torch.nn as nn from torch.nn import functional as F try: import torch.distributed.nn from torch import distributed as dist has_distributed = True except ImportError: has_distributed = False try: import horovod.torch as hvd except ImportError: hvd = None def gather_featur...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/customs.py
src/open_clip/customs.py
from torch import Tensor from torch.nn import MultiheadAttention from torch.nn import functional as F from typing import Optional, Tuple class MultiheadSelfAttention(MultiheadAttention): def forward(self, query: Tensor, key: Tensor, value: Tensor, key_padding_mask: Optional[Tensor] = None, need_we...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/__init__.py
src/open_clip/__init__.py
from .coca_model import CoCa from .constants import OPENAI_DATASET_MEAN, OPENAI_DATASET_STD from .factory import create_model, create_model_and_transforms, create_model_from_pretrained, get_tokenizer from .factory import list_models, add_model_config, get_model_config, load_checkpoint from .loss import ClipLoss, Distil...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/push_to_hf_hub.py
src/open_clip/push_to_hf_hub.py
import argparse import json from pathlib import Path from tempfile import TemporaryDirectory from typing import Optional, Tuple import torch try: from huggingface_hub import ( create_repo, get_hf_file_metadata, hf_hub_download, hf_hub_url, repo_type_and_id_from_hf_id, ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/tokenizer.py
src/open_clip/tokenizer.py
""" CLIP tokenizer Copied from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI. """ import gzip import html import os from functools import lru_cache from typing import Union, List import ftfy import regex as re import torch # https://stackoverflow.com/q/62691279 import os os.enviro...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/generation_utils.py
src/open_clip/generation_utils.py
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/transformer.py
src/open_clip/transformer.py
import logging from collections import OrderedDict import math from typing import Callable, Optional, Sequence, Tuple import torch from torch import nn from torch.nn import functional as F from torch.utils.checkpoint import checkpoint from torchvision.ops import roi_align from .utils import to_2tuple class LayerNormF...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
true
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/coca_model.py
src/open_clip/coca_model.py
from typing import Optional import torch from torch import nn from torch.nn import functional as F import numpy as np from dataclasses import dataclass from .transformer import ( LayerNormFp32, LayerNorm, QuickGELU, MultimodalTransformer, ) from .model import CLIPTextCfg, CLIPVisionCfg, _build_vision_...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/openai.py
src/open_clip/openai.py
""" OpenAI pretrained model functions Adapted from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI. """ import os import warnings from typing import List, Optional, Union import torch from .model import build_model_from_openai_state_dict, convert_weights_to_lp, get_cast_dtype from ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/siglip/declip_siglip.py
src/open_clip/siglip/declip_siglip.py
from transformers import SiglipModel,SiglipVisionModel from transformers.models.siglip.modeling_siglip import (SiglipVisionTransformer,SiglipMultiheadAttentionPoolingHead,SiglipVisionEmbeddings) from typing import Optional, Tuple, Union from transformers.models.siglip.configuration_siglip import SiglipConfig, SiglipVis...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/siglip/__init__.py
src/open_clip/siglip/__init__.py
from .declip_siglip import *
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/modified_resnet.py
src/open_clip/eva_clip/modified_resnet.py
from collections import OrderedDict import torch from torch import nn from torch.nn import functional as F from open_clip.eva_clip.utils import freeze_batch_norm_2d class Bottleneck(nn.Module): expansion = 4 def __init__(self, inplanes, planes, stride=1): super().__init__() # all conv laye...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/pretrained.py
src/open_clip/eva_clip/pretrained.py
import hashlib import os import urllib import warnings from functools import partial from typing import Dict, Union from tqdm import tqdm try: from huggingface_hub import hf_hub_download _has_hf_hub = True except ImportError: hf_hub_download = None _has_hf_hub = False def _pcfg(url='', hf_hub='', fi...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/timm_model.py
src/open_clip/eva_clip/timm_model.py
""" timm model adapter Wraps timm (https://github.com/rwightman/pytorch-image-models) models for use as a vision tower in CLIP model. """ import logging from collections import OrderedDict import torch import torch.nn as nn try: import timm from timm.models.layers import Mlp, to_2tuple try: # old...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/transform.py
src/open_clip/eva_clip/transform.py
from typing import Optional, Sequence, Tuple import torch import torch.nn as nn import torchvision.transforms.functional as F from torchvision.transforms import Normalize, Compose, RandomResizedCrop, InterpolationMode, ToTensor, Resize, \ CenterCrop from .constants import OPENAI_DATASET_MEAN, OPENAI_DATASET_STD ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/constants.py
src/open_clip/eva_clip/constants.py
OPENAI_DATASET_MEAN = (0.48145466, 0.4578275, 0.40821073) OPENAI_DATASET_STD = (0.26862954, 0.26130258, 0.27577711)
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/hf_configs.py
src/open_clip/eva_clip/hf_configs.py
# HF architecture dict: arch_dict = { # https://huggingface.co/docs/transformers/model_doc/roberta#roberta "roberta": { "config_names": { "context_length": "max_position_embeddings", "vocab_size": "vocab_size", "width": "hidden_size", "heads": "num_attention_heads", ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/hf_model.py
src/open_clip/eva_clip/hf_model.py
""" huggingface model adapter Wraps HuggingFace transformers (https://github.com/huggingface/transformers) models for use as a text tower in CLIP model. """ import re import torch import torch.nn as nn from torch.nn import functional as F from torch import TensorType try: import transformers from transformer...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/model.py
src/open_clip/eva_clip/model.py
""" CLIP Model Adapted from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI. """ import os from dataclasses import dataclass from typing import Optional, Tuple, Union from functools import partial import numpy as np import torch import torch.nn.functional as F from torch import nn t...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/eva_vit_model.py
src/open_clip/eva_clip/eva_vit_model.py
# -------------------------------------------------------- # Adapted from https://github.com/microsoft/unilm/tree/master/beit # -------------------------------------------------------- import math import os from functools import partial import torch import torch.nn as nn import torch.nn.functional as F try: from t...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
true
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/utils.py
src/open_clip/eva_clip/utils.py
from itertools import repeat import collections.abc import logging import math import numpy as np import torch from torch import nn as nn from torchvision.ops.misc import FrozenBatchNorm2d import torch.nn.functional as F # open CLIP def resize_clip_pos_embed(state_dict, model, interpolation: str = 'bicubic', seq_dim=...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/factory.py
src/open_clip/eva_clip/factory.py
import json import logging import os import pathlib import re from copy import deepcopy from pathlib import Path from typing import Optional, Tuple, Union, Dict, Any import torch from .constants import OPENAI_DATASET_MEAN, OPENAI_DATASET_STD from .model import CLIP, CustomCLIP, convert_weights_to_lp, convert_to_custom...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/loss.py
src/open_clip/eva_clip/loss.py
import math import torch import torch.nn as nn from torch.nn import functional as F try: import torch.distributed.nn from torch import distributed as dist has_distributed = True except ImportError: has_distributed = False try: import horovod.torch as hvd except ImportError: hvd = None from ti...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/__init__.py
src/open_clip/eva_clip/__init__.py
from .constants import OPENAI_DATASET_MEAN, OPENAI_DATASET_STD from .factory import create_model, create_model_and_transforms, create_model_from_pretrained, get_tokenizer from .factory import list_models, add_model_config, get_model_config, load_checkpoint from .loss import ClipLoss from .model import CLIP, CustomCLIP,...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/rope.py
src/open_clip/eva_clip/rope.py
from math import pi import torch from torch import nn from einops import rearrange, repeat import logging import torch.nn.functional as F def broadcat(tensors, dim = -1): num_tensors = len(tensors) shape_lens = set(list(map(lambda t: len(t.shape), tensors))) assert len(shape_lens) == 1, 'tensors must all ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/tokenizer.py
src/open_clip/eva_clip/tokenizer.py
""" CLIP tokenizer Copied from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI. """ import gzip import html import os from functools import lru_cache from typing import Union, List import ftfy import regex as re import torch # https://stackoverflow.com/q/62691279 import os os.enviro...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/transformer.py
src/open_clip/eva_clip/transformer.py
import os import logging from collections import OrderedDict import math from typing import Callable, Optional, Sequence import numpy as np import torch from torch import nn from torch.nn import functional as F try: from timm.models.layers import trunc_normal_ except: from timm.layers import trunc_normal_ ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/open_clip/eva_clip/openai.py
src/open_clip/eva_clip/openai.py
""" OpenAI pretrained model functions Adapted from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI. """ import os import warnings from typing import List, Optional, Union import torch from .model import build_model_from_openai_state_dict, convert_weights_to_lp, get_cast_dtype from ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/build_sam.py
src/segment_anything/build_sam.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from functools import partial from .modeling import ImageEncoderViT, MaskDecoder, PromptEncoder, Sam, TwoWa...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/predictor.py
src/segment_anything/predictor.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from segment_anything.modeling import Sam from typing import Optional, Tuple from .util...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/__init__.py
src/segment_anything/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from .build_sam import ( build_sam, build_sam_vit_h, build_sam_vit_l, build_sam_vit_b, sam_model_regis...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/automatic_mask_generator.py
src/segment_anything/automatic_mask_generator.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from torchvision.ops.boxes import batched_nms, box_area # type: ignore from typing impor...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/utils/amg.py
src/segment_anything/utils/amg.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch import math from copy import deepcopy from itertools import product from typing import An...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/utils/__init__.py
src/segment_anything/utils/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree.
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/utils/transforms.py
src/segment_anything/utils/transforms.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from torch.nn import functional as F from torchvision.transforms.functional import resize,...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/utils/onnx.py
src/segment_anything/utils/onnx.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn from torch.nn import functional as F from typing import Tuple from ..modeling import ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/modeling/image_encoder.py
src/segment_anything/modeling/image_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F from typing import Optional, Tuple, Type from .common...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/modeling/prompt_encoder.py
src/segment_anything/modeling/prompt_encoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from torch import nn from typing import Any, Optional, Tuple, Type from .common import L...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/modeling/common.py
src/segment_anything/modeling/common.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn from typing import Type class MLPBlock(nn.Module): def __init__( self, ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/modeling/sam.py
src/segment_anything/modeling/sam.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn from torch.nn import functional as F from typing import Any, Dict, List, Tuple from .i...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/modeling/__init__.py
src/segment_anything/modeling/__init__.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. from .sam import Sam from .image_encoder import ImageEncoderViT from .mask_decoder import MaskDecoder from .prompt_encoder...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/modeling/transformer.py
src/segment_anything/modeling/transformer.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from torch import Tensor, nn import math from typing import Tuple, Type from .common import MLPBlock clas...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/segment_anything/modeling/mask_decoder.py
src/segment_anything/modeling/mask_decoder.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn from torch.nn import functional as F from typing import List, Tuple, Type from .common...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false
xiaomoguhz/DeCLIP
https://github.com/xiaomoguhz/DeCLIP/blob/ed89f59c4d5939de0048e3622e6927274a63bcf7/src/training/params.py
src/training/params.py
import argparse import ast def get_default_params(model_name): # Params from paper (https://arxiv.org/pdf/2103.00020.pdf) model_name = model_name.lower() if "vit" in model_name: return {"lr": 5.0e-4, "beta1": 0.9, "beta2": 0.98, "eps": 1.0e-6} else: return {"lr": 5.0e-4, "beta1": 0.9, ...
python
Apache-2.0
ed89f59c4d5939de0048e3622e6927274a63bcf7
2026-01-05T07:08:37.834068Z
false