baubin commited on
Commit
dded383
1 Parent(s): b40fefa

examples, pin version

Browse files
Files changed (6) hide show
  1. .gitignore +1 -0
  2. app.py +34 -21
  3. images/6.png +3 -0
  4. images/7.png +3 -0
  5. images/8.png +3 -0
  6. requirements.txt +7 -5
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ envs
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import random
3
 
@@ -6,8 +7,12 @@ import numpy as np
6
  import PIL.Image
7
  import spaces
8
  import torch
9
- from diffusers import (AutoencoderKL, DDIMInverseScheduler, DDIMScheduler,
10
- StableDiffusionXLPipeline)
 
 
 
 
11
  from torchvision.transforms import ToTensor
12
 
13
  # pyright: reportPrivateImportUsage=false
@@ -15,7 +20,8 @@ from torchvision.transforms import ToTensor
15
 
16
  DESCRIPTION = f"""
17
  # 🎨 Inversion-InstantStyle 🎨
18
- This is an interactive demo of noisy DDIM inversion capabilities on top of Instant-Style styling method. This was developed in the context of a style benchmark : [style-rank](https://gojasper.github.io/style-rank-project) by *Eyal Benaroche, Clément Chadebec, Onur Tasar, and Benjamin Aubin* from [Jasper Research](https://www.jasper.ai/) in the context of Eyal's internship with Ecole Polytechnique.
 
19
  """
20
 
21
  OPEN_SOURCE_PROMO = f"""
@@ -57,6 +63,8 @@ if gr.NO_RELOAD:
57
  "stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler"
58
  )
59
  invert_scheduler = DDIMInverseScheduler(**forward_scheduler.config)
 
 
60
 
61
  css = """
62
  h1 {
@@ -175,15 +183,20 @@ def generate(
175
 
176
  examples_prompts = [
177
  "Astronaut in a jungle, detailed, 8k",
178
- "A Bird",
179
- "A Tiger",
180
- "A Cat",
181
- "cactus",
182
- "A Panda",
 
 
 
183
  ]
184
 
185
- examples_images = [f"./images/{i}.png" for i in range(6)]
186
-
 
 
187
  examples = [[prompt, image] for prompt, image in zip(examples_prompts, examples_images)]
188
 
189
  with gr.Blocks(css=css) as demo:
@@ -197,7 +210,17 @@ with gr.Blocks(css=css) as demo:
197
 
198
  with gr.Column():
199
 
200
- style_image = gr.Image()
 
 
 
 
 
 
 
 
 
 
201
 
202
  noise_scale = gr.Slider(
203
  label="Noise Scale",
@@ -210,16 +233,6 @@ with gr.Blocks(css=css) as demo:
210
  with gr.Blocks():
211
 
212
  with gr.Column():
213
- with gr.Row():
214
- prompt = gr.Text(
215
- label="Prompt",
216
- show_label=False,
217
- max_lines=1,
218
- placeholder="Enter your prompt",
219
- container=False,
220
- )
221
- run_button = gr.Button("Run", scale=0)
222
-
223
  result = gr.Image(label="Result", show_label=False)
224
 
225
  with gr.Accordion("Advanced options", open=False):
 
1
+ import glob
2
  import os
3
  import random
4
 
 
7
  import PIL.Image
8
  import spaces
9
  import torch
10
+ from diffusers import (
11
+ AutoencoderKL,
12
+ DDIMInverseScheduler,
13
+ DDIMScheduler,
14
+ StableDiffusionXLPipeline,
15
+ )
16
  from torchvision.transforms import ToTensor
17
 
18
  # pyright: reportPrivateImportUsage=false
 
20
 
21
  DESCRIPTION = f"""
22
  # 🎨 Inversion-InstantStyle 🎨
23
+ This is an interactive demo of [Inversion-InstantStyle](https://gojasper.github.io/style-rank-project/#inversion_instantstyle), which combines DDIM inversion and renoising with the [Instant-Style](https://instantstyle.github.io/) styling method.
24
+ It was proposed in the context of our [Style-Rank](https://gojasper.github.io/style-rank-project) benchmark which evaluates training-free styling methods, by *Eyal Benaroche, Clément Chadebec, Onur Tasar, and Benjamin Aubin* from [Jasper Research](https://www.jasper.ai/) and [Ecole Polytechnique](https://www.polytechnique.edu/).
25
  """
26
 
27
  OPEN_SOURCE_PROMO = f"""
 
63
  "stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler"
64
  )
65
  invert_scheduler = DDIMInverseScheduler(**forward_scheduler.config)
66
+ else:
67
+ raise ValueError("This demo does not work on CPU.")
68
 
69
  css = """
70
  h1 {
 
183
 
184
  examples_prompts = [
185
  "Astronaut in a jungle, detailed, 8k",
186
+ "A bird",
187
+ "A tiger",
188
+ "A cat",
189
+ "A cactus",
190
+ "A panda",
191
+ "A duck",
192
+ "An elephant",
193
+ "A dragon head",
194
  ]
195
 
196
+ examples_images = glob.glob("./images/*.png")
197
+ assert len(examples_images) == len(
198
+ examples_prompts
199
+ ), "Number of example images and prompts should match"
200
  examples = [[prompt, image] for prompt, image in zip(examples_prompts, examples_images)]
201
 
202
  with gr.Blocks(css=css) as demo:
 
210
 
211
  with gr.Column():
212
 
213
+ with gr.Row():
214
+ prompt = gr.Text(
215
+ label="Target prompt",
216
+ show_label=False,
217
+ max_lines=1,
218
+ placeholder="Enter your prompt to generate new content",
219
+ container=False,
220
+ )
221
+ run_button = gr.Button("Run", scale=0)
222
+
223
+ style_image = gr.Image(label="Style reference image")
224
 
225
  noise_scale = gr.Slider(
226
  label="Noise Scale",
 
233
  with gr.Blocks():
234
 
235
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
236
  result = gr.Image(label="Result", show_label=False)
237
 
238
  with gr.Accordion("Advanced options", open=False):
images/6.png ADDED

Git LFS Details

  • SHA256: 1cb23bbf5d35aad2bdad146b9f8623d237255baf3dfba38cffa5f613364e1c2a
  • Pointer size: 131 Bytes
  • Size of remote file: 254 kB
images/7.png ADDED

Git LFS Details

  • SHA256: ac6a2c9e41ebdac0f2bffdfe8adc87380afbe54196b8ac2326a6d7f05e2f3ef8
  • Pointer size: 131 Bytes
  • Size of remote file: 203 kB
images/8.png ADDED

Git LFS Details

  • SHA256: 04037fa01871e2c9f30f5b0dcdf21159299f94c94dd87ecf48a6de50e8f1a5d0
  • Pointer size: 131 Bytes
  • Size of remote file: 122 kB
requirements.txt CHANGED
@@ -1,12 +1,14 @@
1
  accelerate
2
  diffusers
 
 
3
  gradio==4.37.2
4
  numpy==1.26.4
 
 
 
5
  spaces
6
- torch==2.0.1
7
  torchvision
8
  transformers >= 4.34.0
9
- xformers
10
- ftfy
11
- peft==0.6.0
12
- optimum
 
1
  accelerate
2
  diffusers
3
+ fastapi==0.112.2
4
+ ftfy
5
  gradio==4.37.2
6
  numpy==1.26.4
7
+ optimum
8
+ peft==0.6.0
9
+ pydantic
10
  spaces
11
+ torch>=2.0.1
12
  torchvision
13
  transformers >= 4.34.0
14
+ xformers