Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CPU validation

on:
push:
branches: [main, agent/schema-2-diversity-refactor]
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: cpu-validation-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip

- name: Install project and test dependencies
run: |
python -m pip install --upgrade pip
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
python -m pip install --editable ".[test]"

- name: Run deterministic test suite
run: |
python -m pytest -q tests -m "not gpu" \
--cov=biasauditfw \
--cov-report=term-missing \
--cov-report=xml

- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-python-3.12
path: coverage.xml
if-no-files-found: error
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,7 @@ __marimo__/

# Local PDF review renders
Texto_Latex/.preview/

# Local Colab CLI execution artifacts and credentials
execucao/colab/
.colab-cli/
106 changes: 67 additions & 39 deletions Framework_Auditoria_Viés_IA_Generativa.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "83776683",
"id": "d2e70da5cf87",
"metadata": {},
"source": [
"# BiasAuditFW 2.0 — notebook oficial para Google Colab T4\n",
Expand All @@ -20,7 +20,7 @@
},
{
"cell_type": "markdown",
"id": "bbc9085f",
"id": "1ca43532b6e5",
"metadata": {},
"source": [
"## 1. Preparação\n",
Expand All @@ -33,16 +33,19 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a7af3e4d",
"id": "3f89a0bb8250",
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import os\n",
"import subprocess\n",
"import sys\n",
"\n",
"REPOSITORY_URL = \"https://github.com/Kauandugi/bias-audit-framework.git\"\n",
"REPOSITORY_REF = \"agent/schema-2-diversity-refactor\"\n",
"REPOSITORY_REF = os.getenv(\n",
" \"BIASAUDIT_REPOSITORY_REF\", \"agent/schema-2-diversity-refactor\"\n",
")\n",
"REPO_DIR = Path(\"/content/bias-audit-framework\")\n",
"\n",
"if REPO_DIR.exists() and not (REPO_DIR / \".git\").is_dir():\n",
Expand Down Expand Up @@ -100,7 +103,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "510db36a",
"id": "d19bb8a58de0",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -111,7 +114,7 @@
},
{
"cell_type": "markdown",
"id": "46c5d394",
"id": "b532ba955966",
"metadata": {},
"source": [
"## 2. Configuração da execução\n",
Expand All @@ -124,26 +127,51 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6d09a7ca",
"id": "6addcac4205b",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from pathlib import Path\n",
"\n",
"DATASET_ROOT = Path(\"/content/drive/MyDrive/Estudo UNAL/Images Generated by IA\")\n",
"OUTPUT_ROOT = Path(\"/content/drive/MyDrive/Estudo UNAL/BiasAuditFW outputs schema 2\")\n",
"\n",
"def env_flag(name: str, default: bool = False) -> bool:\n",
" value = os.getenv(name)\n",
" if value is None:\n",
" return default\n",
" return value.strip().lower() in {\"1\", \"true\", \"yes\", \"on\"}\n",
"\n",
"DATASET_ROOT = Path(\n",
" os.getenv(\n",
" \"BIASAUDIT_DATASET_ROOT\",\n",
" \"/content/drive/MyDrive/Estudo UNAL/Images Generated by IA\",\n",
" )\n",
")\n",
"OUTPUT_ROOT = Path(\n",
" os.getenv(\n",
" \"BIASAUDIT_OUTPUT_ROOT\",\n",
" \"/content/drive/MyDrive/Estudo UNAL/BiasAuditFW outputs schema 2\",\n",
" )\n",
")\n",
"DATASET_ID = \"original-64\"\n",
"MANIFEST_PATH = REPO_DIR / \"data\" / \"original_64_manifest.csv\"\n",
"EXPECTED_IMAGES = 64\n",
"\n",
"RUN_FULL = False\n",
"RUN_GROUND_TRUTH = False\n",
"RUN_HUMAN_BASELINE = False\n",
"RUN_FAIRFACE = False\n",
"DOWNLOAD_FAIRFACE_WEIGHTS = False\n",
"RUN_FULL = env_flag(\"BIASAUDIT_RUN_FULL\")\n",
"RUN_GROUND_TRUTH = env_flag(\"BIASAUDIT_RUN_GROUND_TRUTH\")\n",
"RUN_HUMAN_BASELINE = env_flag(\"BIASAUDIT_RUN_HUMAN_BASELINE\")\n",
"RUN_FAIRFACE = env_flag(\"BIASAUDIT_RUN_FAIRFACE\")\n",
"DOWNLOAD_FAIRFACE_WEIGHTS = env_flag(\"BIASAUDIT_DOWNLOAD_FAIRFACE_WEIGHTS\")\n",
"\n",
"GROUND_TRUTH_COCO = Path(\"/content/drive/MyDrive/Estudo UNAL/ground_truth_consenso.json\")\n",
"FAIRFACE_WEIGHTS = Path(\"/content/fairface_alldata_20191111.pt\")\n",
"GROUND_TRUTH_COCO = Path(\n",
" os.getenv(\n",
" \"BIASAUDIT_GROUND_TRUTH_COCO\",\n",
" \"/content/drive/MyDrive/Estudo UNAL/ground_truth_consenso.json\",\n",
" )\n",
")\n",
"FAIRFACE_WEIGHTS = Path(\n",
" os.getenv(\"BIASAUDIT_FAIRFACE_WEIGHTS\", \"/content/fairface_alldata_20191111.pt\")\n",
")\n",
"HUMAN_BASELINE_URL = (\n",
" \"https://raw.githubusercontent.com/Kauandugi/\"\n",
" \"Bias-ai-university-visuals/main/data/metadada/\"\n",
Expand All @@ -154,7 +182,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "23ea24d1",
"id": "f3f04f228cf3",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -187,7 +215,7 @@
},
{
"cell_type": "markdown",
"id": "a36e309b",
"id": "b8d568b5420a",
"metadata": {},
"source": [
"## 3. Preflight de ingestão\n",
Expand All @@ -200,7 +228,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "edc05fc7",
"id": "0f1007864400",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -215,7 +243,7 @@
},
{
"cell_type": "markdown",
"id": "98f74bad",
"id": "927db5f91750",
"metadata": {},
"source": [
"## 4. Testes determinísticos\n",
Expand All @@ -227,7 +255,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "61f348c9",
"id": "898d25313da2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -250,7 +278,7 @@
},
{
"cell_type": "markdown",
"id": "8210cfba",
"id": "edbb51d8b675",
"metadata": {},
"source": [
"## 5. Carregamento único dos modelos\n",
Expand All @@ -263,7 +291,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5810e4ee",
"id": "0c0204f5988f",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -286,7 +314,7 @@
},
{
"cell_type": "markdown",
"id": "c16e1de5",
"id": "1d3b5dfe776f",
"metadata": {},
"source": [
"## 6. Smoke test ou corpus completo\n",
Expand All @@ -298,7 +326,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "21b1fc25",
"id": "b9195c788e2a",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -363,7 +391,7 @@
},
{
"cell_type": "markdown",
"id": "81256a42",
"id": "25a3ea5a01e9",
"metadata": {},
"source": [
"## 7. Estatística no nível da imagem\n",
Expand All @@ -376,7 +404,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c7a98d52",
"id": "d777fe6d633d",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -395,7 +423,7 @@
},
{
"cell_type": "markdown",
"id": "a3a24004",
"id": "644f5744bca0",
"metadata": {},
"source": [
"## 8. Gráficos exploratórios"
Expand All @@ -404,7 +432,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "28571d07",
"id": "bb4c2ec4a5b3",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -448,7 +476,7 @@
},
{
"cell_type": "markdown",
"id": "561a14aa",
"id": "2395ddc88640",
"metadata": {},
"source": [
"## 9. Ground Truth da detecção facial\n",
Expand All @@ -461,7 +489,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0496b012",
"id": "cfc7a6c0cf18",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -491,7 +519,7 @@
},
{
"cell_type": "markdown",
"id": "16a8f822",
"id": "1369f0899375",
"metadata": {},
"source": [
"## 10. Baseline humana\n",
Expand All @@ -504,7 +532,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b852577b",
"id": "d69a60bc8410",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -529,7 +557,7 @@
},
{
"cell_type": "markdown",
"id": "b8f2e956",
"id": "e0b7b84bc5a0",
"metadata": {},
"source": [
"## 11. FairFace como pseudo-oráculo\n",
Expand All @@ -541,7 +569,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d462f231",
"id": "f11107867cc6",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -589,7 +617,7 @@
},
{
"cell_type": "markdown",
"id": "323036e8",
"id": "5423b9dfda8d",
"metadata": {},
"source": [
"## 12. Validação independente dos outputs\n",
Expand All @@ -601,7 +629,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "637fe862",
"id": "d7046b1e31d4",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -621,7 +649,7 @@
},
{
"cell_type": "markdown",
"id": "cda43b96",
"id": "7dd45e520f55",
"metadata": {},
"source": [
"## Checklist final\n",
Expand Down Expand Up @@ -654,4 +682,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Loading
Loading