File size: 3,201 Bytes
7258883
0dd8e7f
1c09022
30d5d12
fd51ff8
6234f75
0eb933f
eddabf1
a6350d7
0eb933f
72d2b05
5396a98
76edd3a
 
 
7bb4986
 
 
 
 
8fcfb0e
 
a69ed79
0cd6b27
72d2b05
 
0cd6b27
 
 
72d2b05
7bb4986
0cd6b27
 
 
45d79dc
76edd3a
b4b40bb
7bb4986
 
079d204
6df5542
 
 
7bb4986
 
 
 
 
 
 
 
 
6df5542
 
7bb4986
 
 
 
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
58
59
import os, glob
import json
from datetime import datetime, timezone
from dataclasses import dataclass
from datasets import load_dataset, Dataset
import pandas as pd
import gradio as gr
from huggingface_hub import HfApi, snapshot_download, ModelInfo, list_models
from enum import Enum

OWNER = "AIEnergyScore"
COMPUTE_SPACE = f"{OWNER}/launch-computation-example"
TOKEN = os.environ.get("DEBUG")
API = HfApi(token=TOKEN)

def add_docker_eval_with_agreement(zip_file, agreement):
    if not agreement:
        gr.Warning("You must agree to the terms before submitting your energy score data.")
        return
    
    new_fid_list = zip_file.split("/")
    new_fid = new_fid_list[-1]
    if new_fid.endswith('.zip'):
        API.upload_file(
            path_or_fileobj=zip_file,
            repo_id="AIEnergyScore/tested_proprietary_models",
            path_in_repo='submitted_models/'+new_fid,
            repo_type="dataset",
            commit_message="Adding logs via submission Space.",
            token=TOKEN
        )
        gr.Info('Uploaded logs to dataset! We will validate their validity and add them to the next version of the leaderboard.')
    else:
        gr.Info('You can only upload .zip files here!')

with gr.Blocks() as demo:
    gr.Markdown("# AI Energy Score | Submission Portal")
    gr.Markdown("### The goal of the AI Energy Score project is to develop an energy-based rating system for AI model deployment that will guide members of the community in choosing models for different tasks based on energy efficiency.")
    
    with gr.Row():
        with gr.Column():
            with gr.Accordion("Submit log files from a Docker run:", open=False):
                gr.Markdown("If you've already benchmarked your model using the [Docker file](https://github.com/huggingface/EnergyStarAI/) provided, please upload the **entire run log directory** (in .zip format) below:")
                
                agreement_checkbox = gr.Checkbox(label="I agree to the following terms:")
                agreement_text = gr.Markdown("""
                By checking the box below and submitting your energy score data, you confirm and agree to the following:
                1. **Public Data Sharing**: You consent to the public sharing of the energy performance data derived from your submission. No additional information related to this model including proprietary configurations will be disclosed.
                2. **Data Integrity**: You validate that the log files submitted are accurate, unaltered, and generated directly from testing your model as per the specified benchmarking procedures.
                3. **Model Representation**: You verify that the model tested and submitted is representative of the production-level version of the model, including its level of quantization and any other relevant characteristics impacting energy efficiency and performance.
                """)
                
                file_output = gr.File(visible=False)
                u = gr.UploadButton("Upload a zip file with logs", file_count="single")
                
                u.upload(add_docker_eval_with_agreement, [u, agreement_checkbox], file_output)

demo.launch()