Spaces:
Running
Running
page configurations
Browse files- mlip_arena/models/__init__.py +2 -3
- mlip_arena/tasks/__init__.py +7 -7
- serve/app.py +62 -2
mlip_arena/models/__init__.py
CHANGED
@@ -9,9 +9,8 @@ from huggingface_hub import PyTorchModelHubMixin
|
|
9 |
from torch import nn
|
10 |
from torch_geometric.data import Data
|
11 |
|
12 |
-
with open(
|
13 |
-
REGISTRY = yaml.
|
14 |
-
|
15 |
|
16 |
class MLIP(
|
17 |
nn.Module,
|
|
|
9 |
from torch import nn
|
10 |
from torch_geometric.data import Data
|
11 |
|
12 |
+
with open(Path(__file__).parent / "registry.yaml") as f:
|
13 |
+
REGISTRY = yaml.safe_load(f)
|
|
|
14 |
|
15 |
class MLIP(
|
16 |
nn.Module,
|
mlip_arena/tasks/__init__.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
|
3 |
import yaml
|
4 |
from huggingface_hub import HfApi, HfFileSystem, hf_hub_download
|
@@ -6,8 +7,8 @@ from huggingface_hub import HfApi, HfFileSystem, hf_hub_download
|
|
6 |
from mlip_arena.models import MLIP
|
7 |
from mlip_arena.models import REGISTRY as MODEL_REGISTRY
|
8 |
|
9 |
-
with open(
|
10 |
-
REGISTRY = yaml.
|
11 |
|
12 |
|
13 |
class Task:
|
@@ -15,11 +16,11 @@ class Task:
|
|
15 |
self.name: str = self.__class__.__name__ # display name on the leaderboard
|
16 |
|
17 |
def run_local(self, model: MLIP):
|
18 |
-
"""Run the task using the given model and return the results"""
|
19 |
raise NotImplementedError
|
20 |
|
21 |
def run_hf(self, model: MLIP):
|
22 |
-
"""Run the task using the given model and return the results"""
|
23 |
raise NotImplementedError
|
24 |
|
25 |
# Calcualte evaluation metrics and postprocessed data
|
@@ -32,12 +33,11 @@ class Task:
|
|
32 |
)
|
33 |
|
34 |
def run_nersc(self, model: MLIP):
|
35 |
-
"""Run the task using the given model and return the results"""
|
36 |
raise NotImplementedError
|
37 |
|
38 |
def get_results(self):
|
39 |
-
"""Get the results from the task"""
|
40 |
-
|
41 |
# fs = HfFileSystem()
|
42 |
# files = fs.glob(f"datasets/atomind/mlip-arena/{self.__class__.__name__}/*/*.json")
|
43 |
|
|
|
1 |
import os
|
2 |
+
from pathlib import Path
|
3 |
|
4 |
import yaml
|
5 |
from huggingface_hub import HfApi, HfFileSystem, hf_hub_download
|
|
|
7 |
from mlip_arena.models import MLIP
|
8 |
from mlip_arena.models import REGISTRY as MODEL_REGISTRY
|
9 |
|
10 |
+
with open(Path(__file__).parent / "registry.yaml") as f:
|
11 |
+
REGISTRY = yaml.safe_load(f)
|
12 |
|
13 |
|
14 |
class Task:
|
|
|
16 |
self.name: str = self.__class__.__name__ # display name on the leaderboard
|
17 |
|
18 |
def run_local(self, model: MLIP):
|
19 |
+
"""Run the task using the given model and return the results."""
|
20 |
raise NotImplementedError
|
21 |
|
22 |
def run_hf(self, model: MLIP):
|
23 |
+
"""Run the task using the given model and return the results."""
|
24 |
raise NotImplementedError
|
25 |
|
26 |
# Calcualte evaluation metrics and postprocessed data
|
|
|
33 |
)
|
34 |
|
35 |
def run_nersc(self, model: MLIP):
|
36 |
+
"""Run the task using the given model and return the results."""
|
37 |
raise NotImplementedError
|
38 |
|
39 |
def get_results(self):
|
40 |
+
"""Get the results from the task."""
|
|
|
41 |
# fs = HfFileSystem()
|
42 |
# files = fs.glob(f"datasets/atomind/mlip-arena/{self.__class__.__name__}/*/*.json")
|
43 |
|
serve/app.py
CHANGED
@@ -1,4 +1,64 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
# Assuming you have similar modules as in the example
|
4 |
+
# For demonstration, these functions will be defined here directly
|
5 |
+
def home_page():
|
6 |
+
st.title("Home Page")
|
7 |
+
st.write("Welcome to the Home Page!")
|
8 |
+
|
9 |
+
def analytics_page():
|
10 |
+
st.title("Analytics Page")
|
11 |
+
st.write("Analytics details go here.")
|
12 |
+
|
13 |
+
def settings_page():
|
14 |
+
st.title("Settings Page")
|
15 |
+
st.write("Settings details go here.")
|
16 |
+
|
17 |
+
# Mimicking the page_group utility from the example
|
18 |
+
class PageGroup:
|
19 |
+
def __init__(self, key):
|
20 |
+
self.key = key
|
21 |
+
self.pages = {}
|
22 |
+
self.default_page = None
|
23 |
+
|
24 |
+
def item(self, title, func, default=False):
|
25 |
+
self.pages[title] = func
|
26 |
+
if default:
|
27 |
+
self.default_page = title
|
28 |
+
|
29 |
+
def show(self):
|
30 |
+
# Use session state to remember the current page
|
31 |
+
if 'current_page' not in st.session_state or st.session_state.current_page not in self.pages:
|
32 |
+
st.session_state.current_page = self.default_page
|
33 |
+
|
34 |
+
# Display the current page function
|
35 |
+
self.pages[st.session_state.current_page]()
|
36 |
+
|
37 |
+
def main():
|
38 |
+
page = PageGroup("p")
|
39 |
+
|
40 |
+
with st.sidebar:
|
41 |
+
st.title("Navigation")
|
42 |
+
|
43 |
+
with st.expander("Pages", True):
|
44 |
+
for title, func in [("Home", home_page), ("Analytics", analytics_page), ("Settings", settings_page)]:
|
45 |
+
|
46 |
+
if st.button(title):
|
47 |
+
st.session_state.current_page = title
|
48 |
+
|
49 |
+
page.item("Home", home_page, default=True)
|
50 |
+
page.item("Analytics", analytics_page)
|
51 |
+
page.item("Settings", settings_page)
|
52 |
+
|
53 |
+
page.show()
|
54 |
+
|
55 |
+
if __name__ == "__main__":
|
56 |
+
# st.set_page_config(page_title="My Streamlit App", page_icon="📊", layout="wide")
|
57 |
+
st.set_page_config(
|
58 |
+
layout="wide",
|
59 |
+
page_title="MLIP Arena",
|
60 |
+
page_icon=":shark:",
|
61 |
+
# initial_sidebar_state="expanded",
|
62 |
+
menu_items=None
|
63 |
+
)
|
64 |
+
main()
|