Spaces:
Runtime error
Runtime error
Update app.py
Browse filesupdating from json to pkl
app.py
CHANGED
@@ -18,22 +18,8 @@ import pandas as pd
|
|
18 |
import plotly.express as px
|
19 |
import numpy as np
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
models= [k.split('/')[1] for k in carbondict.keys()]
|
25 |
-
carbon = [v[1] for v in carbondict.values()]
|
26 |
-
carbon = [4009.5 if x== '4' else x for x in carbon]
|
27 |
-
tasks = [v[0] for v in carbondict.values()]
|
28 |
-
tasks = ["other" if len(x) < 2 else x for x in tasks]
|
29 |
-
|
30 |
-
carbon_df = pd.DataFrame(
|
31 |
-
{'name': models,
|
32 |
-
'task': tasks,
|
33 |
-
'carbon': carbon
|
34 |
-
})
|
35 |
-
|
36 |
-
carbon_df.drop(carbon_df.loc[carbon_df['task']=='other'].index, inplace=True)
|
37 |
|
38 |
st.set_page_config(
|
39 |
page_title="Comparing the Carbon Footprint of Transformers",
|
@@ -43,16 +29,22 @@ st.set_page_config(
|
|
43 |
|
44 |
st.title("Hugging Face Carbon Compare Tool")
|
45 |
|
46 |
-
|
47 |
# Get the sidebar details
|
48 |
with st.sidebar.expander("Models", expanded=True):
|
49 |
st.image('./hf-earth.png')
|
50 |
# choose a dataset to analyze
|
|
|
51 |
model_name = st.selectbox(
|
52 |
f"Choose model to explore:",
|
53 |
models)
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
18 |
import plotly.express as px
|
19 |
import numpy as np
|
20 |
|
21 |
+
carbon_df= pd.read_pickle('./data/carbon_df.pkl')
|
22 |
+
carbon_df.drop(carbon_df.loc[carbon_df['task']==''].index, inplace=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
st.set_page_config(
|
25 |
page_title="Comparing the Carbon Footprint of Transformers",
|
|
|
29 |
|
30 |
st.title("Hugging Face Carbon Compare Tool")
|
31 |
|
|
|
32 |
# Get the sidebar details
|
33 |
with st.sidebar.expander("Models", expanded=True):
|
34 |
st.image('./hf-earth.png')
|
35 |
# choose a dataset to analyze
|
36 |
+
models= [m.split('/')[1].replace('autonlp-','') for m in carbon_df['name']]
|
37 |
model_name = st.selectbox(
|
38 |
f"Choose model to explore:",
|
39 |
models)
|
40 |
|
41 |
+
with st.expander("Model Comparison", expanded=False):
|
42 |
+
|
43 |
+
st.markdown("### Here is how the model " + model_name + " compares to other models:")
|
44 |
+
fig_model = px.bar(carbon_df.sort_values(by=['carbon']), x=models, y='carbon', hover_name= models, color_discrete_map = {model_name : 'red'})
|
45 |
+
st.plotly_chart(fig_model, use_container_width=True)
|
46 |
|
47 |
+
with st.expander("Task Comparison", expanded=False):
|
48 |
+
fig = px.box(carbon_df, x=carbon_df['task'], y=carbon_df['carbon'], color='task', hover_name=carbon_df['name'])
|
49 |
+
#fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default
|
50 |
+
st.plotly_chart(fig, use_container_width=True)
|