Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ token = os.environ['model_fetch']
|
|
14 |
|
15 |
engine_repo = Repository(local_dir="engine", clone_from="felixrosberg/EngageDiffusion", use_auth_token=token)
|
16 |
|
17 |
-
from engine.ui_model import fetch_model, process_sketch, process_mask
|
18 |
|
19 |
engage_logo = Image.open("engage_studios_logo.png").resize((700, 88), Image.Resampling.BICUBIC)
|
20 |
engage_logo_mask = np.array(engage_logo.split()[-1])[..., None] / 255
|
@@ -24,35 +24,7 @@ pipe = fetch_model()
|
|
24 |
pipe.to('cuda')
|
25 |
|
26 |
|
27 |
-
|
28 |
-
def run_text_to_image(prompt=None, neg_prompt=None,
|
29 |
-
inference_steps=8, num_images=2,
|
30 |
-
guidance_scale=2.0,
|
31 |
-
guidance_rescale=0.0,
|
32 |
-
|
33 |
-
height=1024,
|
34 |
-
width=1024,
|
35 |
-
|
36 |
-
condition_scale=0.5,
|
37 |
-
|
38 |
-
exposure=0.0,
|
39 |
-
progress=gr.Progress()):
|
40 |
-
images = pipe(prompt=prompt,
|
41 |
-
negative_prompt=neg_prompt,
|
42 |
-
num_images_per_prompt=num_images,
|
43 |
-
num_inference_steps=inference_steps,
|
44 |
-
height=height,
|
45 |
-
width=width,
|
46 |
-
guidance_scale=guidance_scale,
|
47 |
-
guidance_rescale=guidance_rescale,
|
48 |
-
controlnet_conditioning_scale=condition_scale,
|
49 |
-
gradio_progress=progress,
|
50 |
-
cross_attention_kwargs={"scale": exposure}
|
51 |
-
).images
|
52 |
-
return images
|
53 |
-
|
54 |
-
|
55 |
-
def run_model(user_state, condition_image, settings, prompt, neg_prompt, inference_steps=8, num_images=2,
|
56 |
guidance_scale=2.0,
|
57 |
guidance_rescale=0.0,
|
58 |
enable_freeu=False,
|
@@ -86,47 +58,41 @@ def run_model(user_state, condition_image, settings, prompt, neg_prompt, inferen
|
|
86 |
|
87 |
seed=None,
|
88 |
progress=gr.Progress()):
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
width=width,
|
125 |
-
guidance_scale=guidance_scale,
|
126 |
-
guidance_rescale=guidance_rescale,
|
127 |
-
condition_scale=condition_scale,
|
128 |
-
progress=progress,
|
129 |
-
exposure=exposure)
|
130 |
|
131 |
for idx, im in enumerate(images):
|
132 |
im = np.asarray(im).copy()
|
|
|
14 |
|
15 |
engine_repo = Repository(local_dir="engine", clone_from="felixrosberg/EngageDiffusion", use_auth_token=token)
|
16 |
|
17 |
+
from engine.ui_model import fetch_model, process_sketch, process_mask, run_model, run_text_to_image
|
18 |
|
19 |
engage_logo = Image.open("engage_studios_logo.png").resize((700, 88), Image.Resampling.BICUBIC)
|
20 |
engage_logo_mask = np.array(engage_logo.split()[-1])[..., None] / 255
|
|
|
24 |
pipe.to('cuda')
|
25 |
|
26 |
|
27 |
+
def inference(user_state, condition_image, settings, prompt, neg_prompt, inference_steps=8, num_images=2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
guidance_scale=2.0,
|
29 |
guidance_rescale=0.0,
|
30 |
enable_freeu=False,
|
|
|
58 |
|
59 |
seed=None,
|
60 |
progress=gr.Progress()):
|
61 |
+
|
62 |
+
images = run_model(pipe, user_state, condition_image, settings, prompt, neg_prompt, inference_steps=8, num_images=2,
|
63 |
+
guidance_scale,
|
64 |
+
guidance_rescale,
|
65 |
+
enable_freeu,
|
66 |
+
|
67 |
+
height,
|
68 |
+
width,
|
69 |
+
|
70 |
+
condition_scale,
|
71 |
+
sketch_detail,
|
72 |
+
sketch_softness,
|
73 |
+
inpaint_strength,
|
74 |
+
|
75 |
+
exposure,
|
76 |
+
enable_stylation,
|
77 |
+
|
78 |
+
style_1_down,
|
79 |
+
style_1_mid,
|
80 |
+
style_1_up,
|
81 |
+
|
82 |
+
style_2_down,
|
83 |
+
style_2_mid,
|
84 |
+
style_2_up,
|
85 |
+
|
86 |
+
style_3_down,
|
87 |
+
style_3_mid,
|
88 |
+
style_3_up,
|
89 |
+
|
90 |
+
style_4_down,
|
91 |
+
style_4_mid,
|
92 |
+
style_4_up,
|
93 |
+
|
94 |
+
seed,
|
95 |
+
progress)
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
for idx, im in enumerate(images):
|
98 |
im = np.asarray(im).copy()
|