2020-08-22 07:17:11 +08:00
|
|
|
# Demo: (File, File) -> (File)
|
|
|
|
|
2020-08-20 19:57:07 +08:00
|
|
|
import gradio as gr
|
|
|
|
from zipfile import ZipFile
|
|
|
|
|
2020-08-28 23:56:03 +08:00
|
|
|
|
2020-08-20 19:57:07 +08:00
|
|
|
def zip_two_files(file1, file2):
|
|
|
|
with ZipFile('tmp.zip', 'w') as zipObj:
|
|
|
|
zipObj.write(file1.name, "file1")
|
|
|
|
zipObj.write(file2.name, "file2")
|
|
|
|
return "tmp.zip"
|
|
|
|
|
2020-08-28 23:56:03 +08:00
|
|
|
|
2020-11-11 22:15:53 +08:00
|
|
|
iface = gr.Interface(
|
2020-10-29 02:39:28 +08:00
|
|
|
zip_two_files,
|
|
|
|
["file", "file"],
|
|
|
|
"file",
|
|
|
|
examples=[
|
|
|
|
["images/1.jpg", "images/2.jpg"],
|
|
|
|
["files/titanic.csv", "audio/cantina.wav"],
|
|
|
|
]
|
|
|
|
)
|
2020-08-28 23:56:03 +08:00
|
|
|
|
2020-11-11 22:15:53 +08:00
|
|
|
iface.test_launch()
|
|
|
|
if __name__ == "__main__":
|
|
|
|
iface.launch()
|