Spaces:
Running
on
Zero
Running
on
Zero
import gc | |
import os | |
import random | |
import numpy as np | |
import json | |
import torch | |
import base64 | |
from io import BytesIO | |
from PIL import Image, PngImagePlugin | |
from datetime import datetime | |
from dataclasses import dataclass | |
from typing import Callable, Dict, Optional, Tuple | |
from diffusers import ( | |
DDIMScheduler, | |
DPMSolverMultistepScheduler, | |
DPMSolverSinglestepScheduler, | |
EulerAncestralDiscreteScheduler, | |
EulerDiscreteScheduler, | |
) | |
MAX_SEED = np.iinfo(np.int32).max | |
# ... (rest of the existing functions remain the same) | |
def image_to_base64(image: Image.Image) -> str: | |
buffered = BytesIO() | |
image.save(buffered, format="PNG") | |
return base64.b64encode(buffered.getvalue()).decode() | |
# ... (rest of the existing functions remain the same) |