Spaces:
Running on Zero
Running on Zero
Download openmodellab/comparison/compare.py from ajaygovind/OpenModelLab: direct link, hf CLI and curl.
- Browser
- Download file 1.93 kB
-
https://huggingface.co/spaces/ajaygovind/OpenModelLab/resolve/main/openmodellab/comparison/compare.py
- Command line
-
hf download hf://spaces/ajaygovind/OpenModelLab/openmodellab/comparison/compare.py
-
curl -L -o compare.py https://huggingface.co/spaces/ajaygovind/OpenModelLab/resolve/main/openmodellab/comparison/compare.py
1.93 kB
| import json | |
| import os | |
| def load_reports(report_dir): | |
| models = {} | |
| for file in os.listdir(report_dir): | |
| path = os.path.join( | |
| report_dir, | |
| file | |
| ) | |
| if file.endswith("_genome.json"): | |
| name = file.replace( | |
| "_genome.json", | |
| "" | |
| ) | |
| models.setdefault(name, {}) | |
| with open(path, "r") as f: | |
| models[name]["genome"] = json.load(f) | |
| elif file.endswith("_benchmark.json"): | |
| name = file.replace( | |
| "_benchmark.json", | |
| "" | |
| ) | |
| models.setdefault(name, {}) | |
| with open(path, "r") as f: | |
| models[name]["benchmark"] = json.load(f) | |
| return models | |
| def generate_comparison(report_dir): | |
| reports = load_reports(report_dir) | |
| table = [] | |
| for name, data in reports.items(): | |
| genome = data.get( | |
| "genome", | |
| {} | |
| ) | |
| benchmark = data.get( | |
| "benchmark", | |
| {} | |
| ) | |
| table.append({ | |
| "model": name, | |
| "parameters": genome.get( | |
| "model", | |
| {} | |
| ).get( | |
| "parameter_count" | |
| ), | |
| "layers": genome.get( | |
| "model", | |
| {} | |
| ).get( | |
| "num_hidden_layers" | |
| ), | |
| "hidden_size": genome.get( | |
| "model", | |
| {} | |
| ).get( | |
| "hidden_size" | |
| ), | |
| "latency_ms": benchmark.get( | |
| "latency", | |
| {} | |
| ).get( | |
| "average_ms" | |
| ), | |
| "throughput": benchmark.get( | |
| "throughput", | |
| {} | |
| ).get( | |
| "samples_per_second" | |
| ) | |
| }) | |
| return table | |