Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,15 +4,10 @@ import random
|
|
4 |
from optimum.intel import OVStableDiffusionXLPipeline
|
5 |
import torch
|
6 |
|
7 |
-
# Default model ID
|
8 |
model_id = "None1145/noobai-XL-Vpred-0.65s-openvino"
|
9 |
-
pipe = OVStableDiffusionXLPipeline.from_pretrained(model_id)
|
10 |
|
11 |
-
# Initialize previous dimensions
|
12 |
prev_height = 1216
|
13 |
prev_width = 832
|
14 |
-
pipe.reshape(batch_size=1, height=prev_height, width=prev_width, num_images_per_prompt=1)
|
15 |
-
pipe.compile()
|
16 |
|
17 |
MAX_SEED = np.iinfo(np.int32).max
|
18 |
MAX_IMAGE_SIZE = 2048
|
@@ -21,13 +16,14 @@ def reload_model(new_model_id):
|
|
21 |
global pipe, model_id, prev_height, prev_width
|
22 |
model_id = new_model_id
|
23 |
try:
|
24 |
-
pipe = OVStableDiffusionXLPipeline.from_pretrained(model_id)
|
25 |
pipe.reshape(batch_size=1, height=prev_height, width=prev_width, num_images_per_prompt=1)
|
26 |
pipe.compile()
|
27 |
return f"Model successfully loaded: {model_id}"
|
28 |
except Exception as e:
|
29 |
return f"Failed to load model: {str(e)}"
|
30 |
-
|
|
|
31 |
def infer(
|
32 |
prompt,
|
33 |
negative_prompt,
|
|
|
4 |
from optimum.intel import OVStableDiffusionXLPipeline
|
5 |
import torch
|
6 |
|
|
|
7 |
model_id = "None1145/noobai-XL-Vpred-0.65s-openvino"
|
|
|
8 |
|
|
|
9 |
prev_height = 1216
|
10 |
prev_width = 832
|
|
|
|
|
11 |
|
12 |
MAX_SEED = np.iinfo(np.int32).max
|
13 |
MAX_IMAGE_SIZE = 2048
|
|
|
16 |
global pipe, model_id, prev_height, prev_width
|
17 |
model_id = new_model_id
|
18 |
try:
|
19 |
+
pipe = OVStableDiffusionXLPipeline.from_pretrained(model_id, compile = False)
|
20 |
pipe.reshape(batch_size=1, height=prev_height, width=prev_width, num_images_per_prompt=1)
|
21 |
pipe.compile()
|
22 |
return f"Model successfully loaded: {model_id}"
|
23 |
except Exception as e:
|
24 |
return f"Failed to load model: {str(e)}"
|
25 |
+
reload_model(model_id)
|
26 |
+
|
27 |
def infer(
|
28 |
prompt,
|
29 |
negative_prompt,
|