Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import scripts.control_utils as cu
|
| 2 |
+
import torch
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
path_to_config = 'ControlNet-XS-main/configs/inference/sdxl/sdxl_encD_canny_48m.yaml'
|
| 6 |
+
model = cu.create_model(path_to_config).to('cuda')
|
| 7 |
+
|
| 8 |
+
image_path = 'PATH/TO/IMAGES/Shoe.png'
|
| 9 |
+
|
| 10 |
+
canny_high_th = 250
|
| 11 |
+
canny_low_th = 100
|
| 12 |
+
size = 768
|
| 13 |
+
num_samples=2
|
| 14 |
+
|
| 15 |
+
image = cu.get_image(image_path, size=size)
|
| 16 |
+
edges = cu.get_canny_edges(image, low_th=canny_low_th, high_th=canny_high_th)
|
| 17 |
+
|
| 18 |
+
samples, controls = cu.get_sdxl_sample(
|
| 19 |
+
guidance=edges,
|
| 20 |
+
ddim_steps=10,
|
| 21 |
+
num_samples=num_samples,
|
| 22 |
+
model=model,
|
| 23 |
+
shape=[4, size // 8, size // 8],
|
| 24 |
+
control_scale=0.95,
|
| 25 |
+
prompt='cinematic, shoe in the streets, made from meat, photorealistic shoe, highly detailed',
|
| 26 |
+
n_prompt='lowres, bad anatomy, worst quality, low quality',
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
Image.fromarray(cu.create_image_grid(samples)).save('SDXL_MyShoe.png')
|