3dalgolab commited on
Commit
437157e
·
1 Parent(s): 78702bd

Add application file

Browse files
Files changed (1) hide show
  1. diffuser.py +25 -0
diffuser.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import DiffusionPipeline
3
+ import gradio as gr
4
+
5
+ generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
6
+ # move to GPU if available
7
+ if torch.cuda.is_available():
8
+ generator = generator.to("cuda")
9
+
10
+
11
+ def generate(prompts):
12
+ images = generator(list(prompts)).images
13
+ return [images]
14
+
15
+
16
+ demo = gr.Interface(
17
+ generate,
18
+ "textbox",
19
+ "image",
20
+ batch=True,
21
+ max_batch_size=2, # Set the batch size based on your CPU/GPU memory
22
+ ).queue()
23
+
24
+ if __name__ == "__main__":
25
+ demo.launch(share=True)