mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
Fix file serialization so that output is json serializable (#2999)
* Add comments * CHANGELOG Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
43f0bedf52
commit
2bbec4b41e
@ -6,7 +6,8 @@ No changes to highlight.
|
||||
## Bug Fixes:
|
||||
* Fixes bug where interpretation event was not configured correctly by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2993](https://github.com/gradio-app/gradio/pull/2993)
|
||||
* Fix relative import bug in reload mode by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2992](https://github.com/gradio-app/gradio/pull/2992)
|
||||
* Fixes bug where png files were not being recognized when uploadin images by [@abidlabs](https://github.com/abidlabs) in [PR 3002](https://github.com/gradio-app/gradio/pull/3002)
|
||||
* Fix bug where file serialization output was not JSON serializable by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2999](https://github.com/gradio-app/gradio/pull/2999)
|
||||
* Fixes bug where png files were not being recognized when uploading images by [@abidlabs](https://github.com/abidlabs) in [PR 3002](https://github.com/gradio-app/gradio/pull/3002)
|
||||
|
||||
## Documentation Changes:
|
||||
No changes to highlight.
|
||||
|
@ -119,7 +119,7 @@ class FileSerializable(Serializable):
|
||||
"""
|
||||
if x is None or x == "":
|
||||
return None
|
||||
filename = Path(load_dir) / x
|
||||
filename = str(Path(load_dir) / x)
|
||||
return {
|
||||
"name": filename,
|
||||
"data": processing_utils.encode_url_or_file_to_base64(
|
||||
|
@ -796,7 +796,6 @@ class TestAudio:
|
||||
assert isinstance(audio_input.preprocess(x_wav), str)
|
||||
with pytest.raises(ValueError):
|
||||
gr.Audio(type="unknown")
|
||||
audio_input = gr.Audio(type="numpy")
|
||||
|
||||
# Output functionalities
|
||||
y_audio = gr.processing_utils.decode_base64_to_file(
|
||||
@ -829,6 +828,15 @@ class TestAudio:
|
||||
output2 = audio_output.postprocess(y_audio.name)
|
||||
assert output1 == output2
|
||||
|
||||
def test_serialize(self):
|
||||
audio_input = gr.Audio()
|
||||
assert audio_input.serialize("test/test_files/audio_sample.wav") == {
|
||||
"data": media_data.BASE64_AUDIO["data"],
|
||||
"is_file": False,
|
||||
"orig_name": "audio_sample.wav",
|
||||
"name": "test/test_files/audio_sample.wav",
|
||||
}
|
||||
|
||||
def test_tokenize(self):
|
||||
"""
|
||||
Tokenize, get_masked_inputs
|
||||
|
Loading…
Reference in New Issue
Block a user