Andre Embury commited on
Commit
84d59ce
·
unverified ·
1 Parent(s): 79c322a

Change from canny to scribble

Browse files

Changes the controlnet from canny to scribble.

Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -14,7 +14,9 @@ import torch
14
  import requests
15
  from fastapi import FastAPI, HTTPException
16
  from PIL import Image
17
- from controlnet_aux import CannyDetector
 
 
18
 
19
  device = "cuda" if torch.cuda.is_available() else "cpu"
20
  # model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to use
@@ -29,9 +31,9 @@ else:
29
  # "lllyasviel/sd-controlnet-canny", torch_dtype=torch.float32
30
  # )
31
 
32
- controlnet = ControlNetModel.from_pretrained(
33
- "diffusers/controlnet-canny-sdxl-1.0", torch_dtype=torch.float16
34
- )
35
 
36
  # pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
37
  # pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
@@ -39,6 +41,20 @@ controlnet = ControlNetModel.from_pretrained(
39
  # controlnet=controlnet,
40
  # torch_dtype=torch_dtype,
41
  # ).to(device)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
43
  "stabilityai/stable-diffusion-xl-base-1.0",
44
  controlnet=controlnet,
@@ -46,8 +62,9 @@ pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
46
  variant="fp16",
47
  use_safetensors=True,
48
  ).to(device)
49
- # pipe = pipe.to(device)
50
- canny = CannyDetector()
 
51
 
52
  MAX_SEED = np.iinfo(np.int32).max
53
  MAX_IMAGE_SIZE = 1024
@@ -96,7 +113,8 @@ def infer(
96
  # img = img.resize((req.width, req.height))
97
  img = img.resize((width, height))
98
 
99
- control_net_image = canny(img).resize((width, height))
 
100
 
101
  prompt = (
102
  "redraw the logo from scratch, clean sharp vector-style, "
 
14
  import requests
15
  from fastapi import FastAPI, HTTPException
16
  from PIL import Image
17
+
18
+ # from controlnet_aux import CannyDetector
19
+ from controlnet_aux import ScribbleDetector
20
 
21
  device = "cuda" if torch.cuda.is_available() else "cpu"
22
  # model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to use
 
31
  # "lllyasviel/sd-controlnet-canny", torch_dtype=torch.float32
32
  # )
33
 
34
+ # controlnet = ControlNetModel.from_pretrained(
35
+ # "diffusers/controlnet-canny-sdxl-1.0", torch_dtype=torch.float16
36
+ # )
37
 
38
  # pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
39
  # pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
 
41
  # controlnet=controlnet,
42
  # torch_dtype=torch_dtype,
43
  # ).to(device)
44
+ # pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
45
+ # "stabilityai/stable-diffusion-xl-base-1.0",
46
+ # controlnet=controlnet,
47
+ # torch_dtype=torch.float16,
48
+ # variant="fp16",
49
+ # use_safetensors=True,
50
+ # ).to(device)
51
+
52
+ # Load SDXL-compatible ControlNet (scribble version)
53
+ controlnet = ControlNetModel.from_pretrained(
54
+ "diffusers/controlnet-scribble-sdxl-1.0", torch_dtype=torch.float16
55
+ )
56
+
57
+ # Load SDXL base pipeline with the ControlNet
58
  pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
59
  "stabilityai/stable-diffusion-xl-base-1.0",
60
  controlnet=controlnet,
 
62
  variant="fp16",
63
  use_safetensors=True,
64
  ).to(device)
65
+
66
+ # canny = CannyDetector()
67
+ scribble_detector = ScribbleDetector()
68
 
69
  MAX_SEED = np.iinfo(np.int32).max
70
  MAX_IMAGE_SIZE = 1024
 
113
  # img = img.resize((req.width, req.height))
114
  img = img.resize((width, height))
115
 
116
+ # control_net_image = canny(img).resize((width, height))
117
+ control_net_image = scribble_detector(img).resize((width, height))
118
 
119
  prompt = (
120
  "redraw the logo from scratch, clean sharp vector-style, "