Spaces:
Configuration error
Configuration error
load_model
Browse files
app.py
CHANGED
|
@@ -14,14 +14,16 @@ pipe = None
|
|
| 14 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 15 |
|
| 16 |
def load_model():
|
| 17 |
-
global
|
| 18 |
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
| 19 |
"yeq6x/animagine_position_map",
|
| 20 |
controlnet=ControlNetModel.from_pretrained("yeq6x/Image2PositionColor_v3"),
|
| 21 |
).to(device)
|
| 22 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
def convert_pil_to_opencv(pil_image):
|
| 27 |
return np.array(pil_image)
|
|
@@ -137,6 +139,7 @@ def outpaint_image(image):
|
|
| 137 |
|
| 138 |
@spaces.GPU
|
| 139 |
def predict_image(cond_image, prompt, negative_prompt):
|
|
|
|
| 140 |
generator = torch.Generator()
|
| 141 |
generator.manual_seed(random.randint(0, 2147483647))
|
| 142 |
|
|
|
|
| 14 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 15 |
|
| 16 |
def load_model():
|
| 17 |
+
global device
|
| 18 |
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
| 19 |
"yeq6x/animagine_position_map",
|
| 20 |
controlnet=ControlNetModel.from_pretrained("yeq6x/Image2PositionColor_v3"),
|
| 21 |
).to(device)
|
| 22 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 23 |
|
| 24 |
+
return pipe
|
| 25 |
+
|
| 26 |
+
pipe = load_model()
|
| 27 |
|
| 28 |
def convert_pil_to_opencv(pil_image):
|
| 29 |
return np.array(pil_image)
|
|
|
|
| 139 |
|
| 140 |
@spaces.GPU
|
| 141 |
def predict_image(cond_image, prompt, negative_prompt):
|
| 142 |
+
global pipe
|
| 143 |
generator = torch.Generator()
|
| 144 |
generator.manual_seed(random.randint(0, 2147483647))
|
| 145 |
|