1aurent commited on
Commit
cb6e7cb
1 Parent(s): 256da70

add examples

Browse files
Files changed (2) hide show
  1. src/app.py +37 -4
  2. src/utils.py +2 -4
src/app.py CHANGED
@@ -114,10 +114,20 @@ with gr.Blocks() as demo:
114
 
115
  with gr.Row():
116
  with gr.Column():
117
- input_image = gr.Image(type="pil", label="Input Image", image_mode="RGBA")
118
- run_button = gr.Button(value="Relight Image")
 
 
 
 
 
 
119
  with gr.Column():
120
- output_image = gr.Image(label="Result")
 
 
 
 
121
 
122
  with gr.Accordion("Advanced Settings", open=True):
123
  prompt = gr.Textbox(
@@ -221,6 +231,28 @@ with gr.Blocks() as demo:
221
  25,
222
  69_420,
223
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  ],
225
  inputs=[
226
  input_image,
@@ -235,7 +267,8 @@ with gr.Blocks() as demo:
235
  ],
236
  outputs=output_image,
237
  fn=process,
238
- cache_examples="lazy", # type: ignore
 
239
  run_on_click=False,
240
  )
241
 
 
114
 
115
  with gr.Row():
116
  with gr.Column():
117
+ input_image = gr.Image(
118
+ label="Input Image (RGBA)",
119
+ image_mode="RGBA",
120
+ type="pil",
121
+ )
122
+ run_button = gr.Button(
123
+ value="Relight Image",
124
+ )
125
  with gr.Column():
126
+ output_image = gr.Image(
127
+ label="Relighted Image (RGB)",
128
+ image_mode="RGB",
129
+ type="pil",
130
+ )
131
 
132
  with gr.Accordion("Advanced Settings", open=True):
133
  prompt = gr.Textbox(
 
231
  25,
232
  69_420,
233
  ],
234
+ [
235
+ "examples/chair.png",
236
+ "Right",
237
+ "god rays, fluffy clouds, peaceful surreal atmosphere, high-quality, HEIC, CR2, NEF",
238
+ "dirty, messy, worst quality, low quality, watermark, signature, jpeg artifacts, deformed, monochrome, black and white",
239
+ 0.9,
240
+ 0.5,
241
+ 1.25,
242
+ 25,
243
+ 69,
244
+ ],
245
+ [
246
+ "examples/bunny.png",
247
+ "Left",
248
+ "grass field, high-quality, HEIC, CR2, NEF",
249
+ "dirty, messy, worst quality, low quality, watermark, signature, jpeg artifacts, deformed, monochrome, black and white",
250
+ 0.9,
251
+ 0.5,
252
+ 1.25,
253
+ 25,
254
+ 420,
255
+ ],
256
  ],
257
  inputs=[
258
  input_image,
 
267
  ],
268
  outputs=output_image,
269
  fn=process,
270
+ cache_examples=True,
271
+ cache_mode="lazy",
272
  run_on_click=False,
273
  )
274
 
src/utils.py CHANGED
@@ -53,8 +53,7 @@ def resize_modulo_8(
53
  resample: Image.Resampling | None = None,
54
  on_short: bool = True,
55
  ) -> Image.Image:
56
- """
57
- Resize an image respecting the aspect ratio and ensuring the size is a multiple of 8.
58
 
59
  The `on_short` parameter determines whether the resizing is based on the shortest side.
60
  """
@@ -73,8 +72,7 @@ class LightingPreference(str, Enum):
73
  NONE = auto()
74
 
75
  def get_init_image(self, width: int, height: int, interval: tuple[float, float] = (0.0, 1.0)) -> Image.Image | None:
76
- """
77
- Generate an image with a linear gradient based on the lighting preference.
78
 
79
  In the original code, interval is always (0., 1.) ; we added it as a parameter to make the function more
80
  flexible and allow for less contrasted images with a smaller interval.
 
53
  resample: Image.Resampling | None = None,
54
  on_short: bool = True,
55
  ) -> Image.Image:
56
+ """Resize an image respecting the aspect ratio and ensuring the size is a multiple of 8.
 
57
 
58
  The `on_short` parameter determines whether the resizing is based on the shortest side.
59
  """
 
72
  NONE = auto()
73
 
74
  def get_init_image(self, width: int, height: int, interval: tuple[float, float] = (0.0, 1.0)) -> Image.Image | None:
75
+ """Generate an image with a linear gradient based on the lighting preference.
 
76
 
77
  In the original code, interval is always (0., 1.) ; we added it as a parameter to make the function more
78
  flexible and allow for less contrasted images with a smaller interval.