Spaces:
Sleeping
Sleeping
Delete project_stages.py
Browse files- project_stages.py +0 -116
project_stages.py
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import matplotlib.pyplot as plt
|
3 |
-
import networkx as nx
|
4 |
-
|
5 |
-
|
6 |
-
st.set_page_config(page_title="APRENDIZADO FEDERADO PARA PREVISÃO DE DEMANDA ENERGÉTICA", page_icon=":bar_chart:", layout="wide", initial_sidebar_state="auto")
|
7 |
-
|
8 |
-
st.markdown("<h2 style='text-align: center;'>FL com Flower </h2>", unsafe_allow_html=True)
|
9 |
-
st.sidebar.image("images/logo_inmetro.jpg", width=200)
|
10 |
-
st.sidebar.title("FL Inmetro")
|
11 |
-
|
12 |
-
secao = st.sidebar.radio("Ir para:", ["🏠 Início", "📚 Artigos", "ℹ️ Sobre"])
|
13 |
-
|
14 |
-
if secao == "🏠 Início":
|
15 |
-
|
16 |
-
intro, agregamentos, clients_server,FL,sainda, integracao_rpi = st.tabs(['Introducão', 'Métodos de Agregação',
|
17 |
-
'Criando o Cliente e Servidor', 'Modelo', 'Saida', 'Integração com RPI'])
|
18 |
-
|
19 |
-
with intro:
|
20 |
-
|
21 |
-
st.title("Aprendizado Federado")
|
22 |
-
|
23 |
-
col1, col2 = st.columns(2)
|
24 |
-
|
25 |
-
with col1:
|
26 |
-
# Introdução
|
27 |
-
|
28 |
-
st.markdown("""
|
29 |
-
Este projeto explora o aprendizado federado utilizando o **Flower**.
|
30 |
-
Os principais passos incluem:
|
31 |
-
- Criar código básico de FL com Flower
|
32 |
-
- Configurar clientes e servidor
|
33 |
-
- Testar na base CIFAR-10
|
34 |
-
""")
|
35 |
-
|
36 |
-
with col2:
|
37 |
-
# Criando um fluxograma do processo
|
38 |
-
st.markdown("""
|
39 |
-
1. **Aprender FL com Flower**: Estudo e configuração inicial.
|
40 |
-
2. **Criar Clientes e Servidor**: Implementação prática do FL.
|
41 |
-
3. **Testar na base CIFAR-10**: Avaliação do modelo treinado.
|
42 |
-
4. **Analisar Resultados**: Verificação do desempenho do modelo.
|
43 |
-
""")
|
44 |
-
with agregamentos:
|
45 |
-
col1, col2 = st.columns(2)
|
46 |
-
with col1:
|
47 |
-
st.subheader(
|
48 |
-
"""
|
49 |
-
Federated Averaging (FedAvg)
|
50 |
-
"""
|
51 |
-
)
|
52 |
-
st.image("./images/fedavg.png")
|
53 |
-
st.markdown("[McMaham et al. 2023. Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/pdf/1602.05629)")
|
54 |
-
|
55 |
-
st.markdown("""
|
56 |
-
- Normalmente, a taxa de convergência do FEDAVG piora com a heterogeneidade do cliente.
|
57 |
-
-
|
58 |
-
""")
|
59 |
-
with col2:
|
60 |
-
st.subheader("FedAdagrad, FedYogi, FedAdam")
|
61 |
-
st.image('./images/FedAdaGrad-Yogi-Adam.png')
|
62 |
-
st.markdown("[Reddi et al. DAPTIVE FEDERATED OPTIMIZATION](https://arxiv.org/pdf/2003.00295)")
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
with clients_server:
|
67 |
-
st.subheader("1. Criar Código de FL com Flower")
|
68 |
-
st.code("""
|
69 |
-
import flwr as fl
|
70 |
-
import tensorflow as tf
|
71 |
-
|
72 |
-
# Definição do modelo e cliente FLwr
|
73 |
-
class Client(fl.client.NumPyClient):
|
74 |
-
def get_parameters(self, config):
|
75 |
-
return model.get_weights()
|
76 |
-
def fit(self, parameters, config):
|
77 |
-
model.set_weights(parameters)
|
78 |
-
model.fit(X_train, y_train, epochs=1)
|
79 |
-
return model.get_weights(), len(X_train), {}
|
80 |
-
|
81 |
-
fl.client.start_numpy_client(server_address="127.0.0.1:8080", client=Client())
|
82 |
-
""", language='python')
|
83 |
-
|
84 |
-
st.subheader("2. Criar e Gerenciar Clientes e Servidor")
|
85 |
-
st.code("""
|
86 |
-
# Servidor FLwr
|
87 |
-
import flwr as fl
|
88 |
-
fl.server.start_server(config=fl.server.ServerConfig(num_rounds=3))
|
89 |
-
""", language='python')
|
90 |
-
|
91 |
-
st.subheader("3. Testar na Base CIFAR-10")
|
92 |
-
st.markdown("Carregando e treinando modelo na base CIFAR-10...")
|
93 |
-
|
94 |
-
if secao == "ℹ️ Sobre":
|
95 |
-
st.markdown(
|
96 |
-
"""
|
97 |
-
Este é um projeto para previsão de demanda de combustível utilizando aprendizado federado.
|
98 |
-
Integrantes:
|
99 |
-
- João
|
100 |
-
- Erick
|
101 |
-
- José Wilson
|
102 |
-
"""
|
103 |
-
)
|
104 |
-
if secao == "📚 Artigos":
|
105 |
-
st.markdown(
|
106 |
-
"""
|
107 |
-
### Referências
|
108 |
-
- FedAVG
|
109 |
-
|
110 |
-
[McMaham et al. 2023. Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/pdf/1602.05629)
|
111 |
-
|
112 |
-
- ADAGRAD, ADAM, YOGI
|
113 |
-
|
114 |
-
[Reddi et al. DAPTIVE FEDERATED OPTIMIZATION](https://arxiv.org/pdf/2003.00295)
|
115 |
-
"""
|
116 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|