docs: add docstrings

Wrote an openai script and custom prompt to generate them.
This commit is contained in:
Bryce 2023-12-15 12:31:28 -08:00 committed by Bryce Drennan
parent e7b6fc40fa
commit 316114e660
123 changed files with 245 additions and 0 deletions

View File

@ -1,3 +1,4 @@
"""Pythonic AI generation of images and videos"""
import os
# tells pytorch to allow MPS usage (for Mac M1 compatibility)

View File

@ -1,3 +1,4 @@
"""Functions for creating animations from images."""
import os.path
import cv2

View File

@ -1,3 +1,5 @@
"""Functions for generating and processing images"""
import logging
import os
import re

View File

@ -1,3 +1,5 @@
"""Functions for generating refined images"""
import logging
from typing import List, Optional

View File

@ -1,3 +1,5 @@
"""Decorator and parsers for command scheduling"""
from typing import Iterable
from imaginairy.utils import frange

View File

@ -1,3 +1,5 @@
"""Command for colorizing images with AI"""
import logging
import click

View File

@ -1,3 +1,5 @@
"""Command for generating image descriptions"""
import click

View File

@ -1,3 +1,5 @@
"""Command for AI-powered image editing"""
import click
from imaginairy import config

View File

@ -1,3 +1,5 @@
"""Command for applying preset image edits"""
import click

View File

@ -1,3 +1,5 @@
"""Command-line interface for AI-driven image generation"""
import click
from imaginairy.cli.clickshell_mod import ImagineColorsCommand

View File

@ -1,3 +1,5 @@
"""CLI for AI-powered image generation"""
import logging
import click

View File

@ -1,3 +1,5 @@
"""Code for starting an HTTP API server"""
import logging
import click

View File

@ -1,3 +1,5 @@
"""Context managers and functions for image generation CLI"""
import logging
import math
from contextlib import contextmanager

View File

@ -1,3 +1,5 @@
"""CLI commands for model training and image preparation"""
import logging
import click

View File

@ -1,3 +1,5 @@
"""Command for upscaling images with AI"""
import logging
import click

View File

@ -1,3 +1,5 @@
"""Command for generating AI-powered videos"""
import logging
import click

View File

@ -1,3 +1,5 @@
"""Functions for colorizing black and white images"""
import logging
from PIL import Image, ImageEnhance, ImageStat

View File

@ -1,3 +1,5 @@
"""Classes and constants for AI model configuration"""
from dataclasses import dataclass
from typing import Any, List

View File

@ -1,3 +1,5 @@
"""Functions for assessing image blurriness"""
import cv2
from imaginairy.img_utils import pillow_img_to_opencv_img

View File

@ -1,3 +1,5 @@
"""Functions for generating and processing image masks"""
from functools import lru_cache
from typing import Optional, Sequence

View File

@ -1,3 +1,5 @@
"""Functions for generating image captions"""
import os
import os.path
from functools import lru_cache

View File

@ -1,3 +1,5 @@
"""Functions for image-text similarity assessment"""
from functools import lru_cache
from typing import Sequence

View File

@ -1,3 +1,5 @@
"""Code for enhancing facial images"""
import logging
from functools import lru_cache

View File

@ -1,3 +1,5 @@
"""Functions for detecting and cropping faces"""
import numpy as np
from imaginairy.enhancers.face_restoration_codeformer import face_restore_helper

View File

@ -1,3 +1,5 @@
"""Functions for expanding text prompts with phraselists"""
import gzip
import os.path
import random

View File

@ -1,3 +1,5 @@
"""Functions for image upscaling using RealESRGAN"""
import numpy as np
import torch
from PIL import Image

View File

@ -1,3 +1,5 @@
"""Classes and functions for image upscaling"""
from functools import lru_cache
import numpy as np

View File

@ -1,3 +1,5 @@
"""Functions for image tiling and reconstruction"""
# inspired by https://github.com/ProGamerGov/neural-dream/blob/master/neural_dream/dream_tile.py
# but with all the bugs fixed and lots of simplifications
# MIT License

View File

@ -1,3 +1,5 @@
"""FastAPI application for image generation"""
import logging
import os.path
import sys

View File

@ -1,3 +1,5 @@
"""Classes for image generation API models"""
from datetime import datetime
from typing import List, Optional

View File

@ -1,3 +1,5 @@
"""API routes for image generation service"""
import uuid
from fastapi import APIRouter

View File

@ -1,3 +1,5 @@
"""Functions and class for image generation and encoding"""
import base64
from io import BytesIO

View File

@ -1,3 +1,5 @@
"""Classes and functions for edge detection in images"""
from functools import lru_cache
import cv2

View File

@ -1,3 +1,5 @@
"""Functions for human pose estimation"""
import math
from collections import OrderedDict
from functools import lru_cache

View File

@ -1,3 +1,5 @@
"""Utilities for image generation logging"""
import logging
import logging.config
import re

View File

@ -1,3 +1,5 @@
"""Classes for learning rate scheduling"""
import numpy as np

View File

@ -1,3 +1,5 @@
"""Classes and functions for managing AI models"""
import logging
import os
import re

View File

@ -1,3 +1,5 @@
"""Classes and functions for attention mechanisms in neural networks"""
import math
from functools import lru_cache

View File

@ -1,3 +1,5 @@
"""Classes for image autoencoding and manipulation"""
# pylama:ignore=W0613
import logging
import math

View File

@ -1,3 +1,5 @@
"""Classes for controlled image generation"""
import torch
from torch import nn

View File

@ -1,3 +1,5 @@
"""Classes for text and image encoding"""
import kornia
import torch
from einops import repeat

View File

@ -1,3 +1,5 @@
"""Classes for diffusion-based image generation"""
# pytorch_diffusion + derived encoder decoder
import gc
import math

View File

@ -1,3 +1,5 @@
"""Classes for generative diffusion models"""
import math
from abc import abstractmethod
from typing import Optional

View File

@ -1,3 +1,5 @@
"""Classes for image upscaling diffusion models"""
from functools import partial
import numpy as np

View File

@ -1,3 +1,5 @@
"""Utilities for diffusion model operations"""
# adopted from
# https://github.com/openai/improved-diffusion/blob/main/improved_diffusion/gaussian_diffusion.py
# and

View File

@ -1,3 +1,5 @@
"""Classes for parametric Gaussian distributions"""
import numpy as np
import torch

View File

@ -1,3 +1,5 @@
"""Classes for exponential moving average tracking"""
import torch
from torch import nn

View File

@ -1,3 +1,5 @@
"""Classes for text encoding transformations"""
import open_clip
import torch
from torch import nn

View File

@ -1,3 +1,5 @@
"""Code for depth estimation with MiDaS models"""
# based on https://github.com/isl-org/MiDaS
from functools import lru_cache

View File

@ -1,3 +1,5 @@
"""Classes for loading model weights"""
import torch
from imaginairy import config

View File

@ -1,3 +1,5 @@
"""Functions and classes for neural network construction"""
import torch
from torch import nn

View File

@ -1,3 +1,5 @@
"""Classes for depth estimation from images"""
import torch
from torch import nn

View File

@ -1,3 +1,5 @@
"""Functions and classes for image preprocessing"""
import math
import cv2

View File

@ -1,3 +1,5 @@
"""Classes and functions for Vision Transformer processing"""
import math
import types

View File

@ -1,3 +1,5 @@
"""Refinement modules for image generation"""
import logging
import math
from functools import lru_cache

View File

@ -1,3 +1,5 @@
"""Classes for attention-based neural networks"""
import logging
import math
from inspect import isfunction

View File

@ -1,3 +1,5 @@
"""Classes for autoencoder-based image generation"""
import logging
import math
import re

View File

@ -1,3 +1,5 @@
"""Classes for discriminator loss computation"""
from typing import Dict, Iterator, List, Optional, Tuple, Union
import numpy as np

View File

@ -1,3 +1,5 @@
"""Classes for latent space perceptual loss"""
import torch
import torch.nn as nn

View File

@ -1,3 +1,5 @@
"""Classes for image discrimination"""
import functools
import torch.nn as nn

View File

@ -1,3 +1,5 @@
"""Utilities for model checkpoint management and normalization layers"""
import hashlib
import os

View File

@ -1,3 +1,5 @@
"""Functions for discriminator loss calculation"""
import torch
import torch.nn.functional as F

View File

@ -1,3 +1,5 @@
"""Classes and functions for tensor regularization"""
from abc import abstractmethod
from typing import Any, Tuple

View File

@ -1,3 +1,5 @@
"""Classes for vector quantization regularization"""
import logging
from abc import abstractmethod
from typing import Dict, Iterator, Literal, Optional, Tuple, Union

View File

@ -1,3 +1,5 @@
"""Classes for spatio-temporal video processing"""
import logging
from typing import Callable, Iterable, Union

View File

@ -1,3 +1,5 @@
"""Classes for stochastic diffusion models"""
import logging
import math
from contextlib import contextmanager

View File

@ -1,3 +1,5 @@
"""Classes for image denoising operations"""
from typing import TYPE_CHECKING, Dict, Union
import torch

View File

@ -1,3 +1,5 @@
"""Classes for denoiser scaling calculations"""
from abc import ABC, abstractmethod
from typing import Tuple

View File

@ -1,3 +1,5 @@
"""Classes for denoiser weighting strategies"""
import torch

View File

@ -1,3 +1,5 @@
"""Classes for discretizing diffusion steps"""
from abc import abstractmethod
from functools import partial

View File

@ -1,3 +1,5 @@
"""Classes for guiding diffusion models"""
import logging
from abc import ABC, abstractmethod
from typing import Dict, List, Optional, Tuple, Union

View File

@ -1,3 +1,5 @@
"""Classes for diffusion model loss calculation"""
from typing import Dict, List, Optional, Tuple, Union
import torch

View File

@ -1,3 +1,5 @@
"""Classes for diffusion loss weighting"""
from abc import ABC, abstractmethod
import torch

View File

@ -1,3 +1,5 @@
"""Classes for diffusion-based image generation"""
# pytorch_diffusion + derived encoder decoder
import logging
import math

View File

@ -1,3 +1,5 @@
"""Classes for generative image modeling"""
import logging
import math
from abc import abstractmethod

View File

@ -1,3 +1,5 @@
"""Functions for diffusion sampling calculations"""
import torch
from scipy import integrate

View File

@ -1,3 +1,5 @@
"""Classes for stochastic sampling strategies"""
import torch
from imaginairy.utils import default, instantiate_from_config

View File

@ -1,3 +1,5 @@
"""Classes for video generation models"""
from typing import List, Optional, Union
import torch as th

View File

@ -1,3 +1,5 @@
"""Wrappers for diffusion model integration"""
import torch
import torch.nn as nn
from packaging import version

View File

@ -1,3 +1,5 @@
"""Classes for probabilistic distributions handling"""
import numpy as np
import torch

View File

@ -1,3 +1,5 @@
"""Classes for image and text encoding"""
import math
from contextlib import nullcontext
from functools import partial

View File

@ -1,3 +1,5 @@
"""Classes for video sequence transformation"""
import logging
from typing import Optional

View File

@ -1,3 +1,5 @@
"""Functions for image outpainting preparation"""
import re
import torch

View File

@ -1,3 +1,5 @@
"""Code for defining package root path"""
import os.path
PKG_ROOT = os.path.dirname(__file__)

View File

@ -1,3 +1,5 @@
"""Functions for managing prompt schedules"""
import csv
import re
from copy import copy

View File

@ -1,3 +1,5 @@
"""Functions for managing image regions of interest"""
import logging
logger = logging.getLogger(__name__)

View File

@ -1,3 +1,5 @@
"""Classes for image content safety evaluation"""
import logging
from functools import lru_cache

View File

@ -1,3 +1,5 @@
"""Classes and functions for image generation"""
# pylama:ignore=W0613
import logging
from abc import ABC

View File

@ -1,3 +1,5 @@
"""Classes for diffusion-based image generation"""
# pylama:ignore=W0613
import logging

View File

@ -1,3 +1,5 @@
"""Classes and functions for image generation with diffusion models"""
# pylama:ignore=W0613
from abc import ABC
from typing import Callable

View File

@ -1,3 +1,5 @@
"""Classes for image generation sampling"""
# pylama:ignore=W0613
import logging

View File

@ -1,3 +1,5 @@
"""Classes for image generation and manipulation"""
# pylint: disable=E0213
import base64
import hashlib

View File

@ -1,3 +1,5 @@
"""Functions for generating surprise image edits"""
import logging
import os.path

View File

@ -1,3 +1,5 @@
"""Code for training diffusion models"""
import datetime
import logging
import os

View File

@ -1,3 +1,5 @@
"""Functions for image preprocessing and generation"""
import logging
import os
import os.path

View File

@ -1,3 +1,5 @@
"""Functions for pruning diffusion models"""
import logging
import os

View File

@ -1,3 +1,5 @@
"""Classes for single-concept model finetuning"""
import os
import random
import re

View File

@ -1,3 +1,5 @@
"""Classes for data distortion testing"""
import contextlib
import math
import sys

View File

@ -1,3 +1,5 @@
"""Functions for gathering system debug information"""
from functools import lru_cache

View File

@ -1,3 +1,5 @@
"""Utilities for managing model caching"""
# pylama: ignore=W0212
import logging
from collections import OrderedDict

Some files were not shown because too many files have changed in this diff Show More