Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import matplotlib.pyplot as plt | |
| import networkx as nx | |
| 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") | |
| st.markdown("<h2 style='text-align: center;'>FL com Flower </h2>", unsafe_allow_html=True) | |
| st.sidebar.image("images/logo_inmetro.jpg", width=200) | |
| st.sidebar.title("FL Inmetro") | |
| secao = st.sidebar.radio("Ir para:", ["🏠 Início", "📚 Artigos", "ℹ️ Sobre"]) | |
| if secao == "🏠 Início": | |
| intro, agregamentos, clients_server,FL,sainda, integracao_rpi = st.tabs(['Introducão', 'Métodos de Agregação', | |
| 'Criando o Cliente e Servidor', 'Modelo', 'Saida', 'Integração com RPI']) | |
| with intro: | |
| st.title("Aprendizado Federado") | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| # Introdução | |
| st.markdown(""" | |
| Este projeto explora o aprendizado federado utilizando o **Flower**. | |
| Os principais passos incluem: | |
| - Criar código básico de FL com Flower | |
| - Configurar clientes e servidor | |
| - Testar na base CIFAR-10 | |
| """) | |
| with col2: | |
| # Criando um fluxograma do processo | |
| st.markdown(""" | |
| 1. **Aprender FL com Flower**: Estudo e configuração inicial. | |
| 2. **Criar Clientes e Servidor**: Implementação prática do FL. | |
| 3. **Testar na base CIFAR-10**: Avaliação do modelo treinado. | |
| 4. **Analisar Resultados**: Verificação do desempenho do modelo. | |
| """) | |
| with agregamentos: | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| st.subheader( | |
| """ | |
| Federated Averaging (FedAvg) | |
| """ | |
| ) | |
| st.image("./images/fedavg.png") | |
| st.markdown("[McMaham et al. 2023. Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/pdf/1602.05629)") | |
| st.markdown(""" | |
| - Normalmente, a taxa de convergência do FEDAVG piora com a heterogeneidade do cliente. | |
| - | |
| """) | |
| with col2: | |
| st.subheader("FedAdagrad, FedYogi, FedAdam") | |
| st.image('./images/FedAdaGrad-Yogi-Adam.png') | |
| st.markdown("[Reddi et al. DAPTIVE FEDERATED OPTIMIZATION](https://arxiv.org/pdf/2003.00295)") | |
| with clients_server: | |
| st.subheader("1. Criar Código de FL com Flower") | |
| st.code(""" | |
| import flwr as fl | |
| import tensorflow as tf | |
| # Definição do modelo e cliente FLwr | |
| class Client(fl.client.NumPyClient): | |
| def get_parameters(self, config): | |
| return model.get_weights() | |
| def fit(self, parameters, config): | |
| model.set_weights(parameters) | |
| model.fit(X_train, y_train, epochs=1) | |
| return model.get_weights(), len(X_train), {} | |
| fl.client.start_numpy_client(server_address="127.0.0.1:8080", client=Client()) | |
| """, language='python') | |
| st.subheader("2. Criar e Gerenciar Clientes e Servidor") | |
| st.code(""" | |
| # Servidor FLwr | |
| import flwr as fl | |
| fl.server.start_server(config=fl.server.ServerConfig(num_rounds=3)) | |
| """, language='python') | |
| st.subheader("3. Testar na Base CIFAR-10") | |
| st.markdown("Carregando e treinando modelo na base CIFAR-10...") | |
| if secao == "ℹ️ Sobre": | |
| st.markdown( | |
| """ | |
| Este é um projeto para previsão de demanda de combustível utilizando aprendizado federado. | |
| Integrantes: | |
| - João | |
| - Erick | |
| - José Wilson | |
| """ | |
| ) | |
| if secao == "📚 Artigos": | |
| st.markdown( | |
| """ | |
| ### Referências | |
| - FedAVG | |
| [McMaham et al. 2023. Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/pdf/1602.05629) | |
| - ADAGRAD, ADAM, YOGI | |
| [Reddi et al. DAPTIVE FEDERATED OPTIMIZATION](https://arxiv.org/pdf/2003.00295) | |
| """ | |
| ) | |