Initial commit
Browse files
app.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
import subprocess
|
3 |
+
import sys
|
4 |
+
from datetime import datetime
|
5 |
+
from importlib import import_module
|
6 |
+
from pathlib import Path
|
7 |
+
|
8 |
+
import gradio as gr
|
9 |
+
import pandas as pd
|
10 |
+
|
11 |
+
if Path("optimum-intel").is_dir():
|
12 |
+
subprocess.run(["git", "pull"], cwd="optimum-intel")
|
13 |
+
else:
|
14 |
+
subprocess.run(["git", "clone", "https://github.com/huggingface/optimum-intel.git"])
|
15 |
+
test_path = Path(".") / "optimum-intel" / "tests" / "openvino"
|
16 |
+
sys.path.append(str(test_path))
|
17 |
+
|
18 |
+
from test_modeling import *
|
19 |
+
from test_stable_diffusion import *
|
20 |
+
|
21 |
+
|
22 |
+
def generate_model_list():
|
23 |
+
tests = []
|
24 |
+
d = {}
|
25 |
+
for item in globals().copy():
|
26 |
+
match = re.match("(OVModelFor.*IntegrationTest)", item) or re.match("(OV.*PipelineTest)", item)
|
27 |
+
if match:
|
28 |
+
tests.append(match.group(1))
|
29 |
+
|
30 |
+
for test in tests:
|
31 |
+
task = test.replace("IntegrationTest", "").replace("Test", "")
|
32 |
+
if "OVModelFor" in task:
|
33 |
+
cls = getattr(import_module("test_modeling"), test)
|
34 |
+
else:
|
35 |
+
cls = getattr(import_module("test_stable_diffusion"), test)
|
36 |
+
try:
|
37 |
+
print(cls.SUPPORTED_ARCHITECTURES)
|
38 |
+
d[task] = cls.SUPPORTED_ARCHITECTURES
|
39 |
+
except AttributeError:
|
40 |
+
print(cls.SUPPORTED_ARCHITECTURES_WITH_HIDDEN_STATES)
|
41 |
+
print(cls.SUPPORTED_ARCHITECTURES_WITH_ATTENTION)
|
42 |
+
d[task] = cls.SUPPORTED_ARCHITECTURES_WITH_ATTENTION + cls.SUPPORTED_ARCHITECTURES_WITH_HIDDEN_STATES
|
43 |
+
|
44 |
+
with open("supported_models.md", "w") as f:
|
45 |
+
f.write(f"Updated at {datetime.now().strftime('%d %B %Y')}\n\n")
|
46 |
+
|
47 |
+
summary = []
|
48 |
+
all_archs = []
|
49 |
+
for archs in d.values():
|
50 |
+
all_archs += archs
|
51 |
+
for title, supported_models in d.items():
|
52 |
+
f.write(f"## {title}\n\n")
|
53 |
+
for item in supported_models:
|
54 |
+
f.write(f" - {item}\n")
|
55 |
+
f.write("\n")
|
56 |
+
summary.append((title, len(supported_models)))
|
57 |
+
md_summary = pd.DataFrame.from_records(summary, columns=["task", "number of architectures"]).to_markdown()
|
58 |
+
f.write("# Summary\n\n")
|
59 |
+
f.write(md_summary)
|
60 |
+
f.write("\n\n")
|
61 |
+
num_total_archs = len(set(all_archs))
|
62 |
+
f.write(f"Total unique architectures: {num_total_archs}\n\n")
|
63 |
+
f.write(f"Total validated architecture/task combinations: {len(all_archs)}\n\n")
|
64 |
+
|
65 |
+
return Path("supported_models.md").read_text()
|
66 |
+
|
67 |
+
|
68 |
+
demo = gr.Interface(
|
69 |
+
fn=generate_model_list,
|
70 |
+
title="List of validated architectures for optimum[openvino]",
|
71 |
+
inputs=[],
|
72 |
+
outputs=[gr.Markdown()],
|
73 |
+
allow_flagging=False,
|
74 |
+
)
|
75 |
+
demo.launch(server_name="0.0.0.0")
|