Spaces:
Running
Running
File size: 2,058 Bytes
ed67098 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import streamlit as st
import requests
import plotly.express as px
import pandas as pd
st.set_page_config(page_title="NicheImage Studio", layout="wide")
st.markdown("## :black[Image Generation Studio by NicheImage]")
replicate_logo = "assets/NicheTensorTransparent.png"
with st.sidebar:
st.image(replicate_logo, use_column_width=True)
st.markdown(
"""
**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.**
""",
unsafe_allow_html=True,
)
response = requests.get(
"http://proxy_client_nicheimage.nichetensor.com:10003/get_uid_info"
)
if response.status_code == 200:
response = response.json()
# Plot distribution of models
model_distribution = {}
for uid, info in response["all_uid_info"].items():
model_name = info["model_name"]
model_distribution[model_name] = model_distribution.get(model_name, 0) + 1
fig = px.pie(
values=list(model_distribution.values()),
names=list(model_distribution.keys()),
title="Model Distribution",
)
st.plotly_chart(fig)
transformed_dict = []
for k, v in response["all_uid_info"].items():
transformed_dict.append(
{
"uid": k,
"model_name": v["model_name"],
"mean_score": (
sum(v["scores"]) / (len(v["scores"])) if len(v["scores"]) > 0 else 0
),
}
)
transformed_dict = pd.DataFrame(transformed_dict)
# plot N bar chart for N models, sorted by mean score
for model in model_distribution.keys():
model_data = transformed_dict[transformed_dict["model_name"] == model]
model_data = model_data.sort_values(by="mean_score", ascending=False)
if model_data.mean_score.sum() == 0:
continue
st.write(f"Model: {model}")
st.bar_chart(model_data[["uid", "mean_score"]].set_index("uid"))
else:
st.error("Error getting miner info")
|