Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,8 @@ pipe.to(device)
|
|
21 |
MAX_SEED = np.iinfo(np.int32).max
|
22 |
|
23 |
@spaces.GPU(enable_queue=True)
|
24 |
-
|
|
|
25 |
if randomize_seed:
|
26 |
seed = random.randint(0, MAX_SEED)
|
27 |
|
@@ -36,7 +37,19 @@ def predict(prompt, upload_images, ip_adapter_scale=0.5, negative_prompt="", see
|
|
36 |
# ip_adapter_images = [image.resize((224, 224)) for image in ip_adapter_images]
|
37 |
|
38 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
image = pipe(
|
42 |
prompt=prompt,
|
@@ -107,7 +120,7 @@ with gr.Blocks(css=css) as demo:
|
|
107 |
value=1.0,
|
108 |
)
|
109 |
|
110 |
-
gr.Dropdown(
|
111 |
["Basic", "Style1", "Style2","Style3"], label="Adapter Type", info="Style Transfer Options"
|
112 |
)
|
113 |
with gr.Column():
|
@@ -199,7 +212,7 @@ with gr.Blocks(css=css) as demo:
|
|
199 |
gr.on(
|
200 |
triggers=[run_button.click, prompt.submit],
|
201 |
fn=predict,
|
202 |
-
inputs=[prompt, files, ip_adapter_scale, negative_prompt, seed, randomize_seed, center_crop, width, height, guidance_scale, num_inference_steps],
|
203 |
outputs=[result, seed]
|
204 |
)
|
205 |
|
|
|
21 |
MAX_SEED = np.iinfo(np.int32).max
|
22 |
|
23 |
@spaces.GPU(enable_queue=True)
|
24 |
+
|
25 |
+
def predict(prompt, upload_images, ip_adapter_scale=0.5, negative_prompt="", seed=100, randomize_seed=False, center_crop=False, width=1024, height=1024, guidance_scale=5.0, num_inference_steps=50, style="Basic", progress=gr.Progress(track_tqdm=True)):
|
26 |
if randomize_seed:
|
27 |
seed = random.randint(0, MAX_SEED)
|
28 |
|
|
|
37 |
# ip_adapter_images = [image.resize((224, 224)) for image in ip_adapter_images]
|
38 |
|
39 |
generator = torch.Generator(device="cuda").manual_seed(seed)
|
40 |
+
|
41 |
+
if style == "Style1":
|
42 |
+
adapter_scale = {"down": {"block_2": [ip_adapter_scale, 0.0]}, "up": {"block_0": [0.0, ip_adapter_scale, 0.0]}, "mid": ip_adapter_scale}
|
43 |
+
elif style == "Style2":
|
44 |
+
adapter_scale = {"down": {"block_2": [ip_adapter_scale, ip_adapter_scale]}, "up": {"block_0": [0.0, ip_adapter_scale, 0.0]}}
|
45 |
+
elif style == "Style3":
|
46 |
+
adapter_scale = {"down": {"block_2": [ip_adapter_scale, 0.0], "block_1": [0.0, ip_adapter_scale]}, "up": {"block_0": [0.0, ip_adapter_scale, 0.0]}}
|
47 |
+
else:
|
48 |
+
adapter_scale = ip_adapter_scale
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
pipe.set_ip_adapter_scale([adapter_scale])
|
53 |
|
54 |
image = pipe(
|
55 |
prompt=prompt,
|
|
|
120 |
value=1.0,
|
121 |
)
|
122 |
|
123 |
+
style = gr.Dropdown(
|
124 |
["Basic", "Style1", "Style2","Style3"], label="Adapter Type", info="Style Transfer Options"
|
125 |
)
|
126 |
with gr.Column():
|
|
|
212 |
gr.on(
|
213 |
triggers=[run_button.click, prompt.submit],
|
214 |
fn=predict,
|
215 |
+
inputs=[prompt, files, ip_adapter_scale, negative_prompt, seed, randomize_seed, center_crop, width, height, guidance_scale, num_inference_steps, style],
|
216 |
outputs=[result, seed]
|
217 |
)
|
218 |
|