apsys commited on
Commit
d4a2bc9
1 Parent(s): 301c74c
Files changed (2) hide show
  1. app.py +82 -36
  2. data/leaderboard.json +1 -1
app.py CHANGED
@@ -11,6 +11,35 @@ from gradio_space_ci import enable_space_ci
11
  import json
12
  from io import BytesIO
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  from src.display.about import (
16
  INTRODUCTION_TEXT,
@@ -78,44 +107,61 @@ def build_demo():
78
  gr.Markdown("# ✨ Submit your model here!", elem_classes="markdown-text")
79
 
80
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  model_name_textbox = gr.Textbox(label="Model name")
82
  submitter_username = gr.Textbox(label="Username")
83
 
84
- def upload_file(file,su,mn):
85
- file_path = file.name.split("/")[-1] if "/" in file.name else file.name
86
- logging.info("New submition: file saved to %s", file_path)
87
- with open(file.name, "r") as f:
88
- v=json.load(f)
89
- new_file = v['results']
90
- new_file['model'] = mn+"/"+su
91
- new_file['moviesmc']=new_file['moviemc']["acc,none"]
92
- new_file['musicmc']=new_file['musicmc']["acc,none"]
93
- new_file['booksmc']=new_file['bookmc']["acc,none"]
94
- new_file['lawmc']=new_file['lawmc']["acc,none"]
95
- # name = v['config']["model_args"].split('=')[1].split(',')[0]
96
- new_file['model_dtype'] = v['config']["model_dtype"]
97
- new_file['ppl'] = 0
98
- new_file.pop('moviemc')
99
- new_file.pop('bookmc')
100
- buf = BytesIO()
101
- buf.write(json.dumps(new_file).encode('utf-8'))
102
- API.upload_file(
103
- path_or_fileobj=buf,
104
- path_in_repo="model_data/external/" + su+mn + ".json",
105
- repo_id="Vikhrmodels/s-openbench-eval",
106
- repo_type="dataset",
107
- )
108
- os.environ[RESET_JUDGEMENT_ENV] = "1"
109
- return file.name
110
-
111
- if model_name_textbox and submitter_username:
112
- file_output = gr.File()
113
- upload_button = gr.UploadButton(
114
- "Click to Upload & Submit Answers", file_types=["*"], file_count="single"
115
- )
116
- upload_button.upload(upload_file, [upload_button,model_name_textbox,submitter_username], file_output)
117
-
118
- return demo
119
 
120
 
121
  # print(os.system('cd src/gen && ../../.venv/bin/python gen_judgment.py'))
@@ -169,7 +215,7 @@ if __name__ == "__main__":
169
  os.environ[RESET_JUDGEMENT_ENV] = "1"
170
 
171
  scheduler = BackgroundScheduler()
172
- scheduler.add_job(update_board, "interval", minutes=600)
173
  scheduler.start()
174
 
175
  demo_app = build_demo()
 
11
  import json
12
  from io import BytesIO
13
 
14
+ def handle_file_upload(file):
15
+ file_path = file.name.split("/")[-1] if "/" in file.name else file.name
16
+ logging.info("File uploaded: %s", file_path)
17
+ with open(file.name, "r") as f:
18
+ v = json.load(f)
19
+ return v, file_path
20
+
21
+ def submit_file(v, file_path, su, mn):
22
+ new_file = v['results']
23
+ new_file['model'] = mn + "/" + su
24
+ new_file['moviesmc'] = new_file['moviemc']["acc,none"]
25
+ new_file['musicmc'] = new_file['musicmc']["acc,none"]
26
+ new_file['booksmc'] = new_file['bookmc']["acc,none"]
27
+ new_file['lawmc'] = new_file['lawmc']["acc,none"]
28
+ new_file['model_dtype'] = v['config']["model_dtype"]
29
+ new_file['ppl'] = 0
30
+ new_file.pop('moviemc')
31
+ new_file.pop('bookmc')
32
+
33
+ buf = BytesIO()
34
+ buf.write(json.dumps(new_file).encode('utf-8'))
35
+ API.upload_file(
36
+ path_or_fileobj=buf,
37
+ path_in_repo="model_data/external/" + su + mn + ".json",
38
+ repo_id="Vikhrmodels/s-openbench-eval",
39
+ repo_type="dataset",
40
+ )
41
+ os.environ[RESET_JUDGEMENT_ENV] = "1"
42
+ return "Success!"
43
 
44
  from src.display.about import (
45
  INTRODUCTION_TEXT,
 
107
  gr.Markdown("# ✨ Submit your model here!", elem_classes="markdown-text")
108
 
109
  with gr.Column():
110
+
111
+ # def upload_file(file,su,mn):
112
+ # file_path = file.name.split("/")[-1] if "/" in file.name else file.name
113
+ # logging.info("New submition: file saved to %s", file_path)
114
+ # with open(file.name, "r") as f:
115
+ # v=json.load(f)
116
+ # new_file = v['results']
117
+ # new_file['model'] = mn+"/"+su
118
+ # new_file['moviesmc']=new_file['moviemc']["acc,none"]
119
+ # new_file['musicmc']=new_file['musicmc']["acc,none"]
120
+ # new_file['booksmc']=new_file['bookmc']["acc,none"]
121
+ # new_file['lawmc']=new_file['lawmc']["acc,none"]
122
+ # # name = v['config']["model_args"].split('=')[1].split(',')[0]
123
+ # new_file['model_dtype'] = v['config']["model_dtype"]
124
+ # new_file['ppl'] = 0
125
+ # new_file.pop('moviemc')
126
+ # new_file.pop('bookmc')
127
+ # buf = BytesIO()
128
+ # buf.write(json.dumps(new_file).encode('utf-8'))
129
+ # API.upload_file(
130
+ # path_or_fileobj=buf,
131
+ # path_in_repo="model_data/external/" + su+mn + ".json",
132
+ # repo_id="Vikhrmodels/s-openbench-eval",
133
+ # repo_type="dataset",
134
+ # )
135
+ # os.environ[RESET_JUDGEMENT_ENV] = "1"
136
+ # return file.name
137
+
138
  model_name_textbox = gr.Textbox(label="Model name")
139
  submitter_username = gr.Textbox(label="Username")
140
 
141
+ # def toggle_upload_button(model_name, username):
142
+ # return bool(model_name) and bool(username)
143
+ file_output = gr.File(label="Drag and drop JSON file judgment here", type="filepath")
144
+ # upload_button = gr.Button("Click to Upload & Submit Answers", elem_id="upload_button",variant='primary')
145
+ uploaded_file = gr.State()
146
+ file_path = gr.State()
147
+ out = gr.Textbox("Статус отправки")
148
+
149
+ submit_button = gr.Button("Submit File", elem_id="submit_button", variant='primary')
150
+
151
+ file_output.upload(
152
+ handle_file_upload,
153
+ file_output,
154
+ [uploaded_file, file_path]
155
+ )
156
+
157
+ submit_button.click(
158
+ submit_file,
159
+ [uploaded_file, file_path, submitter_username, model_name_textbox],
160
+ [out]
161
+ )
162
+
163
+
164
+ return demo
 
 
 
 
 
 
 
 
 
 
 
165
 
166
 
167
  # print(os.system('cd src/gen && ../../.venv/bin/python gen_judgment.py'))
 
215
  os.environ[RESET_JUDGEMENT_ENV] = "1"
216
 
217
  scheduler = BackgroundScheduler()
218
+ scheduler.add_job(update_board, "interval", minutes=2)
219
  scheduler.start()
220
 
221
  demo_app = build_demo()
data/leaderboard.json CHANGED
@@ -1 +1 @@
1
- []
 
1
+ [{"musicmc": 0.2936170212765957, "lawmc": 0.48094747682801237, "model": "apsys/saiga_3_8b", "moviesmc": 0.3402777777777778, "booksmc": 0.3112033195020747, "model_dtype": "torch.float16", "ppl": 0}, {"musicmc": 0.251063829787234, "lawmc": 0.48712667353244077, "model": "apsys/vikhr-52-7b", "moviesmc": 0.4212962962962963, "booksmc": 0.3112033195020747, "model_dtype": "torch.float16", "ppl": 0}, {"musicmc": 0.24468085106382978, "lawmc": 0.4788877445932029, "model": "apsys/vikhr-53-7b-32k", "moviesmc": 0.4050925925925926, "booksmc": 0.3049792531120332, "model_dtype": "torch.float16", "ppl": 0}]