Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -115,12 +115,46 @@ def display_videos(type, prompt, model_name_1, model_name_2):
|
|
115 |
|
116 |
def record_user_feedback_a(model_name1, model_name2, type, prompt):
|
117 |
# 0 means model A better, 1 means model B better
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
f.write(f"{model_name1}\t{model_name2}\t{type}\t{prompt}\t{0}\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
def record_user_feedback_b(model_name1, model_name2, type, prompt):
|
121 |
# 0 means model A better, 1 means model B better
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
f.write(f"{model_name1}\t{model_name2}\t{type}\t{prompt}\t{1}\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
with gr.Blocks() as interface:
|
126 |
gr.Markdown("# VBench Video Arena")
|
@@ -144,8 +178,8 @@ If you are interested, you can also leave your comments.""")
|
|
144 |
model_name_2_output = gr.Dropdown(label="Model Name 2", choices=model_names, value=model_names[1])
|
145 |
video_output_2 = gr.Video(label="Video 2")
|
146 |
with gr.Row():
|
147 |
-
feed0 = gr.Button("👈 Model A is better")
|
148 |
-
feed1 = gr.Button("👉 Model B is better")
|
149 |
type_output.change(fn=update_prompt_options, inputs=[type_output], outputs=[prompt_output])
|
150 |
|
151 |
|
@@ -154,9 +188,14 @@ If you are interested, you can also leave your comments.""")
|
|
154 |
outputs=[video_output_1, video_output_2,model_name_1_output, model_name_2_output, type_output, prompt_placeholder]
|
155 |
).then(fn=update_prompt_options,
|
156 |
inputs=[type_output],
|
157 |
-
outputs=[prompt_output]
|
|
|
158 |
inputs=[type_output,prompt_placeholder],
|
159 |
-
outputs=[prompt_output]
|
|
|
|
|
|
|
|
|
160 |
|
161 |
|
162 |
display_button.click(
|
@@ -167,11 +206,13 @@ If you are interested, you can also leave your comments.""")
|
|
167 |
|
168 |
feed0.click(
|
169 |
fn = record_user_feedback_a,
|
170 |
-
inputs=[model_name_1_output, model_name_2_output, type_output, prompt_placeholder]
|
|
|
171 |
)
|
172 |
feed1.click(
|
173 |
fn = record_user_feedback_b,
|
174 |
-
inputs=[model_name_1_output, model_name_2_output, type_output, prompt_placeholder]
|
|
|
175 |
)
|
176 |
|
177 |
interface.launch()
|
|
|
115 |
|
116 |
def record_user_feedback_a(model_name1, model_name2, type, prompt):
|
117 |
# 0 means model A better, 1 means model B better
|
118 |
+
hf_api.hf_hub_download(
|
119 |
+
repo_id = "Vchitect/VBench_human_annotation",
|
120 |
+
filename = "arena_feedback.csv",
|
121 |
+
repo_type = "dataset",
|
122 |
+
local_dir = './'
|
123 |
+
)
|
124 |
+
with open("arena_feedback.csv",'a') as f:
|
125 |
f.write(f"{model_name1}\t{model_name2}\t{type}\t{prompt}\t{0}\n")
|
126 |
+
hf_api.upload_file(
|
127 |
+
path_or_fileobj="arena_feedback.csv",
|
128 |
+
path_in_repo="arena_feedback.csv",
|
129 |
+
repo_id="Vchitect/VBench_human_annotation",
|
130 |
+
token=hf_token,
|
131 |
+
repo_type="dataset",
|
132 |
+
commit_message="[From VBench Arena] user feedback",
|
133 |
+
)
|
134 |
+
return gr.update(visible=False),gr.update(visible=False)
|
135 |
+
|
136 |
def record_user_feedback_b(model_name1, model_name2, type, prompt):
|
137 |
# 0 means model A better, 1 means model B better
|
138 |
+
hf_api.hf_hub_download(
|
139 |
+
repo_id = "Vchitect/VBench_human_annotation",
|
140 |
+
filename = "arena_feedback.csv",
|
141 |
+
repo_type = "dataset",
|
142 |
+
local_dir = './'
|
143 |
+
)
|
144 |
+
with open("arena_feedback.csv",'a') as f:
|
145 |
f.write(f"{model_name1}\t{model_name2}\t{type}\t{prompt}\t{1}\n")
|
146 |
+
hf_api.upload_file(
|
147 |
+
path_or_fileobj="arena_feedback.csv",
|
148 |
+
path_in_repo="arena_feedback.csv",
|
149 |
+
repo_id="Vchitect/VBench_human_annotation",
|
150 |
+
token=hf_token,
|
151 |
+
repo_type="dataset",
|
152 |
+
commit_message="[From VBench Arena] user feedback",
|
153 |
+
)
|
154 |
+
return gr.update(visible=False),gr.update(visible=False)
|
155 |
+
|
156 |
+
def show_feedback_button():
|
157 |
+
return gr.update(visible=True),gr.update(visible=True)
|
158 |
|
159 |
with gr.Blocks() as interface:
|
160 |
gr.Markdown("# VBench Video Arena")
|
|
|
178 |
model_name_2_output = gr.Dropdown(label="Model Name 2", choices=model_names, value=model_names[1])
|
179 |
video_output_2 = gr.Video(label="Video 2")
|
180 |
with gr.Row():
|
181 |
+
feed0 = gr.Button("👈 Model A is better",visible=False)
|
182 |
+
feed1 = gr.Button("👉 Model B is better",visible=False)
|
183 |
type_output.change(fn=update_prompt_options, inputs=[type_output], outputs=[prompt_output])
|
184 |
|
185 |
|
|
|
188 |
outputs=[video_output_1, video_output_2,model_name_1_output, model_name_2_output, type_output, prompt_placeholder]
|
189 |
).then(fn=update_prompt_options,
|
190 |
inputs=[type_output],
|
191 |
+
outputs=[prompt_output]
|
192 |
+
).then(fn=update_prompt_options,
|
193 |
inputs=[type_output,prompt_placeholder],
|
194 |
+
outputs=[prompt_output]
|
195 |
+
).then(
|
196 |
+
fn= show_feedback_button,
|
197 |
+
outputs=[feed0, feed1]
|
198 |
+
)
|
199 |
|
200 |
|
201 |
display_button.click(
|
|
|
206 |
|
207 |
feed0.click(
|
208 |
fn = record_user_feedback_a,
|
209 |
+
inputs=[model_name_1_output, model_name_2_output, type_output, prompt_placeholder],
|
210 |
+
outputs=[feed0, feed1]
|
211 |
)
|
212 |
feed1.click(
|
213 |
fn = record_user_feedback_b,
|
214 |
+
inputs=[model_name_1_output, model_name_2_output, type_output, prompt_placeholder],
|
215 |
+
outputs=[feed0, feed1]
|
216 |
)
|
217 |
|
218 |
interface.launch()
|