Spaces:
Runtime error
Runtime error
File size: 601 Bytes
6fbcb41 8956714 714c61b c02844f 714c61b c02844f 8956714 c02844f 714c61b c02844f 714c61b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import gradio as gr
import spaces
import torch
from diffusers import DiffusionPipeline
generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
# move to GPU if available
if torch.cuda.is_available():
generator = generator.to("cuda")
@spaces.GPU
def generate(prompts):
images = generator(list(prompts)).images
return [images]
demo = gr.Interface(generate,
"textbox",
"image",
batch=True,
max_batch_size=4 # Set the batch size based on your CPU/GPU memory
).queue()
if __name__ == "__main__":
demo.launch()
|