Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,16 @@
|
|
1 |
from PIL import Image
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
|
|
4 |
import random
|
|
|
5 |
import torch
|
6 |
from accelerate import Accelerator
|
7 |
from transformers import pipeline
|
8 |
from diffusers.utils import load_image
|
9 |
from diffusers import KandinskyV22PriorPipeline, KandinskyV22ControlnetPipeline
|
10 |
|
11 |
-
accelerator = Accelerator()
|
12 |
|
13 |
def make_hint(image, depth_estimator):
|
14 |
image = depth_estimator(image)["depth"]
|
@@ -24,6 +26,7 @@ pipe_prior = accelerator.prepare(KandinskyV22PriorPipeline.from_pretrained("kand
|
|
24 |
pipe_prior = accelerator.prepare(pipe_prior.to("cpu"))
|
25 |
pipe = accelerator.prepare(KandinskyV22ControlnetPipeline.from_pretrained("kandinsky-community/kandinsky-2-2-controlnet-depth", torch_dtype=torch.float32))
|
26 |
pipe = accelerator.prepare(pipe.to("cpu"))
|
|
|
27 |
generator = torch.Generator(device="cpu").manual_seed(random.randint(-1, 2147483647))
|
28 |
|
29 |
def plex(prompt,goof):
|
|
|
1 |
from PIL import Image
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
+
import PIL.Image
|
5 |
import random
|
6 |
+
import cv2
|
7 |
import torch
|
8 |
from accelerate import Accelerator
|
9 |
from transformers import pipeline
|
10 |
from diffusers.utils import load_image
|
11 |
from diffusers import KandinskyV22PriorPipeline, KandinskyV22ControlnetPipeline
|
12 |
|
13 |
+
accelerator = Accelerator(cpu=True)
|
14 |
|
15 |
def make_hint(image, depth_estimator):
|
16 |
image = depth_estimator(image)["depth"]
|
|
|
26 |
pipe_prior = accelerator.prepare(pipe_prior.to("cpu"))
|
27 |
pipe = accelerator.prepare(KandinskyV22ControlnetPipeline.from_pretrained("kandinsky-community/kandinsky-2-2-controlnet-depth", torch_dtype=torch.float32))
|
28 |
pipe = accelerator.prepare(pipe.to("cpu"))
|
29 |
+
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
30 |
generator = torch.Generator(device="cpu").manual_seed(random.randint(-1, 2147483647))
|
31 |
|
32 |
def plex(prompt,goof):
|