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 import os
# tells pytorch to allow MPS usage (for Mac M1 compatibility) # 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 os.path
import cv2 import cv2

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
"""Functions for assessing image blurriness"""
import cv2 import cv2
from imaginairy.img_utils import pillow_img_to_opencv_img 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 functools import lru_cache
from typing import Optional, Sequence from typing import Optional, Sequence

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
"""Functions for detecting and cropping faces"""
import numpy as np import numpy as np
from imaginairy.enhancers.face_restoration_codeformer import face_restore_helper 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 gzip
import os.path import os.path
import random import random

View File

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

View File

@ -1,3 +1,5 @@
"""Classes and functions for image upscaling"""
from functools import lru_cache from functools import lru_cache
import numpy as np 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 # 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 # but with all the bugs fixed and lots of simplifications
# MIT License # MIT License

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
"""Classes for text encoding transformations"""
import open_clip import open_clip
import torch import torch
from torch import nn 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 # based on https://github.com/isl-org/MiDaS
from functools import lru_cache from functools import lru_cache

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
"""Classes for guiding diffusion models"""
import logging import logging
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Dict, List, Optional, Tuple, Union 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 from typing import Dict, List, Optional, Tuple, Union
import torch import torch

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
"""Classes for stochastic sampling strategies"""
import torch import torch
from imaginairy.utils import default, instantiate_from_config 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 from typing import List, Optional, Union
import torch as th import torch as th

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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