CharlieAmalet Fabrice-TIERCELIN commited on
Commit
42036ef
·
verified ·
1 Parent(s): 49812df

Allows to automatically change the seed (#1)

Browse files

- Allows to automatically change the seed (91038eb5e1e00cceace9db1542e315d2bcbaaee6)


Co-authored-by: Fabrice TIERCELIN <[email protected]>

Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -68,6 +68,7 @@ max_64_bit_int = 2**63 - 1
68
  @spaces.GPU(enable_queue=True, duration=240)
69
  def generate_video(
70
  image: Image,
 
71
  seed: int,
72
  motion_bucket_id: int = 127,
73
  fps_id: int = 6,
@@ -87,6 +88,9 @@ def generate_video(
87
 
88
  if image.mode == "RGBA":
89
  image = image.convert("RGB")
 
 
 
90
 
91
  generator = torch.manual_seed(seed)
92
 
@@ -162,6 +166,7 @@ with gr.Blocks(css=css) as SVD_XT_1_1:
162
  image = gr.Image(label="Upload your image", type="pil")
163
  generate_btn = gr.Button("Generate")
164
  # base64_out = gr.Textbox(label="Base64 Video")
 
165
  seed = gr.Slider(label="Seed", value=42, randomize=False, minimum=0, maximum=max_64_bit_int, step=1)
166
  motion_bucket_id = gr.Slider(label="Motion bucket id", info="Controls how much motion to add/remove from the image", value=127, minimum=1, maximum=255)
167
  fps_id = gr.Slider(label="Frames per second", info="The length of your video in seconds will be 25/fps", value=6, minimum=5, maximum=30)
@@ -176,7 +181,7 @@ with gr.Blocks(css=css) as SVD_XT_1_1:
176
 
177
  generate_btn.click(
178
  fn=generate_video,
179
- inputs=[image, seed, motion_bucket_id, fps_id],
180
  outputs=video_out,
181
  api_name="run"
182
  )
 
68
  @spaces.GPU(enable_queue=True, duration=240)
69
  def generate_video(
70
  image: Image,
71
+ randomize_seed: bool = True,
72
  seed: int,
73
  motion_bucket_id: int = 127,
74
  fps_id: int = 6,
 
88
 
89
  if image.mode == "RGBA":
90
  image = image.convert("RGB")
91
+
92
+ if randomize_seed:
93
+ seed = random.randint(0, 2147483647)
94
 
95
  generator = torch.manual_seed(seed)
96
 
 
166
  image = gr.Image(label="Upload your image", type="pil")
167
  generate_btn = gr.Button("Generate")
168
  # base64_out = gr.Textbox(label="Base64 Video")
169
+ randomize_seed = gr.Checkbox(label="\U0001F3B2 Randomize seed", value=True, info="If checked, result is always different")
170
  seed = gr.Slider(label="Seed", value=42, randomize=False, minimum=0, maximum=max_64_bit_int, step=1)
171
  motion_bucket_id = gr.Slider(label="Motion bucket id", info="Controls how much motion to add/remove from the image", value=127, minimum=1, maximum=255)
172
  fps_id = gr.Slider(label="Frames per second", info="The length of your video in seconds will be 25/fps", value=6, minimum=5, maximum=30)
 
181
 
182
  generate_btn.click(
183
  fn=generate_video,
184
+ inputs=[image, randomize_seed, seed, motion_bucket_id, fps_id],
185
  outputs=video_out,
186
  api_name="run"
187
  )