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
andylvua/bibaandboba
https://github.com/andylvua/bibaandboba/blob/b2c5ee1ad241fe3384394c7e8cf18e1feb930457/BibaAndBoba/utils/tokenizer.py
BibaAndBoba/utils/tokenizer.py
import pkgutil from nltk.tokenize import word_tokenize from BibaAndBoba.utils.cacher import cache_to_file from BibaAndBoba.utils.progress_bar import progress_bar from BibaAndBoba.utils.languages import get_supported_language # from emoji.unicode_codes import EMOJI_UNICODE_ENGLISH stopwords = pkgutil.get_data(__name...
python
MIT
b2c5ee1ad241fe3384394c7e8cf18e1feb930457
2026-01-05T07:14:26.497544Z
false
andylvua/bibaandboba
https://github.com/andylvua/bibaandboba/blob/b2c5ee1ad241fe3384394c7e8cf18e1feb930457/BibaAndBoba/utils/nltk_punkt_downloader.py
BibaAndBoba/utils/nltk_punkt_downloader.py
""" Important! This module downloads the punkt tokenizer from NLTK. """ import nltk import ssl from BibaAndBoba.utils.logger import logger def download_punkt(): try: _create_unverified_https_context = ssl._create_unverified_context except AttributeError: logger.warning( "Warning, ...
python
MIT
b2c5ee1ad241fe3384394c7e8cf18e1feb930457
2026-01-05T07:14:26.497544Z
false
andylvua/bibaandboba
https://github.com/andylvua/bibaandboba/blob/b2c5ee1ad241fe3384394c7e8cf18e1feb930457/BibaAndBoba/utils/progress_bar.py
BibaAndBoba/utils/progress_bar.py
def progress_bar(iterable, prefix: str = '', suffix: str = '', decimals: int = 1, length: int = 50, fill: str = '█', print_end: str = "") -> list: """ Takes an iterable as input, which is the object that will be looped over. The prefix and suffix arguments are strings that will be displayed...
python
MIT
b2c5ee1ad241fe3384394c7e8cf18e1feb930457
2026-01-05T07:14:26.497544Z
false
andylvua/bibaandboba
https://github.com/andylvua/bibaandboba/blob/b2c5ee1ad241fe3384394c7e8cf18e1feb930457/BibaAndBoba/docs/source/conf.py
BibaAndBoba/docs/source/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
python
MIT
b2c5ee1ad241fe3384394c7e8cf18e1feb930457
2026-01-05T07:14:26.497544Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/prune_sparse_seq.py
prune_sparse_seq.py
from __future__ import print_function import datetime import time import torch import torch.autograd as autograd import torch.nn as nn import torch.optim as optim import codecs import pickle import math from model_word_ada.LM import LM from model_word_ada.basic import BasicRNN from model_word_ada.densenet import Dense...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/train_lm.py
train_lm.py
from __future__ import print_function import datetime import time import torch import torch.nn as nn import torch.optim as optim import codecs import pickle import math from model_word_ada.LM import LM from model_word_ada.basic import BasicRNN from model_word_ada.ldnet import LDRNN from model_word_ada.densenet import ...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/train_seq_elmo.py
train_seq_elmo.py
from __future__ import print_function import datetime import time import torch import torch.nn as nn import torch.optim as optim import codecs import pickle import math import numpy as np from model_word_ada.LM import LM from model_word_ada.basic import BasicRNN from model_word_ada.densenet import DenseRNN from model_...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/train_seq.py
train_seq.py
from __future__ import print_function import datetime import time import torch import torch.nn as nn import torch.optim as optim import codecs import pickle import math from model_word_ada.LM import LM from model_word_ada.basic import BasicRNN from model_word_ada.densenet import DenseRNN from model_word_ada.ldnet impo...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/pre_seq/encode_data.py
pre_seq/encode_data.py
""" .. module:: encode_data :synopsis: encode data for sequence labeling .. moduleauthor:: Liyuan Liu """ import pickle import argparse import os import random import numpy as np from tqdm import tqdm import itertools import functools def encode_dataset(input_file, flm_map, blm_map, gw_map, c_map, y_map): ...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/pre_seq/gene_map.py
pre_seq/gene_map.py
""" .. module:: gene_map :synopsis: generate map for sequence labeling .. moduleauthor:: Liyuan Liu """ import pickle import argparse import os import random import numpy as np from tqdm import tqdm import itertools import functools if __name__ == "__main__": parser = argparse.ArgumentParser() parser.ad...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_seq/sparse_lm.py
model_seq/sparse_lm.py
""" .. module:: sparse_lm :synopsis: sparse language model for sequence labeling .. moduleauthor:: Liyuan Liu """ import time import torch import torch.nn as nn import torch.nn.functional as F import model_seq.utils as utils class SBUnit(nn.Module): """ The basic recurrent unit for the dense-RNNs wrappe...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_seq/seqlm.py
model_seq/seqlm.py
""" .. module:: seqlm :synopsis: language model for sequence labeling .. moduleauthor:: Liyuan Liu """ import time import torch import torch.nn as nn import torch.nn.functional as F import model_seq.utils as utils import torch import torch.nn as nn import torch.nn.functional as F class BasicSeqLM(nn.Module): ...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_seq/crf.py
model_seq/crf.py
""" .. module:: crf :synopsis: conditional random field .. moduleauthor:: Liyuan Liu """ import torch import torch.nn as nn import torch.optim as optim import torch.sparse as sparse import model_seq.utils as utils class CRF(nn.Module): """ Conditional Random Field Module Parameters ---------- ...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_seq/dataset.py
model_seq/dataset.py
""" .. module:: dataset :synopsis: dataset for sequence labeling .. moduleauthor:: Liyuan Liu """ import torch import torch.nn as nn import torch.nn.functional as F import sys import pickle import random import functools import itertools from tqdm import tqdm class SeqDataset(object): """ Dataset f...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_seq/evaluator.py
model_seq/evaluator.py
""" .. module:: evaluator :synopsis: evaluator for sequence labeling .. moduleauthor:: Liyuan Liu """ import torch import numpy as np import itertools import model_seq.utils as utils from torch.autograd import Variable class eval_batch: """ Base class for evaluation, provide method to calculate f1 score...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_seq/utils.py
model_seq/utils.py
""" .. module:: utils :synopsis: utils .. moduleauthor:: Liyuan Liu """ import numpy as np import torch import json import torch import torch.nn as nn import torch.nn.init from torch.autograd import Variable def log_sum_exp(vec): """ log sum exp function. Parameters ---------- vec : ``torc...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_seq/__init__.py
model_seq/__init__.py
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_seq/elmo.py
model_seq/elmo.py
""" .. module:: elmo :synopsis: deep contextualized representation .. moduleauthor:: Liyuan Liu """ import time import torch import torch.nn as nn import torch.nn.functional as F import model_seq.utils as utils import torch import torch.nn as nn import torch.nn.functional as F class EBUnit(nn.Module): """ ...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_seq/seqlabel.py
model_seq/seqlabel.py
""" .. module:: seqlabel :synopsis: sequence labeling model .. moduleauthor:: Liyuan Liu """ import torch import torch.nn as nn import torch.nn.functional as F import model_seq.utils as utils from model_seq.crf import CRF class SeqLabel(nn.Module): """ Sequence Labeling model augumented with language mod...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_word_ada/LM.py
model_word_ada/LM.py
""" .. module:: LM :synopsis: language modeling .. moduleauthor:: Liyuan Liu """ import torch import torch.nn as nn import torch.nn.functional as F import model_word_ada.utils as utils class LM(nn.Module): """ The language model model. Parameters ---------- rnn : ``torch.nn.Module``, req...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_word_ada/dataset.py
model_word_ada/dataset.py
""" .. module:: dataset :synopsis: dataset for language modeling .. moduleauthor:: Liyuan Liu """ import torch import torch.nn as nn import torch.nn.functional as F import sys import pickle import random from tqdm import tqdm from torch.utils.data import Dataset class EvalDataset(object): """ Datas...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_word_ada/utils.py
model_word_ada/utils.py
""" .. module:: utils :synopsis: utils .. moduleauthor:: Liyuan Liu """ import numpy as np import torch import json import torch import torch.nn as nn import torch.nn.init from torch.autograd import Variable def repackage_hidden(h): """ Wraps hidden states in new Variables, to detach them from their hi...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_word_ada/basic.py
model_word_ada/basic.py
""" .. module:: basic :synopsis: basic rnn .. moduleauthor:: Liyuan Liu """ import torch import torch.nn as nn import torch.nn.functional as F import model_word_ada.utils as utils class BasicUnit(nn.Module): """ The basic recurrent unit for the vanilla stacked RNNs. Parameters ---------- uni...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_word_ada/adaptive.py
model_word_ada/adaptive.py
""" .. module:: adaptive :synopsis: adaptive softmax .. moduleauthor:: Liyuan Liu """ import torch from torch import nn from math import sqrt class AdaptiveSoftmax(nn.Module): """ The adaptive softmax layer. Modified from: https://github.com/rosinality/adaptive-softmax-pytorch/blob/master/adasoft.py...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_word_ada/__init__.py
model_word_ada/__init__.py
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_word_ada/ldnet.py
model_word_ada/ldnet.py
""" .. module:: ldnet :synopsis: LD-Net .. moduleauthor:: Liyuan Liu """ import torch import torch.nn as nn import torch.nn.functional as F import model_word_ada.utils as utils import random class BasicUnit(nn.Module): """ The basic recurrent unit for the densely connected RNNs with layer-wise dropout. ...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/model_word_ada/densenet.py
model_word_ada/densenet.py
""" .. module:: densenet :synopsis: densernn .. moduleauthor:: Liyuan Liu """ import torch import torch.nn as nn import torch.nn.functional as F import model_word_ada.utils as utils class BasicUnit(nn.Module): """ The basic recurrent unit for the densely connected RNNs. Parameters ---------- ...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/pre_word_ada/encode_data2folder.py
pre_word_ada/encode_data2folder.py
""" .. module:: encode_data2folder :synopsis: encode data folder for language modeling .. moduleauthor:: Liyuan Liu """ import pickle import argparse import os import random import numpy as np from tqdm import tqdm import itertools import functools def encode_dataset(input_folder, w_map, reverse): w_eof =...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/pre_word_ada/gene_map.py
pre_word_ada/gene_map.py
""" .. module:: gene_map :synopsis: gene map for language modeling .. moduleauthor:: Liyuan Liu """ import pickle import argparse import os import random import numpy as np from tqdm import tqdm import itertools import functools if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_ar...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
LiyuanLucasLiu/LD-Net
https://github.com/LiyuanLucasLiu/LD-Net/blob/f9489b6e7d436b7e3ed6447b797fb6ce9a886483/docs/source/conf.py
docs/source/conf.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Wrapper documentation build configuration file, created by # sphinx-quickstart on Thu Sep 14 03:49:01 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # au...
python
Apache-2.0
f9489b6e7d436b7e3ed6447b797fb6ce9a886483
2026-01-05T07:14:28.410516Z
false
jiashunwang/Neural-Pose-Transfer
https://github.com/jiashunwang/Neural-Pose-Transfer/blob/bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6/train.py
train.py
import torch import torch.optim as optim from data import SMPL_DATA from model_maxpool import NPT import utils as utils import numpy as np import time import pymesh batch_size=8 dataset = SMPL_DATA(train=True, shuffle_point = True) dataloader = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=T...
python
Apache-2.0
bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6
2026-01-05T07:14:12.473684Z
false
jiashunwang/Neural-Pose-Transfer
https://github.com/jiashunwang/Neural-Pose-Transfer/blob/bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6/model_maxpool.py
model_maxpool.py
from __future__ import print_function import torch import torch.nn as nn import numpy as np import torch.nn.functional as F class PoseFeature(nn.Module): def __init__(self, num_points = 6890): super(PoseFeature, self).__init__() self.conv1 = torch.nn.Conv1d(3, 64, 1) self.conv2 = ...
python
Apache-2.0
bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6
2026-01-05T07:14:12.473684Z
false
jiashunwang/Neural-Pose-Transfer
https://github.com/jiashunwang/Neural-Pose-Transfer/blob/bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6/model.py
model.py
from __future__ import print_function import torch import torch.nn as nn import numpy as np import torch.nn.functional as F class PoseFeature(nn.Module): def __init__(self, num_points = 6890): super(PoseFeature, self).__init__() self.conv1 = torch.nn.Conv1d(3, 64, 1) self.conv2 = ...
python
Apache-2.0
bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6
2026-01-05T07:14:12.473684Z
false
jiashunwang/Neural-Pose-Transfer
https://github.com/jiashunwang/Neural-Pose-Transfer/blob/bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6/data_generation.py
data_generation.py
import numpy as np import pickle import math import random import torch import os import trimesh import torch class SMPLModel(): def __init__(self, model_path): """ SMPL model. Parameter: --------- model_path: Path to the SMPL model parameters, pre-processed by `preprocess.py`. """ ...
python
Apache-2.0
bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6
2026-01-05T07:14:12.473684Z
false
jiashunwang/Neural-Pose-Transfer
https://github.com/jiashunwang/Neural-Pose-Transfer/blob/bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6/utils.py
utils.py
import numpy as np import torch def init_regul(source_vertices, source_faces): sommet_A_source = source_vertices[source_faces[:, 0]] sommet_B_source = source_vertices[source_faces[:, 1]] sommet_C_source = source_vertices[source_faces[:, 2]] target = [] target.append(np.sqrt( np.sum((sommet_A_source...
python
Apache-2.0
bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6
2026-01-05T07:14:12.473684Z
false
jiashunwang/Neural-Pose-Transfer
https://github.com/jiashunwang/Neural-Pose-Transfer/blob/bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6/demo.py
demo.py
import torch from model import NPT import numpy as np import pymesh net_G=NPT() net_G.cuda() net_G.load_state_dict(torch.load('original_169.model')) def face_reverse(faces): identity_faces=faces face_dict={} for i in range(len(random_sample)): face_dict[random_sample[i]]=i new_f=[] for i ...
python
Apache-2.0
bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6
2026-01-05T07:14:12.473684Z
false
jiashunwang/Neural-Pose-Transfer
https://github.com/jiashunwang/Neural-Pose-Transfer/blob/bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6/evaluate.py
evaluate.py
import trimesh import numpy as np #make sure the order of identity points and gt points are same #for original_model, please keep the identity and pose points in different order ours_mesh = trimesh.load('ours.obj') ours_vertices=ours_mesh.vertices ours_bbox= np.array([[np.max(ours_vertices[:,0]), np.max(ours_vertice...
python
Apache-2.0
bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6
2026-01-05T07:14:12.473684Z
false
jiashunwang/Neural-Pose-Transfer
https://github.com/jiashunwang/Neural-Pose-Transfer/blob/bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6/data.py
data.py
import torch.utils.data as data import torch import numpy as np import pymesh import random class SMPL_DATA(data.Dataset): def __init__(self, train, npoints=6890, shuffle_point = False): self.train = train self.shuffle_point = shuffle_point self.npoints = npoints self.path='./smpl...
python
Apache-2.0
bd62eef7bad6752ae6cab7fa40bc1935e4dfeec6
2026-01-05T07:14:12.473684Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/setup.py
setup.py
from setuptools import setup, find_packages from pathlib import Path import os if __name__ == "__main__": with Path(Path(__file__).parent, "README.md").open(encoding="utf-8") as file: long_description = file.read() def _read_reqs(relpath): fullpath = os.path.join(os.path.dirname(__file__), rel...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/tests/test_similarity.py
tests/test_similarity.py
import os import numpy as np import pytest import tempfile import torch import open_clip from clip_video_encode import clip_video_encode def test_similarity(): test_path = "tests/test_videos" with tempfile.TemporaryDirectory() as tmpdir: clip_video_encode( ["tests/test_videos/vid1.mp4", "...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/tests/test_encode.py
tests/test_encode.py
import os import numpy as np import pytest import tempfile from clip_video_encode import clip_video_encode FRAME_COUNTS = { "vid1.mp4": 56, "vid2.mp4": 134, "https://www.youtube.com/watch?v=a8DM-tD9w2I": 20, } def test_encode(): test_path = "tests/test_videos" with tempfile.TemporaryDirectory() ...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/tests/test_modules.py
tests/test_modules.py
import os import glob import pytest import tempfile import open_clip import multiprocessing import numpy as np import tarfile import torch from torchvision.transforms import Compose, Normalize, ToPILImage, ToTensor from clip_video_encode.utils import block2dl from clip_video_encode.simplemapper import FrameMapper fr...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/writer.py
clip_video_encode/writer.py
"""save embeddings.""" import os import json import fsspec import numpy as np import webdataset as wds from io import BytesIO write_fmt = { "mp4": lambda data: data, # pylint: disable=unnecessary-lambda "txt": lambda data: str(data), # pylint: disable=unnecessary-lambda "json": lambda data: json.dumps...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/cli.py
clip_video_encode/cli.py
"""cli entry point""" import fire from clip_video_encode import clip_video_encode def main(): """Main entry point""" fire.Fire(clip_video_encode) if __name__ == "__main__": main()
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/reader.py
clip_video_encode/reader.py
"""handles input parsing.""" import os import json import glob import pyarrow.parquet as pq import pyarrow.csv as csv_pq import pyarrow as pa class Reader: """Parses input into required data. Necessary columns (reader will always look for these columns in parquet and csv): * videoLoc - location of video...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/simplemapper.py
clip_video_encode/simplemapper.py
"""simplemapper - simple frame -> embedding mapper.""" import torch import numpy as np import open_clip from torchvision.transforms import ToPILImage try: from omegaconf import OmegaConf from taming.models.vqgan import VQModel, GumbelVQ except ImportError as e: print("Missing imports") def load_config(c...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/distributed.py
clip_video_encode/distributed.py
"""functions for distributing computation""" import os def world_info_from_env(): """get info from dist env""" local_rank = 0 for v in ("LOCAL_RANK", "MPI_LOCALRANKID", "SLURM_LOCALID", "OMPI_COMM_WORLD_LOCAL_RANK"): if v in os.environ: local_rank = int(os.environ[v]) break...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/utils.py
clip_video_encode/utils.py
"""clip-video-encode utils.""" from torch.utils.data import Dataset, DataLoader class HelperDataset(Dataset): """Helper dataset that preprocesses frames""" def __init__(self, imgs, preprocess): super().__init__() self.imgs = imgs self.preprocess = preprocess def __len__(self): ...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/__init__.py
clip_video_encode/__init__.py
"""clip video encode""" from .clip_video_encode import clip_video_encode
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/clip_video_encode.py
clip_video_encode/clip_video_encode.py
"""encode video with CLIP""" import re import sys import time import math import torch from video2numpy.frame_reader import FrameReader from .reader import Reader, read_shard from .simplemapper import FrameMapper from .writer import FileWriter, WebDatasetWriter from .distributed import world_info_from_env from .hand...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/handle_chunk.py
clip_video_encode/handle_chunk.py
"""encode chunk with CLIP""" import numpy as np import torch from .utils import block2dl # BATCH_SIZE = 256 BATCH_SIZE = 128 N_DATASET_WORKERS = 6 def encode_chunk( frames, ind_dict, writer, mapper, meta, ids, use_dst_name, device, input_format="table", captioning_strategy="...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/live_numpy_encoder.py
clip_video_encode/live_numpy_encoder.py
"""encode numpy video frame arrays with CLIP from directory as they come in from other processes.""" import os import time import numpy as np from .utils import block2dl from .writer import FileWriter N_DATASET_WORKERS = 6 BATCH_SIZE = 256 class LiveNumpyEncoder: """class that watches directory for set of nump...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/dataset/dataset_reader.py
clip_video_encode/dataset/dataset_reader.py
""" utils for processing datasets of format described in https://github.com/iejMac/clip-video-encode/pull/13 used https://github.com/rom1504/laion-prepro/blob/main/laion5B/usage_guide/dataloader_pytorch.py as template """ import io import json import numpy as np import open_clip import torch import webdataset as wds...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/dataset/create_shards.py
clip_video_encode/dataset/create_shards.py
"""creates EmbeddingWebDataset from Processed Dataset format""" import os import os.path import random import argparse import json from csv import writer from pathlib import Path import numpy as np import webdataset as wds parser = argparse.ArgumentParser("""Generate Embedding WebDataset from Processed Dataset.""") ...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/dataset/kinetics700_example_process.py
clip_video_encode/dataset/kinetics700_example_process.py
""" processes s3://s-datasets/kinetics-700/kinetics700_embeddings into processed dataset format. run from kinetics700_embeddings directory (so train/val/test at the same level) """ import os import glob import json import shutil from tqdm import tqdm SPLITS = ["train", "val", "test"] PROCESSED_DIR = "processed" sa...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/clip_video_encode/dataset/__init__.py
clip_video_encode/dataset/__init__.py
"""clip-video-encode dataset.""" from .dataset_reader import EmbeddingWebDatasetReader
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/examples/reader.py
examples/reader.py
""" The example below is showcasing how to read an Embedding WebDataset uing the EmbeddingWebDatasetReader object. In order to follow along, below are instructions to download the dataset used in this example. In a directory of your choice, from the command line call: git clone https://huggingface.co/datasets/iejMa...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/examples/live_encoding.py
examples/live_encoding.py
import os import glob import clip import torch import time from torchvision.transforms import ToPILImage, Compose, ToTensor, Normalize from clip_video_encode.live_numpy_encoder import LiveNumpyEncoder from clip_video_encode.simplemapper import FrameMapper def _convert_image_to_rgb(image): return image.convert("...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iejMac/clip-video-encode
https://github.com/iejMac/clip-video-encode/blob/b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7/examples/thing_detector/thing_detector.py
examples/thing_detector/thing_detector.py
"""thing detector script using clip-video-encode.""" import clip import numpy as np import sys import torch from matplotlib import pyplot as plt def conv_filter(probs, width=10): padded_probs = np.pad(probs, width // 2) prob_filt = np.zeros(probs.shape) for i in range(len(probs)): prob_filt[i] =...
python
MIT
b5df2c7e116d937ac1e67b14c1516f2f07cfe5b7
2026-01-05T07:14:33.720079Z
false
iniwym/XT-Bot
https://github.com/iniwym/XT-Bot/blob/f577d2a3161a5209b059b07aada4c087a2aa2894/Python/src/T-Bot.py
Python/src/T-Bot.py
import sys import json import os import requests import telegram from datetime import datetime, timedelta from pathlib import Path from typing import (Optional, Dict, Any, List, Tuple, DefaultDict, BinaryIO, IO) from collections import defaultdict # 将项目根目录添加到模块搜索路径 _project_root = Path(__file__).resolve().parent.paren...
python
MIT
f577d2a3161a5209b059b07aada4c087a2aa2894
2026-01-05T07:14:36.260795Z
true
iniwym/XT-Bot
https://github.com/iniwym/XT-Bot/blob/f577d2a3161a5209b059b07aada4c087a2aa2894/Python/src/INI-XT-Bot.py
Python/src/INI-XT-Bot.py
import sys import json import os import subprocess import telegram from datetime import datetime from pathlib import Path from typing import List, Dict # 将项目根目录添加到模块搜索路径 _project_root = Path(__file__).resolve().parent.parent sys.path.append(str(_project_root)) from utils.log_utils import LogUtils # -----------------...
python
MIT
f577d2a3161a5209b059b07aada4c087a2aa2894
2026-01-05T07:14:36.260795Z
false
iniwym/XT-Bot
https://github.com/iniwym/XT-Bot/blob/f577d2a3161a5209b059b07aada4c087a2aa2894/Python/src/X-Bot.py
Python/src/X-Bot.py
import sys import json import os from datetime import datetime, timedelta from pathlib import Path # 将项目根目录添加到模块搜索路径 _project_root = Path(__file__).resolve().parent.parent sys.path.append(str(_project_root)) from utils.log_utils import LogUtils # -------------------- # 配置区 # -------------------- class Config: # ...
python
MIT
f577d2a3161a5209b059b07aada4c087a2aa2894
2026-01-05T07:14:36.260795Z
false
iniwym/XT-Bot
https://github.com/iniwym/XT-Bot/blob/f577d2a3161a5209b059b07aada4c087a2aa2894/Python/utils/encrypt_7z.py
Python/utils/encrypt_7z.py
import sys import py7zr from pathlib import Path # 将项目根目录添加到模块搜索路径 _project_root = Path(__file__).resolve().parent.parent sys.path.append(str(_project_root)) from utils.log_utils import LogUtils logger = LogUtils().get_logger() logger.info("🔄 Encrypt_7z 初始化完成") def compress_folders(dirs, output_file, password): ...
python
MIT
f577d2a3161a5209b059b07aada4c087a2aa2894
2026-01-05T07:14:36.260795Z
false
iniwym/XT-Bot
https://github.com/iniwym/XT-Bot/blob/f577d2a3161a5209b059b07aada4c087a2aa2894/Python/utils/get_redis_config.py
Python/utils/get_redis_config.py
import os import json import sys import redis from redis.exceptions import RedisError from pathlib import Path # 将项目根目录添加到模块搜索路径 _project_root = Path(__file__).resolve().parent.parent sys.path.append(str(_project_root)) from utils.log_utils import LogUtils logger = LogUtils().get_logger() logger.info("🔄 Get_Redis_Co...
python
MIT
f577d2a3161a5209b059b07aada4c087a2aa2894
2026-01-05T07:14:36.260795Z
false
iniwym/XT-Bot
https://github.com/iniwym/XT-Bot/blob/f577d2a3161a5209b059b07aada4c087a2aa2894/Python/utils/log_utils.py
Python/utils/log_utils.py
import sys import json import logging from datetime import datetime from pathlib import Path from dotenv import load_dotenv # 获取python根目录(向上找两级) python_root = Path(__file__).resolve().parent.parent # 获取项目根目录(向上找三级) project_root = python_root.parent # 定位到项目根目录的 .env env_path = project_root / '.env' load_dotenv(dotenv_...
python
MIT
f577d2a3161a5209b059b07aada4c087a2aa2894
2026-01-05T07:14:36.260795Z
false
iniwym/XT-Bot
https://github.com/iniwym/XT-Bot/blob/f577d2a3161a5209b059b07aada4c087a2aa2894/Python/utils/sync_data.py
Python/utils/sync_data.py
import sys import os import shutil import argparse from pathlib import Path # 将项目根目录添加到模块搜索路径 _project_root = Path(__file__).resolve().parent.parent sys.path.append(str(_project_root)) from utils.log_utils import LogUtils logger = LogUtils().get_logger() logger.info("🔄 Sync_Data 初始化完成") def sync_dirs(source, dest)...
python
MIT
f577d2a3161a5209b059b07aada4c087a2aa2894
2026-01-05T07:14:36.260795Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/__init__.py
src/cellcharter/__init__.py
from importlib.metadata import version from . import datasets, gr, pl, tl __all__ = ["gr", "pl", "tl", "datasets"] __version__ = version("cellcharter")
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/_utils.py
src/cellcharter/_utils.py
from __future__ import annotations from typing import Union import numpy as np AnyRandom = Union[int, np.random.RandomState, None] def str2list(value: Union[str, list]) -> list: """Check whether value is a string. If so, converts into a list containing value.""" return [value] if isinstance(value, str) els...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/_constants/_pkg_constants.py
src/cellcharter/_constants/_pkg_constants.py
"""Internal constants not exposed to the user.""" class Key: class obs: @classmethod @property def sample(cls) -> str: return "sample"
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/datasets/_dataset.py
src/cellcharter/datasets/_dataset.py
from copy import copy from squidpy.datasets._utils import AMetadata _codex_mouse_spleen = AMetadata( name="codex_mouse_spleen", doc_header="Pre-processed CODEX dataset of mouse spleen from `Goltsev et al " "<https://doi.org/10.1016/j.cell.2018.07.010>`__.", shape=(707474, 29), url="https://figshar...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/datasets/__init__.py
src/cellcharter/datasets/__init__.py
from ._dataset import * # noqa: F403
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/pl/_shape.py
src/cellcharter/pl/_shape.py
from __future__ import annotations import warnings from pathlib import Path import anndata as ad import geopandas import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns from anndata import AnnData from squidpy._docs import d from ._utils import adjust_box_widths def plot_bound...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/pl/_autok.py
src/cellcharter/pl/_autok.py
from __future__ import annotations from pathlib import Path import matplotlib.pyplot as plt import pandas as pd import seaborn as sns from cellcharter.tl import ClusterAutoK def autok_stability(autok: ClusterAutoK, save: str | Path | None = None, return_ax: bool = False) -> None: """ Plot the clustering st...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/pl/_nhood.py
src/cellcharter/pl/_nhood.py
from __future__ import annotations import warnings from itertools import combinations from pathlib import Path from types import MappingProxyType from typing import Any, Mapping import matplotlib.pyplot as plt import numpy as np import pandas as pd from anndata import AnnData from matplotlib import rcParams from matp...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/pl/__init__.py
src/cellcharter/pl/__init__.py
from ._autok import autok_stability from ._group import enrichment, proportion from ._nhood import diff_nhood_enrichment, nhood_enrichment from ._shape import boundaries, shape_metrics
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/pl/_group.py
src/cellcharter/pl/_group.py
from __future__ import annotations import warnings from pathlib import Path import matplotlib import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns from anndata import AnnData from matplotlib.colors import LogNorm, Normalize from matplotlib.legend_handler import HandlerTuple fro...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/pl/_utils.py
src/cellcharter/pl/_utils.py
from __future__ import annotations from copy import copy from types import MappingProxyType from typing import Any, Mapping import matplotlib as mpl import numpy as np import seaborn as sns import squidpy as sq from anndata import AnnData from matplotlib import colors as mcolors from matplotlib import pyplot as plt f...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/gr/_build.py
src/cellcharter/gr/_build.py
from __future__ import annotations import numpy as np import pandas as pd import scipy.sparse as sps from anndata import AnnData from scipy.sparse import csr_matrix from squidpy._constants._pkg_constants import Key from squidpy._docs import d from squidpy.gr._utils import _assert_connectivity_key @d.dedent def remov...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/gr/_nhood.py
src/cellcharter/gr/_nhood.py
from __future__ import annotations import warnings from concurrent.futures import ProcessPoolExecutor, as_completed from functools import partial from itertools import combinations import numpy as np import pandas as pd import scipy.sparse as sp from anndata import AnnData from squidpy._constants._pkg_constants impor...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/gr/__init__.py
src/cellcharter/gr/__init__.py
from ._aggr import aggregate_neighbors from ._build import connected_components, remove_intra_cluster_links, remove_long_links from ._group import enrichment from ._nhood import diff_nhood_enrichment, nhood_enrichment
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/gr/_group.py
src/cellcharter/gr/_group.py
from __future__ import annotations import numpy as np import pandas as pd from anndata import AnnData from squidpy._docs import d from tqdm import tqdm def _proportion(obs, id_key, val_key, normalize=True): df = pd.pivot(obs[[id_key, val_key]].value_counts().reset_index(), index=id_key, columns=val_key) df[d...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/gr/_aggr.py
src/cellcharter/gr/_aggr.py
from __future__ import annotations import warnings from typing import Optional, Union import numpy as np import scipy.sparse as sps from anndata import AnnData from scipy.sparse import spdiags from squidpy._constants._pkg_constants import Key as sqKey from squidpy._docs import d from tqdm.auto import tqdm from cellc...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/gr/_utils.py
src/cellcharter/gr/_utils.py
"""Graph utilities.""" from __future__ import annotations from anndata import AnnData def _assert_distances_key(adata: AnnData, key: str) -> None: if key not in adata.obsp: key_added = key.replace("_distances", "") raise KeyError( f"Spatial distances key `{key}` not found in `adata.o...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/tl/_shape.py
src/cellcharter/tl/_shape.py
from __future__ import annotations import warnings from collections import deque from concurrent.futures import ProcessPoolExecutor, as_completed import h5py import networkx as nx import numpy as np import pandas as pd import shapely import sknw from anndata import AnnData from anndata._io.specs.registry import _REGI...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/tl/_autok.py
src/cellcharter/tl/_autok.py
from __future__ import annotations import concurrent.futures import inspect import json import logging import os import pickle import warnings from collections import defaultdict from copy import deepcopy from pathlib import Path from typing import Any, Dict, List import anndata as ad import numpy as np import pandas...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/tl/_trvae.py
src/cellcharter/tl/_trvae.py
from __future__ import annotations import os from typing import Optional from anndata import AnnData, read_h5ad from torch import nn try: from scarches.models import TRVAE as scaTRVAE from scarches.models import trVAE from scarches.models.base._utils import _validate_var_names except ImportError: cl...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/tl/__init__.py
src/cellcharter/tl/__init__.py
from ._autok import ClusterAutoK from ._gmm import Cluster, GaussianMixture from ._shape import ( boundaries, curl, elongation, linearity, purity, relative_component_size_metric, ) from ._trvae import TRVAE
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/tl/_gmm.py
src/cellcharter/tl/_gmm.py
from __future__ import annotations import logging from typing import List, Tuple, cast import anndata as ad import numpy as np import pandas as pd import scipy.sparse as sps import torch from pytorch_lightning import Trainer from torchgmm.base.data import ( DataLoader, TensorLike, collate_tensor, data...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/src/cellcharter/tl/_utils.py
src/cellcharter/tl/_utils.py
from itertools import combinations import numpy as np from joblib import Parallel, delayed from sklearn.metrics import adjusted_rand_score def _stability(labels, similarity_function=adjusted_rand_score, n_jobs=-1): clusters = list(labels.keys()) max_runs = len(labels[clusters[0]]) num_combinations = max_...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/conftest.py
tests/conftest.py
import time from urllib.error import HTTPError import anndata as ad import numpy as np import pytest import scanpy as sc from squidpy._constants._pkg_constants import Key _adata = sc.read("tests/_data/test_data.h5ad") _adata.raw = _adata.copy() @pytest.fixture() def non_visium_adata() -> ad.AnnData: non_visium_...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/tools/test_gmm.py
tests/tools/test_gmm.py
import pytest import scipy.sparse as sps import squidpy as sq import cellcharter as cc class TestCluster: @pytest.mark.parametrize("dataset_name", ["mibitof"]) def test_sparse(self, dataset_name: str): download_dataset = getattr(sq.datasets, dataset_name) adata = download_dataset() ad...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/tools/test_autok.py
tests/tools/test_autok.py
import numpy as np import pytest import scipy.sparse as sps import squidpy as sq import cellcharter as cc class TestClusterAutoK: @pytest.mark.parametrize("dataset_name", ["mibitof"]) def test_spatial_proteomics(self, dataset_name: str): download_dataset = getattr(sq.datasets, dataset_name) a...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/tools/test_shape.py
tests/tools/test_shape.py
import numpy as np import pandas as pd from anndata import AnnData from shapely import Polygon import cellcharter as cc # Test for cc.tl.boundaries, that computes the topological boundaries of sets of cells. class TestBoundaries: def test_boundaries(self, codex_adata: AnnData): cc.gr.connected_components...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/graph/test_build.py
tests/graph/test_build.py
import numpy as np import pandas as pd import scipy.sparse as sps import squidpy as sq from anndata import AnnData from squidpy._constants._pkg_constants import Key import cellcharter as cc class TestRemoveLongLinks: def test_remove_long_links(self, non_visium_adata: AnnData): # ground-truth removing con...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/graph/test_aggregate_neighbors.py
tests/graph/test_aggregate_neighbors.py
import numpy as np import scipy.sparse as sps import squidpy as sq from anndata import AnnData from cellcharter.gr import aggregate_neighbors class TestAggregateNeighbors: def test_aggregate_neighbors(self): n_layers = 2 aggregations = ["mean", "var"] G = sps.csr_matrix( np.a...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/graph/test_diff_nhood.py
tests/graph/test_diff_nhood.py
import numpy as np import pytest from anndata import AnnData import cellcharter as cc _CLUSTER_KEY = "cell_type" _CONDITION_KEY = "sample" key = f"{_CLUSTER_KEY}_{_CONDITION_KEY}_diff_nhood_enrichment" class TestDiffNhoodEnrichment: def test_enrichment(self, codex_adata: AnnData): n_conditions = codex_a...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/graph/test_group.py
tests/graph/test_group.py
import numpy as np import squidpy as sq import cellcharter as cc GROUP_KEY = "batch" LABEL_KEY = "Cell_class" key = f"{GROUP_KEY}_{LABEL_KEY}_enrichment" adata = sq.datasets.merfish() class TestEnrichment: def test_enrichment(self): cc.gr.enrichment(adata, group_key=GROUP_KEY, label_key=LABEL_KEY) ...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/graph/test_nhood.py
tests/graph/test_nhood.py
import numpy as np import scipy import squidpy as sq from squidpy._constants._pkg_constants import Key import cellcharter as cc _CK = "cell type" key = Key.uns.nhood_enrichment(_CK) adata = sq.datasets.imc() sq.gr.spatial_neighbors(adata, coord_type="generic", delaunay=True) cc.gr.remove_long_links(adata) class Te...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/plotting/test_plot_stability.py
tests/plotting/test_plot_stability.py
import pytest import scipy.sparse as sps import squidpy as sq import cellcharter as cc class TestPlotStability: @pytest.mark.parametrize("dataset_name", ["mibitof"]) def test_spatial_proteomics(self, dataset_name: str): download_dataset = getattr(sq.datasets, dataset_name) adata = download_da...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false
CSOgroup/cellcharter
https://github.com/CSOgroup/cellcharter/blob/461165f57ee9ac5614f550d99a82bf01fb086948/tests/plotting/test_group.py
tests/plotting/test_group.py
import matplotlib.pyplot as plt import pytest import squidpy as sq try: from matplotlib.colormaps import get_cmap except ImportError: from matplotlib.pyplot import get_cmap import cellcharter as cc GROUP_KEY = "batch" LABEL_KEY = "Cell_class" key = f"{GROUP_KEY}_{LABEL_KEY}_enrichment" adata = sq.datasets.m...
python
BSD-3-Clause
461165f57ee9ac5614f550d99a82bf01fb086948
2026-01-05T07:13:12.201168Z
false