text stringlengths 1 93.6k |
|---|
# cam_gb = gb * mask[..., np.newaxis]
|
# image_dict['cam_gb'] = norm_image(cam_gb)
|
save_image(image_dict, os.path.basename(path), args.index)
|
if __name__ == "__main__":
|
"""
|
Usage:export KMP_DUPLICATE_LIB_OK=TRUE
|
python detection/demo.py --config-file detection/faster_rcnn_R_50_C4.yaml \
|
--input ./examples/pic1.jpg \
|
--opts MODEL.WEIGHTS ./model_final_b1acc2.pkl MODEL.DEVICE cpu
|
"""
|
mp.set_start_method("spawn", force=True)
|
arguments = get_parser().parse_args()
|
main(arguments)
|
# <FILESEP>
|
"""
|
A demo script to finetune a pretrained VAE on ImageNet with the EQ-VAE setup.
|
"""
|
if __name__ == "__main__":
|
import torch
|
import torch.utils.data as data
|
import lightning.pytorch as pl
|
from lightning.pytorch.loggers import WandbLogger
|
from lightning.pytorch.callbacks import ModelCheckpoint, LearningRateMonitor
|
from torchvision.transforms import (
|
Compose,
|
Resize,
|
RandomCrop,
|
RandomHorizontalFlip,
|
RandomVerticalFlip,
|
ToTensor,
|
Lambda,
|
)
|
from diffusers import AutoencoderKL
|
from convnext_perceptual_loss import ConvNextType
|
from hl_dataset.imagenet import ImageNetDataset
|
from hakulatent.transform import (
|
LatentTransformCompose,
|
LatentTransformSwitch,
|
RotationTransform,
|
ScaleDownTransform,
|
ScaleUpCropTransform,
|
CropTransform,
|
RandomAffineTransform,
|
)
|
from hakulatent.trainer import LatentTrainer
|
from hakulatent.losses import AdvLoss, ReconLoss
|
else:
|
# This if-else can speedup multi-worker dataloader in windows
|
print("Subprocess Starting:", __name__)
|
BASE_MODEL = "KBlueLeaf/EQ-SDXL-VAE"
|
SUB_FOLDER = None
|
EPOCHS = 1
|
BATCH_SIZE = 8
|
GRAD_ACC = 4
|
GRAD_CKPT = False
|
LOSS_TYPE = "mse"
|
LPIPS_NET = "vgg"
|
USE_CONVNEXT = True
|
ADV_START_ITER = 1000
|
NUM_WORKERS = 8
|
SIZE = 256
|
LR = 5e-5
|
DLR = 1e-3
|
def process(x):
|
return x * 2 - 1
|
def deprocess(x):
|
return x * 0.5 + 0.5
|
if __name__ == "__main__":
|
split = "train"
|
transform = Compose(
|
[
|
Resize(SIZE),
|
RandomCrop((SIZE, SIZE)),
|
RandomHorizontalFlip(),
|
RandomVerticalFlip(),
|
ToTensor(),
|
Lambda(process),
|
]
|
)
|
dataset = ImageNetDataset(split, transform)
|
loader = data.DataLoader(
|
dataset,
|
batch_size=BATCH_SIZE,
|
shuffle=True,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.