laureBe commited on
Commit
4e58066
·
verified ·
1 Parent(s): c282179

Upload 3 files

Browse files
Files changed (3) hide show
  1. __init__.py +0 -0
  2. emissions.py +28 -0
  3. evaluation.py +18 -0
__init__.py ADDED
File without changes
emissions.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from codecarbon import EmissionsTracker
2
+ import os
3
+
4
+ # Initialize tracker
5
+ tracker = EmissionsTracker(allow_multiple_runs=True)
6
+
7
+ class EmissionsData:
8
+ def __init__(self, energy_consumed: float, emissions: float):
9
+ self.energy_consumed = energy_consumed
10
+ self.emissions = emissions
11
+
12
+ def clean_emissions_data(emissions_data):
13
+ """Remove unwanted fields from emissions data"""
14
+ data_dict = emissions_data.__dict__
15
+ fields_to_remove = ['timestamp', 'project_name', 'experiment_id', 'latitude', 'longitude']
16
+ return {k: v for k, v in data_dict.items() if k not in fields_to_remove}
17
+
18
+ def get_space_info():
19
+ """Get the space username and URL from environment variables"""
20
+ space_name = os.getenv("SPACE_ID", "")
21
+ if space_name:
22
+ try:
23
+ username = space_name.split("/")[0]
24
+ space_url = f"https://huggingface.co/spaces/{space_name}"
25
+ return username, space_url
26
+ except Exception as e:
27
+ print(f"Error getting space info: {e}")
28
+ return "local-user", "local-development"
evaluation.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional
2
+ from pydantic import BaseModel, Field
3
+
4
+ class BaseEvaluationRequest(BaseModel):
5
+ test_size: float = Field(0.2, ge=0.0, le=1.0, description="Size of the test split (between 0 and 1)")
6
+ test_seed: int = Field(42, ge=0, description="Random seed for reproducibility")
7
+
8
+ class TextEvaluationRequest(BaseEvaluationRequest):
9
+ dataset_name: str = Field("QuotaClimat/frugalaichallenge-text-train",
10
+ description="The name of the dataset on HuggingFace Hub")
11
+
12
+ class ImageEvaluationRequest(BaseEvaluationRequest):
13
+ dataset_name: str = Field("pyronear/pyro-sdis",
14
+ description="The name of the dataset on HuggingFace Hub")
15
+
16
+ class AudioEvaluationRequest(BaseEvaluationRequest):
17
+ dataset_name: str = Field("rfcx/frugalai",
18
+ description="The name of the dataset on HuggingFace Hub")