Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +26 -7
- requirements.txt +2 -1
app.py
CHANGED
@@ -110,13 +110,32 @@ def simulate(image0, image1):
|
|
110 |
|
111 |
subtitle = "Upload two images of emails and see which is generally preferred by Petco customers!"
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
if __name__ == "__main__":
|
122 |
demo.launch()
|
|
|
110 |
|
111 |
subtitle = "Upload two images of emails and see which is generally preferred by Petco customers!"
|
112 |
|
113 |
+
|
114 |
+
from pathlib import Path
|
115 |
+
|
116 |
+
def upload_file(filepath):
|
117 |
+
name = Path(filepath).name
|
118 |
+
return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)]
|
119 |
+
|
120 |
+
def download_file():
|
121 |
+
return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]
|
122 |
+
|
123 |
+
with gr.Blocks() as demo:
|
124 |
+
gr.Markdown("First upload a file and and then you'll be able download it (but only once!)")
|
125 |
+
with gr.Row():
|
126 |
+
u = gr.UploadButton("Upload a file", file_count="single")
|
127 |
+
d = gr.DownloadButton("Download the file", visible=False)
|
128 |
+
|
129 |
+
u.upload(upload_file, u, [u, d])
|
130 |
+
d.click(download_file, None, [u, d])
|
131 |
+
|
132 |
+
# demo = gr.Interface(fn=simulate,
|
133 |
+
# inputs=[gr.UploadButton("Click to Upload Email 0", file_types=["image"], file_count="single"),
|
134 |
+
# gr.UploadButton("Click to Upload Email 1", file_types=["image"], file_count="single")],
|
135 |
+
# outputs="text",
|
136 |
+
# title="Pairwise Simulation of Petco Email Preference",
|
137 |
+
# description=subtitle
|
138 |
+
# )
|
139 |
|
140 |
if __name__ == "__main__":
|
141 |
demo.launch()
|
requirements.txt
CHANGED
@@ -2,4 +2,5 @@ openai
|
|
2 |
https://gradio-builds.s3.amazonaws.com/75ed61524f55e542414d165ed60a976091c24f77/gradio-3.16.2-py3-none-any.whl
|
3 |
pandas
|
4 |
numpy
|
5 |
-
datasets
|
|
|
|
2 |
https://gradio-builds.s3.amazonaws.com/75ed61524f55e542414d165ed60a976091c24f77/gradio-3.16.2-py3-none-any.whl
|
3 |
pandas
|
4 |
numpy
|
5 |
+
datasets
|
6 |
+
pathlib
|