alex commited on
Commit
dde723b
·
1 Parent(s): 867aab6

allow different orientation

Browse files
Files changed (2) hide show
  1. app.py +20 -3
  2. requirements.txt +1 -0
app.py CHANGED
@@ -46,6 +46,7 @@ from diffusers import FluxPipeline
46
  import tempfile
47
  from ovi.utils.io_utils import save_video
48
  from ovi.utils.processing_utils import clean_text, scale_hw_to_area_divisible
 
49
 
50
  # ----------------------------
51
  # Parse CLI Args
@@ -126,6 +127,7 @@ def generate_video(
126
  slg_layer = 11,
127
  video_negative_prompt = "",
128
  audio_negative_prompt = "",
 
129
  ):
130
  try:
131
  image_path = None
@@ -176,6 +178,19 @@ def generate_image(text_prompt, image_seed, image_height, image_width):
176
  image.save(tmpfile.name)
177
  return tmpfile.name
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  css = """
180
  #col-container {
181
  margin: 0 auto;
@@ -193,7 +208,7 @@ css = """
193
 
194
  with gr.Blocks(css=css) as demo:
195
 
196
- session_state = gr.State()
197
 
198
  with gr.Column(elem_id="col-container"):
199
  gr.HTML(
@@ -217,7 +232,7 @@ with gr.Blocks(css=css) as demo:
217
  with gr.Row():
218
  with gr.Column():
219
  # Image section
220
- image = gr.Image(type="filepath", label="First Frame Image (upload or generate)")
221
 
222
  if args.use_image_gen:
223
  with gr.Accordion("🖼️ Image Generation Options", visible=True):
@@ -235,7 +250,7 @@ with gr.Blocks(css=css) as demo:
235
  value=50,
236
  label="Sample Steps",
237
  minimum=20,
238
- maximum=100,
239
  step=1.0
240
  )
241
  run_btn = gr.Button("Generate Video 🚀", variant="primary")
@@ -294,6 +309,8 @@ with gr.Blocks(css=css) as demo:
294
  cache_examples=True,
295
  )
296
 
 
 
297
  if args.use_image_gen and gen_img_btn is not None:
298
  gen_img_btn.click(
299
  fn=generate_image,
 
46
  import tempfile
47
  from ovi.utils.io_utils import save_video
48
  from ovi.utils.processing_utils import clean_text, scale_hw_to_area_divisible
49
+ from gradio_extendedimage import extendedimage
50
 
51
  # ----------------------------
52
  # Parse CLI Args
 
127
  slg_layer = 11,
128
  video_negative_prompt = "",
129
  audio_negative_prompt = "",
130
+ progress=gr.Progress(track_tqdm=True)
131
  ):
132
  try:
133
  image_path = None
 
178
  image.save(tmpfile.name)
179
  return tmpfile.name
180
 
181
+ def orientation_changed(evt: gr.EventData):
182
+
183
+ detail = getattr(evt, "data", None) or getattr(evt, "_data", {}) or {}
184
+
185
+ if detail['value'] == "9:16":
186
+ orientation_state = [[992, 512]]
187
+ elif detail['value'] == "1:1":
188
+ orientation_state = [[992, 992]]
189
+ elif detail['value'] == "16:9":
190
+ orientation_state = [[512, 992]]
191
+
192
+ return orientation_state
193
+
194
  css = """
195
  #col-container {
196
  margin: 0 auto;
 
208
 
209
  with gr.Blocks(css=css) as demo:
210
 
211
+ orientation_state = gr.State([[992, 512]])
212
 
213
  with gr.Column(elem_id="col-container"):
214
  gr.HTML(
 
232
  with gr.Row():
233
  with gr.Column():
234
  # Image section
235
+ image = extendedimage(type="filepath", label="Image")
236
 
237
  if args.use_image_gen:
238
  with gr.Accordion("🖼️ Image Generation Options", visible=True):
 
250
  value=50,
251
  label="Sample Steps",
252
  minimum=20,
253
+ maximum=50,
254
  step=1.0
255
  )
256
  run_btn = gr.Button("Generate Video 🚀", variant="primary")
 
309
  cache_examples=True,
310
  )
311
 
312
+ image.orientation(fn=orientation_changed, outputs=[orientation_state])
313
+
314
  if args.use_image_gen and gen_img_btn is not None:
315
  gen_img_btn.click(
316
  fn=generate_image,
requirements.txt CHANGED
@@ -5,6 +5,7 @@ transformers>=4.49.0,<=4.51.3
5
  tokenizers>=0.20.3
6
  accelerate>=1.1.1
7
 
 
8
  tqdm
9
  imageio[ffmpeg]
10
  easydict
 
5
  tokenizers>=0.20.3
6
  accelerate>=1.1.1
7
 
8
+ gradio_extendedimage @ https://github.com/OutofAi/gradio-extendedimage/releases/download/0.0.2/gradio_extendedimage-0.0.2-py3-none-any.whl
9
  tqdm
10
  imageio[ffmpeg]
11
  easydict