aliabd HF staff commited on
Commit
7f5f38c
·
verified ·
1 Parent(s): 13d4d01

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. requirements.txt +2 -2
  2. run.ipynb +1 -1
  3. run.py +2 -2
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@38c2ad425a905431b1eb17b9498669f9e49f0dd5#subdirectory=client/python
2
- https://gradio-builds.s3.amazonaws.com/38c2ad425a905431b1eb17b9498669f9e49f0dd5/gradio-4.38.1-py3-none-any.whl
3
  torch
4
  transformers
5
  diffusers
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@76c175935019833baef709a5cf401d2263ca72ee#subdirectory=client/python
2
+ https://gradio-builds.s3.amazonaws.com/76c175935019833baef709a5cf401d2263ca72ee/gradio-4.38.1-py3-none-any.whl
3
  torch
4
  transformers
5
  diffusers
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: diffusers_with_batching"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio torch transformers diffusers"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import torch\n", "from diffusers import DiffusionPipeline\n", "import gradio as gr\n", "\n", "generator = DiffusionPipeline.from_pretrained(\"CompVis/ldm-text2im-large-256\")\n", "# move to GPU if available\n", "if torch.cuda.is_available():\n", " generator = generator.to(\"cuda\")\n", "\n", "def generate(prompts):\n", " images = generator(list(prompts)).images\n", " return [images]\n", "\n", "demo = gr.Interface(generate, \n", " \"textbox\", \n", " \"image\", \n", " batch=True, \n", " max_batch_size=4 # Set the batch size based on your CPU/GPU memory\n", ").queue()\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: diffusers_with_batching"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio torch transformers diffusers"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import torch\n", "from diffusers import DiffusionPipeline # type: ignore\n", "import gradio as gr\n", "\n", "generator = DiffusionPipeline.from_pretrained(\"CompVis/ldm-text2im-large-256\")\n", "# move to GPU if available\n", "if torch.cuda.is_available():\n", " generator = generator.to(\"cuda\")\n", "\n", "def generate(prompts):\n", " images = generator(list(prompts)).images # type: ignore\n", " return [images]\n", "\n", "demo = gr.Interface(generate, \n", " \"textbox\", \n", " \"image\", \n", " batch=True, \n", " max_batch_size=4 # Set the batch size based on your CPU/GPU memory\n", ").queue()\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -1,5 +1,5 @@
1
  import torch
2
- from diffusers import DiffusionPipeline
3
  import gradio as gr
4
 
5
  generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
@@ -8,7 +8,7 @@ if torch.cuda.is_available():
8
  generator = generator.to("cuda")
9
 
10
  def generate(prompts):
11
- images = generator(list(prompts)).images
12
  return [images]
13
 
14
  demo = gr.Interface(generate,
 
1
  import torch
2
+ from diffusers import DiffusionPipeline # type: ignore
3
  import gradio as gr
4
 
5
  generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
 
8
  generator = generator.to("cuda")
9
 
10
  def generate(prompts):
11
+ images = generator(list(prompts)).images # type: ignore
12
  return [images]
13
 
14
  demo = gr.Interface(generate,