Spaces:
Runtime error
Runtime error
Vivien Chappelier
commited on
Commit
β’
8b44d8d
1
Parent(s):
1a5c99e
GPU version
Browse files- .gitattributes +2 -0
- app.py +23 -6
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
checkpoint_000.pth filter=lfs diff=lfs merge=lfs -text
|
37 |
+
checkpoint_*.pth filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -1,17 +1,34 @@
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from optimum.intel.openvino import OVStableDiffusionPipeline
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
prompt = "sailing ship in storm by Rembrandt"
|
9 |
|
10 |
-
def generate(
|
11 |
output = pipe(prompt, num_inference_steps=50, output_type="pil")
|
12 |
output.images[0].save("result.png")
|
13 |
return output.images[0]
|
14 |
|
15 |
iface = gr.Interface(fn=generate, inputs=[gr.Textbox(label="Prompt", value=prompt)], outputs=[gr.Image(type="pil")])
|
16 |
-
iface.launch()
|
17 |
|
|
|
1 |
+
import socketserver
|
2 |
+
socketserver.TCPServer.allow_reuse_address = True
|
3 |
+
|
4 |
import gradio as gr
|
|
|
5 |
|
6 |
+
import torch
|
7 |
+
|
8 |
+
from diffusers import StableDiffusionPipeline
|
9 |
+
|
10 |
+
pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base", torch_dtype=torch.float16)
|
11 |
+
|
12 |
+
# load the patched VQ-VAE
|
13 |
+
patched_decoder_ckpt = "checkpoint_000.pth"
|
14 |
+
|
15 |
+
if patched_decoder_ckpt is not None:
|
16 |
+
sd2 = torch.load(patched_decoder_ckpt)['ldm_decoder']
|
17 |
+
#print("patching keys for first_stage_model: ", sd2.keys())
|
18 |
+
|
19 |
+
msg = pipe.vae.load_state_dict(sd2, strict=False)
|
20 |
+
print(f"loaded LDM decoder state_dict with message\n{msg}")
|
21 |
+
print("you should check that the decoder keys are correctly matched")
|
22 |
+
|
23 |
+
pipe = pipe.to("cuda")
|
24 |
|
25 |
prompt = "sailing ship in storm by Rembrandt"
|
26 |
|
27 |
+
def generate(prompt):
|
28 |
output = pipe(prompt, num_inference_steps=50, output_type="pil")
|
29 |
output.images[0].save("result.png")
|
30 |
return output.images[0]
|
31 |
|
32 |
iface = gr.Interface(fn=generate, inputs=[gr.Textbox(label="Prompt", value=prompt)], outputs=[gr.Image(type="pil")])
|
33 |
+
iface.launch(server_name="0.0.0.0")
|
34 |
|