mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-07 11:46:51 +08:00
* changes * changes * revert changes * changes * add changeset * notebooks script * changes * changes --------- Co-authored-by: Ali Abid <aliabid94@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
1.2 KiB
1.2 KiB
Gradio Demo: diffusers_with_batching¶
In [ ]:
!pip install -q gradio torch transformers diffusers
In [ ]:
import torch from diffusers import DiffusionPipeline # type: ignore import gradio as gr generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256") # move to GPU if available if torch.cuda.is_available(): generator = generator.to("cuda") def generate(prompts): images = generator(list(prompts)).images # type: ignore return [images] demo = gr.Interface(generate, "textbox", "image", batch=True, max_batch_size=4 # Set the batch size based on your CPU/GPU memory ) if __name__ == "__main__": demo.launch()