clarice7 commited on
Commit
424cf41
1 Parent(s): 966c960

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -84,7 +84,8 @@ def query_agent(description, question, image0, image1):
84
  return None, None
85
 
86
  def simulate(image0, image1):
87
- print(image0, image1)
 
88
  preferences = []
89
  reasons = []
90
  probs = []
@@ -111,6 +112,22 @@ def simulate(image0, image1):
111
 
112
  subtitle = "Upload two images of emails and see which is generally preferred by Petco customers!"
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  demo = gr.Interface(fn=simulate,
115
  inputs=[gr.UploadButton("Click to Upload Email 0", file_types=["image"], file_count="single"),
116
  gr.UploadButton("Click to Upload Email 1", file_types=["image"], file_count="single")],
 
84
  return None, None
85
 
86
  def simulate(image0, image1):
87
+ upload_file(image0)
88
+ upload_file(image1)
89
  preferences = []
90
  reasons = []
91
  probs = []
 
112
 
113
  subtitle = "Upload two images of emails and see which is generally preferred by Petco customers!"
114
 
115
+
116
+ from pathlib import Path
117
+
118
+ def upload_file(filepath):
119
+ name = Path(filepath).name
120
+ return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"{name}", value=filepath, visible=True)]
121
+
122
+ # with gr.Blocks() as demo:
123
+ # gr.Markdown("First upload a file and and then you'll be able download it (but only once!)")
124
+ # with gr.Row():
125
+ # u = gr.UploadButton("Upload a file", file_count="single")
126
+ # d = gr.DownloadButton("Download the file", visible=False)
127
+
128
+ # u.upload(upload_file, u, [u, d])
129
+ # d.click(download_file, None, [u, d])
130
+
131
  demo = gr.Interface(fn=simulate,
132
  inputs=[gr.UploadButton("Click to Upload Email 0", file_types=["image"], file_count="single"),
133
  gr.UploadButton("Click to Upload Email 1", file_types=["image"], file_count="single")],