This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Global site tag (gtag.js) - Google Analytics --> | |
<script> | |
var dnt = (navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack); | |
var doNotTrack = (dnt == "1" || dnt == "yes"); | |
if (!doNotTrack) { | |
(function () { | |
var ga = document.createElement('script'); | |
ga.type = 'text/javascript'; | |
ga.async = true; | |
ga.src = 'https://www.googletagmanager.com/gtag/js?id=UA-ADD-YOUR-ID'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from shutil import copyfile | |
def _make_sure_dir_exist(path): | |
if not os.path.isdir(path): | |
os.mkdir(path) | |
def refactor_dataset_folder(root_path, classes_map, img_path_root=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to change a model's fc layer. | |
# with this code, you can get a model's features | |
del model.fc | |
model.fc = lambda x:x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import models | |
model = getattr(models, 'AlexNet')() | |
# same as: | |
# model = models.AlexNet() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train_size = int(0.8 * len(full_dataset)) | |
test_size = len(full_dataset) - train_size | |
train_dataset, test_dataset = torch.utils.data.random_split(full_dataset, [train_size, test_size]) | |
## or | |
dataset = MyCustomDataset(my_path) | |
batch_size = 16 | |
validation_split = .2 | |
shuffle_dataset = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import toml | |
from argparse import ArgumentParser | |
from os import path | |
import collections | |
# python 3.8+ compatibility | |
try: | |
collectionsAbc = collections.abc | |
except: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Package logger add level feature log for *log*. | |
*/ | |
package logger | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
import torch | |
import argparse | |
import scipy.io | |
def get_right_and_junk_index(query_label, gallery_labels, query_camera_label=None, gallery_camera_labels=None): | |
same_label_index = np.argwhere(gallery_labels == query_label) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import types | |
from typing import Union, List, Optional, Callable | |
import diffusers | |
import torch | |
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion import StableDiffusionPipelineOutput | |
@torch.inference_mode() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import types | |
from typing import List, Optional, Tuple, Union | |
import torch | |
from diffusers.models import PriorTransformer | |
from diffusers.pipelines import DiffusionPipeline, StableDiffusionImageVariationPipeline | |
from diffusers.schedulers import UnCLIPScheduler | |
from diffusers.utils import logging, randn_tensor | |
from transformers import CLIPTextModelWithProjection, CLIPTokenizer | |
from transformers.models.clip.modeling_clip import CLIPTextModelOutput |