File size: 1,040 Bytes
6dc443d
47d95c0
6dc443d
 
 
 
72baa29
 
6dc443d
 
 
 
 
 
 
 
 
47d95c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6dc443d
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from typing import Dict
from pathlib import Path

import gradio as gr


# def predict(text: str) -> Dict:
#     return {"alive": 0.9, "death": 0.1}
    

example_list = [[1.0, 1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0]]

# Create title, description and article strings
title = "This is title."
description = "This is description."
article = "This is article."

def upload_file(filepath):
    name = Path(filepath).name
    return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]

def download_file():
    return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]

with gr.Blocks() as demo:
    gr.Markdown("First upload a file and and then you'll be able download it (but only once!)")
    with gr.Row():
        u = gr.UploadButton("Upload a file", file_count="single")
        d = gr.DownloadButton("Download the file", visible=False)

    u.upload(upload_file, u, [u, d])
    d.click(download_file, None, [u, d])

demo.launch(debug=False,
           share=True)