Spaces:
Sleeping
Sleeping
Commit
·
a61e83a
1
Parent(s):
c27b8a4
pass token around
Browse files
app.py
CHANGED
@@ -37,7 +37,7 @@ BENCHMARKS_REPO_ID = "optimum-benchmark/OpenVINO-Benchmarks"
|
|
37 |
TASKS = set(TASKS_TO_OVMODEL.keys()) & set(TASKS_TO_MODEL_LOADERS.keys())
|
38 |
|
39 |
|
40 |
-
def parse_configs(inputs):
|
41 |
configs = {"process": {}, "inference": {}, "pytorch": {}, "openvino": {}}
|
42 |
|
43 |
for key, value in inputs.items():
|
@@ -59,10 +59,18 @@ def parse_configs(inputs):
|
|
59 |
configs["process"] = ProcessConfig(**configs.pop("process"))
|
60 |
configs["inference"] = InferenceConfig(**configs.pop("inference"))
|
61 |
configs["pytorch"] = PyTorchConfig(
|
62 |
-
task=task,
|
|
|
|
|
|
|
|
|
63 |
)
|
64 |
configs["openvino"] = OVConfig(
|
65 |
-
task=task,
|
|
|
|
|
|
|
|
|
66 |
)
|
67 |
|
68 |
return configs
|
@@ -79,8 +87,8 @@ def run_benchmark(inputs, oauth_token: Optional[gr.OAuthToken]):
|
|
79 |
gr.Info(f"📩 Benchmark will be saved under {BENCHMARKS_REPO_ID}/{folder}")
|
80 |
|
81 |
outputs = {backend: "Running..." for backend in BACKENDS}
|
|
|
82 |
yield tuple(outputs[b] for b in BACKENDS)
|
83 |
-
configs = parse_configs(inputs)
|
84 |
|
85 |
for backend in BACKENDS:
|
86 |
try:
|
@@ -93,6 +101,9 @@ def run_benchmark(inputs, oauth_token: Optional[gr.OAuthToken]):
|
|
93 |
)
|
94 |
benchmark_report = Benchmark.launch(benchmark_config)
|
95 |
|
|
|
|
|
|
|
96 |
benchmark_config.push_to_hub(
|
97 |
repo_id=BENCHMARKS_REPO_ID,
|
98 |
subfolder=benchmark_name,
|
|
|
37 |
TASKS = set(TASKS_TO_OVMODEL.keys()) & set(TASKS_TO_MODEL_LOADERS.keys())
|
38 |
|
39 |
|
40 |
+
def parse_configs(inputs, token: str):
|
41 |
configs = {"process": {}, "inference": {}, "pytorch": {}, "openvino": {}}
|
42 |
|
43 |
for key, value in inputs.items():
|
|
|
59 |
configs["process"] = ProcessConfig(**configs.pop("process"))
|
60 |
configs["inference"] = InferenceConfig(**configs.pop("inference"))
|
61 |
configs["pytorch"] = PyTorchConfig(
|
62 |
+
task=task,
|
63 |
+
model=model,
|
64 |
+
device=DEVICE,
|
65 |
+
**configs["pytorch"],
|
66 |
+
model_kwargs={"token": token},
|
67 |
)
|
68 |
configs["openvino"] = OVConfig(
|
69 |
+
task=task,
|
70 |
+
model=model,
|
71 |
+
device=DEVICE,
|
72 |
+
**configs["openvino"],
|
73 |
+
model_kwargs={"token": token},
|
74 |
)
|
75 |
|
76 |
return configs
|
|
|
87 |
gr.Info(f"📩 Benchmark will be saved under {BENCHMARKS_REPO_ID}/{folder}")
|
88 |
|
89 |
outputs = {backend: "Running..." for backend in BACKENDS}
|
90 |
+
configs = parse_configs(inputs, token=oauth_token.token)
|
91 |
yield tuple(outputs[b] for b in BACKENDS)
|
|
|
92 |
|
93 |
for backend in BACKENDS:
|
94 |
try:
|
|
|
101 |
)
|
102 |
benchmark_report = Benchmark.launch(benchmark_config)
|
103 |
|
104 |
+
# make sure the token is never pushed to the hub
|
105 |
+
del benchmark_config.backend.model_kwargs["token"]
|
106 |
+
|
107 |
benchmark_config.push_to_hub(
|
108 |
repo_id=BENCHMARKS_REPO_ID,
|
109 |
subfolder=benchmark_name,
|