toilaluan commited on
Commit
99bebe0
β€’
1 Parent(s): 22df377
__pycache__/core.cpython-310.pyc ADDED
Binary file (6.97 kB). View file
 
app.py CHANGED
@@ -1,56 +1,16 @@
1
- import streamlit as st
2
- import requests
3
- import plotly.express as px
4
- import pandas as pd
5
 
6
- st.set_page_config(page_title="NicheImage Studio", layout="wide")
7
- st.markdown("## :black[Image Generation Studio by NicheImage]")
8
- replicate_logo = "assets/NicheTensorTransparent.png"
9
 
10
- with st.sidebar:
11
- st.image(replicate_logo, use_column_width=True)
12
- st.markdown(
13
- """
14
- **NicheImage is a decentralized network of image generation models, powered by the Bittensor protocol. Below you find information about the current models on the network.**
15
- """,
16
- unsafe_allow_html=True,
 
 
 
17
  )
18
- response = requests.get(
19
- "http://proxy_client_nicheimage.nichetensor.com:10003/get_uid_info"
20
- )
21
- if response.status_code == 200:
22
- response = response.json()
23
- # Plot distribution of models
24
- model_distribution = {}
25
- for uid, info in response["all_uid_info"].items():
26
- model_name = info["model_name"]
27
- model_distribution[model_name] = model_distribution.get(model_name, 0) + 1
28
- fig = px.pie(
29
- values=list(model_distribution.values()),
30
- names=list(model_distribution.keys()),
31
- title="Model Distribution",
32
- )
33
- st.plotly_chart(fig)
34
- transformed_dict = []
35
- for k, v in response["all_uid_info"].items():
36
- transformed_dict.append(
37
- {
38
- "uid": k,
39
- "model_name": v["model_name"],
40
- "mean_score": (
41
- sum(v["scores"]) / (len(v["scores"])) if len(v["scores"]) > 0 else 0
42
- ),
43
- }
44
- )
45
- transformed_dict = pd.DataFrame(transformed_dict)
46
- # plot N bar chart for N models, sorted by mean score
47
- for model in model_distribution.keys():
48
- model_data = transformed_dict[transformed_dict["model_name"] == model]
49
- model_data = model_data.sort_values(by="mean_score", ascending=False)
50
- if model_data.mean_score.sum() == 0:
51
- continue
52
- st.write(f"Model: {model}")
53
- st.bar_chart(model_data[["uid", "mean_score"]].set_index("uid"))
54
-
55
- else:
56
- st.error("Error getting miner info")
 
1
+ from st_pages import Page, show_pages, add_page_title
 
 
 
2
 
3
+ # Optional -- adds the title and icon to the current page
4
+ add_page_title()
 
5
 
6
+ # Specify what pages should be shown in the sidebar, and what their titles and icons
7
+ # should be
8
+ show_pages(
9
+ [
10
+ Page("home.py", "Home & Statistics", "πŸ“Š"),
11
+ Page("pages/0_GoJourney.py", "GoJourney", "β›΅"),
12
+ Page("pages/1_Text_To_Image.py", "Text To Image", "🎨"),
13
+ Page("pages/2_Image_To_Image.py", "Image To Image", "πŸ–ΌοΈ"),
14
+ Page("pages/3_Control_To_Image.py", "Control To Image", "πŸŽ›οΈ"),
15
+ ]
16
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
home.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import plotly.express as px
4
+ import pandas as pd
5
+
6
+ st.set_page_config(page_title="NicheImage Studio", layout="wide")
7
+ st.markdown("## :black[Image Generation Studio by NicheImage]")
8
+ replicate_logo = "assets/NicheTensorTransparent.png"
9
+
10
+ with st.sidebar:
11
+ st.image(replicate_logo, use_column_width=True)
12
+ st.markdown(
13
+ """
14
+ **NicheImage is a decentralized network of image generation models, powered by the Bittensor protocol. Below you find information about the current models on the network.**
15
+ """,
16
+ unsafe_allow_html=True,
17
+ )
18
+ response = requests.get(
19
+ "http://proxy_client_nicheimage.nichetensor.com:10003/get_uid_info"
20
+ )
21
+ if response.status_code == 200:
22
+ response = response.json()
23
+ # Plot distribution of models
24
+ model_distribution = {}
25
+ for uid, info in response["all_uid_info"].items():
26
+ model_name = info["model_name"]
27
+ model_distribution[model_name] = model_distribution.get(model_name, 0) + 1
28
+ fig = px.pie(
29
+ values=list(model_distribution.values()),
30
+ names=list(model_distribution.keys()),
31
+ title="Model Distribution",
32
+ )
33
+ st.plotly_chart(fig)
34
+ transformed_dict = []
35
+ for k, v in response["all_uid_info"].items():
36
+ transformed_dict.append(
37
+ {
38
+ "uid": k,
39
+ "model_name": v["model_name"],
40
+ "mean_score": (
41
+ sum(v["scores"]) / (len(v["scores"])) if len(v["scores"]) > 0 else 0
42
+ ),
43
+ }
44
+ )
45
+ transformed_dict = pd.DataFrame(transformed_dict)
46
+ # plot N bar chart for N models, sorted by mean score
47
+ for model in model_distribution.keys():
48
+ model_data = transformed_dict[transformed_dict["model_name"] == model]
49
+ model_data = model_data.sort_values(by="mean_score", ascending=False)
50
+ if model_data.mean_score.sum() == 0:
51
+ continue
52
+ st.write(f"Model: {model}")
53
+ st.bar_chart(model_data[["uid", "mean_score"]].set_index("uid"))
54
+
55
+ else:
56
+ st.error("Error getting miner info")
pages/{0_β›΅_GoJourney.py β†’ 0_GoJourney.py} RENAMED
File without changes
pages/{1_🎨_Text_To_Image.py β†’ 1_Text_To_Image.py} RENAMED
File without changes
pages/{2_🎨_Image_To_Image.py β†’ 2_Image_To_Image.py} RENAMED
File without changes
pages/{3_🎨_Control_To_Image.py β†’ 3_Control_To_Image.py} RENAMED
File without changes
requirements.txt CHANGED
@@ -5,4 +5,5 @@ streamlit-image-select
5
  plotly
6
  pandas
7
  httpx
8
- aiohttp
 
 
5
  plotly
6
  pandas
7
  httpx
8
+ aiohttp
9
+ st-pages
utils/__init__.py ADDED
File without changes
utils/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (142 Bytes). View file
 
utils/__pycache__/icon.cpython-310.pyc ADDED
Binary file (541 Bytes). View file
 
utils/icon.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+
4
+ @st.cache_data
5
+ def show_icon(emoji: str):
6
+ """Shows an emoji as a Notion-style page icon.
7
+
8
+ Args:
9
+ emoji (str): name of the emoji, i.e. ":balloon:"
10
+ """
11
+
12
+ st.write(
13
+ f'<span style="font-size: 78px; line-height: 1">{emoji}</span>',
14
+ unsafe_allow_html=True,
15
+ )