Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,39 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import random
|
4 |
-
from diffusers import
|
5 |
-
import
|
6 |
|
7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
|
9 |
if torch.cuda.is_available():
|
10 |
torch.cuda.max_memory_allocated(device=device)
|
11 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/
|
12 |
pipe.enable_xformers_memory_efficient_attention()
|
13 |
pipe = pipe.to(device)
|
14 |
else:
|
15 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/
|
16 |
pipe = pipe.to(device)
|
17 |
|
18 |
MAX_SEED = np.iinfo(np.int32).max
|
19 |
MAX_IMAGE_SIZE = 1024
|
20 |
|
|
|
|
|
21 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
22 |
|
23 |
if randomize_seed:
|
24 |
seed = random.randint(0, MAX_SEED)
|
25 |
|
26 |
generator = torch.Generator().manual_seed(seed)
|
|
|
|
|
|
|
27 |
|
28 |
-
image =
|
29 |
-
|
30 |
-
negative_prompt = negative_prompt,
|
31 |
-
guidance_scale = guidance_scale,
|
32 |
-
num_inference_steps = num_inference_steps,
|
33 |
-
width = width,
|
34 |
-
height = height,
|
35 |
-
generator = generator
|
36 |
-
).images[0]
|
37 |
|
38 |
-
return
|
39 |
|
40 |
examples = [
|
41 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import random
|
4 |
+
from diffusers import AutoPipelineForImage2Image
|
5 |
+
from diffusers.utils import make_image_grid, load_image
|
6 |
|
7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
|
9 |
if torch.cuda.is_available():
|
10 |
torch.cuda.max_memory_allocated(device=device)
|
11 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
12 |
pipe.enable_xformers_memory_efficient_attention()
|
13 |
pipe = pipe.to(device)
|
14 |
else:
|
15 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", use_safetensors=True)
|
16 |
pipe = pipe.to(device)
|
17 |
|
18 |
MAX_SEED = np.iinfo(np.int32).max
|
19 |
MAX_IMAGE_SIZE = 1024
|
20 |
|
21 |
+
pipe.load_lora_weights("artificialguybr/ps1redmond-ps1-game-graphics-lora-for-sdxl")
|
22 |
+
|
23 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
24 |
|
25 |
if randomize_seed:
|
26 |
seed = random.randint(0, MAX_SEED)
|
27 |
|
28 |
generator = torch.Generator().manual_seed(seed)
|
29 |
+
|
30 |
+
url = "https://cmmodels.de/wp-content/uploads/2021/08/gabriel-new-face-white-shirt-brown-hair-pretty-boy-young-white-background-studio-brown-hair-wet-look.jpg"
|
31 |
+
init_image = load_image(url)
|
32 |
|
33 |
+
image = pipeline(prompt, image=init_image, strength=0.5).images[0]
|
34 |
+
grid = make_image_grid([init_image, image], rows=1, cols=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
+
return grid
|
37 |
|
38 |
examples = [
|
39 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|