Fix video serializing in client (#3860)

* Fix video serializing in client

* Add to changelog

* Remove print
This commit is contained in:
Freddy Boulton 2023-04-14 17:07:19 -07:00 committed by GitHub
parent 1b4925712b
commit 7ef0439d3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -6,7 +6,7 @@ No changes to highlight.
## Bug Fixes:
No changes to highlight.
- Fixed bug where `Video` components in latest gradio were not able to be deserialized by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3860](https://github.com/gradio-app/gradio/pull/3860)
## Documentation Changes:

View File

@ -368,7 +368,7 @@ class VideoSerializable(FileSerializable):
Convert from serialized representation of a file (base64) to a human-friendly
version (string filepath). Optionally, save the file to the directory specified by `save_dir`
"""
if isinstance(x, tuple):
if isinstance(x, (tuple, list)):
assert len(x) == 2, f"Expected tuple of length 2. Received: {x}"
x_as_list = [x[0], x[1]]
else:
@ -501,7 +501,12 @@ class GallerySerializable(Serializable):
return os.path.abspath(gallery_path)
SERIALIZER_MAPPING = {cls.__name__: cls for cls in Serializable.__subclasses__()}
SERIALIZER_MAPPING = {}
for cls in Serializable.__subclasses__():
SERIALIZER_MAPPING[cls.__name__] = cls
for subcls in cls.__subclasses__():
SERIALIZER_MAPPING[subcls.__name__] = subcls
SERIALIZER_MAPPING["Serializable"] = SimpleSerializable
SERIALIZER_MAPPING["File"] = FileSerializable
SERIALIZER_MAPPING["UploadButton"] = FileSerializable