jbilcke-hf HF staff commited on
Commit
beaef0c
1 Parent(s): 8ab9fd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -52,7 +52,12 @@ def model_select(selected_file):
52
  del state_dict
53
  return
54
 
55
-
 
 
 
 
 
56
 
57
  # ----------------------------- FRAME INTERPOLATION ---------------------------------
58
  # we cannot afford to use AI-based algorithms such as FILM or ST-MFNet,
@@ -190,7 +195,7 @@ max_64_bit_int = 2**63 - 1
190
 
191
  def sample(
192
  secret_token: str,
193
- image: Image,
194
  seed: Optional[int] = 42,
195
  randomize_seed: bool = False,
196
  motion_bucket_id: int = 80,
@@ -207,6 +212,8 @@ def sample(
207
  raise gr.Error(
208
  f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
209
 
 
 
210
  if image.mode == "RGBA":
211
  image = image.convert("RGB")
212
 
 
52
  del state_dict
53
  return
54
 
55
+ def decode_data_uri_to_image(data_uri):
56
+ # parse the data uri
57
+ header, encoded = data_uri.split(",", 1)
58
+ data = base64.b64decode(encoded)
59
+ img = Image.open(BytesIO(data))
60
+ return img
61
 
62
  # ----------------------------- FRAME INTERPOLATION ---------------------------------
63
  # we cannot afford to use AI-based algorithms such as FILM or ST-MFNet,
 
195
 
196
  def sample(
197
  secret_token: str,
198
+ input_image_base64: Image,
199
  seed: Optional[int] = 42,
200
  randomize_seed: bool = False,
201
  motion_bucket_id: int = 80,
 
212
  raise gr.Error(
213
  f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
214
 
215
+ image = decode_data_uri_to_image(input_image_base64)
216
+
217
  if image.mode == "RGBA":
218
  image = image.convert("RGB")
219