Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,19 @@ import spaces
|
|
7 |
import gradio as gr
|
8 |
|
9 |
from diffusers import AutoPipelineForText2Image
|
|
|
10 |
from diffusers.utils import load_image
|
11 |
from torchvision import transforms
|
12 |
|
13 |
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
14 |
dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def prepare_image(image_path_or_url):
|
19 |
# Load the image
|
|
|
7 |
import gradio as gr
|
8 |
|
9 |
from diffusers import AutoPipelineForText2Image
|
10 |
+
from transformers import CLIPVisionModelWithProjection
|
11 |
from diffusers.utils import load_image
|
12 |
from torchvision import transforms
|
13 |
|
14 |
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
|
15 |
dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
16 |
+
image_encoder = CLIPVisionModelWithProjection.from_pretrained(
|
17 |
+
"h94/IP-Adapter",
|
18 |
+
subfolder="models/image_encoder",
|
19 |
+
torch_dtype=dtype
|
20 |
+
)
|
21 |
+
pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",image_encoder=image_encoder, torch_dtype=dtype).to(device)
|
22 |
+
pipeline.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models", weight_name="ip-adapter-plus_sdxl_vit-h.safetensors")
|
23 |
|
24 |
def prepare_image(image_path_or_url):
|
25 |
# Load the image
|