Alley P commited on
Commit
0b85c0f
·
0 Parent(s):

add project without dataset

Browse files
.gitignore ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ╭──────────────────────────────╮
2
+ # │ AMBIENTE PYTHON │
3
+ # ╰──────────────────────────────╯
4
+ __pycache__/
5
+ .pytest_cache/
6
+ .mypy_cache/
7
+ .env
8
+ .venv/
9
+ env/
10
+ my_env/
11
+
12
+ # ╭──────────────────────────────╮
13
+ # │ ARQUIVOS DVC │
14
+ # ╰──────────────────────────────╯
15
+ .dvc/cache/
16
+ .dvc/tmp/
17
+ !.dvc/
18
+
19
+ # ╭──────────────────────────────╮
20
+ # │ DADOS IGNORADOS (RAW) │
21
+ # ╰──────────────────────────────╯
22
+ datasets/FASDD_MERGED/
23
+ datasets/FASDD_40PERCENT/
24
+ .gitattributes
25
+ # datasets/0_D-Fire/
26
+ # !datasets/*.dvc
27
+ # !datasets/.gitignore
28
+
29
+ # ╭──────────────────────────────╮
30
+ # │ SAÍDAS DO YOLO │
31
+ # ╰──────────────────────────────╯
32
+ runs/
33
+ train/
34
+ detect/
35
+
36
+ # ╭──────────────────────────────╮
37
+ # │ MODELOS PESADOS │
38
+ # ╰──────────────────────────────╯
39
+ *.pt
40
+ *.onnx
41
+ *.zip
42
+ *.tar
Readme.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Structure directories FASDD
3
+ ```
4
+ FS_DETECTION
5
+ └───data
6
+ ├───FASDD_CV
7
+ │ ├───annotations
8
+ │ │ └───YOLO_CV
9
+ │ │ └───labels
10
+ │ └───images
11
+ └───FASDD_UAV
12
+ ├───annotations
13
+ │ └───YOLO_UAV
14
+ │ └───labels
15
+ ```
16
+
17
+ ## Contagem de Arquivos por Dataset e Tipo
18
+
19
+ ### FASDD_CV
20
+ - **bothFireAndSmoke**: 20151 arquivos
21
+ - **fire**: 12550 arquivos
22
+ - **neitherFireNorSmoke**: 39199 arquivos
23
+ - **smoke**: 23414 arquivos
24
+ Total de arquivos em FASDD_CV: 95314
25
+
26
+ ### FASDD_UAV
27
+ - **bothFireAndSmoke**: 7821 arquivos
28
+ - **fire**: 210 arquivos
29
+ - **neitherFireNorSmoke**: 11986 arquivos
30
+ - **smoke**: 5080 arquivos
31
+ Total de arquivos em FASDD_UAV: 25097
32
+
33
+ # Detalhes da estrutura pra treino CV e UAV
34
+ ```
35
+ data/FASDD_MERGED/
36
+ ├── images/
37
+ │ ├── train/
38
+ │ ├── val/
39
+ │ └── test/
40
+ └── labels/
41
+ ├── train/
42
+ ├── val/
43
+ └── test/
44
+ ```
check_status.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Script para verificar se o upload está funcionando"""
3
+
4
+ import subprocess
5
+ import time
6
+ import os
7
+ from pathlib import Path
8
+
9
+ def check_processes():
10
+ """Verifica processos Python rodando"""
11
+ try:
12
+ result = subprocess.run(
13
+ ['wmic', 'process', 'where', 'name="python.exe"', 'get', 'processid,commandline'],
14
+ capture_output=True,
15
+ text=True
16
+ )
17
+
18
+ if result.returncode == 0:
19
+ lines = result.stdout.strip().split('\n')
20
+ python_processes = []
21
+ for line in lines[1:]: # Pular header
22
+ if line.strip() and 'upload' in line.lower():
23
+ python_processes.append(line.strip())
24
+
25
+ if python_processes:
26
+ print("✓ Processos de upload encontrados:")
27
+ for proc in python_processes:
28
+ print(f" {proc}")
29
+ else:
30
+ print("⚠ Nenhum processo de upload encontrado")
31
+ else:
32
+ print("✗ Erro ao verificar processos")
33
+
34
+ except Exception as e:
35
+ print(f"Erro: {e}")
36
+
37
+ def check_files():
38
+ """Verifica arquivos criados"""
39
+ files_to_check = [
40
+ 'upload_log.txt',
41
+ 'test_upload_results.txt',
42
+ 'dagshub_analysis.txt'
43
+ ]
44
+
45
+ for file_path in files_to_check:
46
+ path = Path(file_path)
47
+ if path.exists():
48
+ size = path.stat().st_size
49
+ print(f"✓ {file_path} existe ({size} bytes)")
50
+ else:
51
+ print(f"⚠ {file_path} não existe")
52
+
53
+ def main():
54
+ print("=== Verificação de status do upload ===")
55
+ print(f"Diretório atual: {os.getcwd()}")
56
+ print()
57
+
58
+ print("1. Verificando processos...")
59
+ check_processes()
60
+
61
+ print("\n2. Verificando arquivos...")
62
+ check_files()
63
+
64
+ print("\n3. Testando comando simples...")
65
+ try:
66
+ result = subprocess.run(['dagshub', '--help'], capture_output=True, text=True, timeout=5)
67
+ if result.returncode == 0:
68
+ print("✓ DagsHub CLI funciona")
69
+ else:
70
+ print("✗ DagsHub CLI não funciona")
71
+ except Exception as e:
72
+ print(f"✗ Erro ao testar DagsHub: {e}")
73
+
74
+ if __name__ == "__main__":
75
+ main()
check_upload_status.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Script para monitorar o progresso do upload"""
3
+
4
+ import time
5
+ import subprocess
6
+ import os
7
+ from pathlib import Path
8
+
9
+ def check_upload_status():
10
+ """Verifica o status do upload"""
11
+ print("Verificando status do upload...")
12
+
13
+ # Verificar se o processo está rodando
14
+ try:
15
+ result = subprocess.run(
16
+ ['tasklist', '/fi', 'imagename eq python.exe'],
17
+ capture_output=True,
18
+ text=True
19
+ )
20
+
21
+ if 'python.exe' in result.stdout:
22
+ print("✓ Processo Python está rodando")
23
+ else:
24
+ print("⚠ Nenhum processo Python encontrado")
25
+
26
+ except Exception as e:
27
+ print(f"Erro ao verificar processos: {e}")
28
+
29
+ # Verificar se há arquivos de log
30
+ log_file = Path('upload_log.txt')
31
+ if log_file.exists():
32
+ print(f"✓ Arquivo de log encontrado: {log_file.stat().st_size} bytes")
33
+
34
+ # Mostrar últimas linhas do log
35
+ with open(log_file, 'r', encoding='utf-8') as f:
36
+ lines = f.readlines()
37
+ if lines:
38
+ print("Últimas linhas do log:")
39
+ for line in lines[-10:]:
40
+ print(f" {line.strip()}")
41
+ else:
42
+ print("⚠ Arquivo de log não encontrado")
43
+
44
+ return True
45
+
46
+ if __name__ == "__main__":
47
+ check_upload_status()
fasdd_40.yaml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ path: datasets/FASDD_40PERCENT
2
+ train: images/train
3
+ val: images/val
4
+ test: images/test
5
+ nc: 2
6
+ names: ["fire", "smoke"]
pipeline/sample_dataset_subset.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ import random
4
+ from pathlib import Path
5
+ from tqdm import tqdm
6
+
7
+ def sample_split(split, input_dir, output_dir, percent):
8
+ img_dir = Path(input_dir) / "images" / split
9
+ label_dir = Path(input_dir) / "labels" / split
10
+ out_img_dir = Path(output_dir) / "images" / split
11
+ out_label_dir = Path(output_dir) / "labels" / split
12
+
13
+ out_img_dir.mkdir(parents=True, exist_ok=True)
14
+ out_label_dir.mkdir(parents=True, exist_ok=True)
15
+
16
+ images = list(img_dir.glob("*.jpg"))
17
+ sample_size = int(len(images) * percent)
18
+ selected_images = random.sample(images, sample_size)
19
+
20
+ print(f"📂 {split.upper()}: copiando {sample_size} de {len(images)} imagens...")
21
+
22
+ for img_path in tqdm(selected_images):
23
+ shutil.copy(img_path, out_img_dir / img_path.name)
24
+
25
+ label_path = label_dir / f"{img_path.stem}.txt"
26
+ out_label = out_label_dir / f"{img_path.stem}.txt"
27
+ if label_path.exists():
28
+ shutil.copy(label_path, out_label)
29
+
30
+ def sample_dataset(input_dir, output_dir, percent=0.4):
31
+ print(f"🚀 Criando subconjunto do dataset: {int(percent*100)}%")
32
+ for split in ["train", "val", "test"]:
33
+ sample_split(split, input_dir, output_dir, percent)
34
+ print("✅ Dataset copiado.")
35
+
36
+ if __name__ == "__main__":
37
+ import argparse
38
+ parser = argparse.ArgumentParser()
39
+ parser.add_argument("--input", type=str, required=True, help="Caminho do dataset original")
40
+ parser.add_argument("--output", type=str, default="datasets/FASDD_40PERCENT", help="Destino do novo subset")
41
+ parser.add_argument("--percent", type=float, default=0.4, help="Porcentagem a copiar (ex: 0.4 para 40%)")
42
+ args = parser.parse_args()
43
+
44
+ sample_dataset(args.input, args.output, args.percent)
pipeline/upload_to_dagshub.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ from pathlib import Path
4
+ from dotenv import load_dotenv
5
+ import requests
6
+
7
+ # Carrega o token do .env
8
+ load_dotenv(dotenv_path=Path(__file__).resolve().parent.parent / ".env")
9
+ DAGSHUB_TOKEN = os.getenv("DAGSHUB_TOKEN")
10
+ USERNAME = "All3yp"
11
+ REPO = "FS_DETECTION"
12
+ REPO_PATH = f"{USERNAME}/{REPO}"
13
+
14
+ if not DAGSHUB_TOKEN:
15
+ raise ValueError("❌ DAGSHUB_TOKEN não encontrado no .env")
16
+
17
+ def testar_conexao_dagshub(username, repo, token):
18
+ print("🔐 Testando autenticação com DagsHub...")
19
+ url = f"https://dagshub.com/api/v1/repos/{username}/{repo}"
20
+ response = requests.get(url, auth=(username, token))
21
+ if response.status_code == 200:
22
+ print("✅ Conexão com DagsHub OK")
23
+ return True
24
+ print(f"❌ Falha na autenticação ({response.status_code}): {response.text}")
25
+ return False
26
+
27
+ def install_dagshub_client():
28
+ print("🔧 Verificando cliente DagsHub...")
29
+ try:
30
+ subprocess.run(["dagshub", "--help"], capture_output=True, text=True, check=True)
31
+ except (FileNotFoundError, subprocess.CalledProcessError):
32
+ print("📦 Instalando cliente DagsHub...")
33
+ subprocess.run(["pip", "install", "dagshub", "--upgrade"], check=True)
34
+
35
+ def login_dagshub():
36
+ print("🔐 Realizando login automático no DagsHub via token...")
37
+ try:
38
+ subprocess.run(["dagshub", "login", "--token", DAGSHUB_TOKEN], check=True)
39
+ print("✅ Login realizado com sucesso")
40
+ except subprocess.CalledProcessError as e:
41
+ print(f"⚠️ Aviso durante login: {e.stderr}")
42
+
43
+ def upload_datasets():
44
+ print("📤 Enviando datasets para o bucket do DagsHub...")
45
+
46
+ datasets_to_upload = [
47
+ "datasets/FASDD_40PERCENT"
48
+ ]
49
+
50
+ for dataset_path in datasets_to_upload:
51
+ path_obj = Path(dataset_path)
52
+ if not path_obj.exists():
53
+ print(f"⚠️ Dataset não encontrado: {dataset_path}, pulando...")
54
+ continue
55
+
56
+ print(f"📁 Upload: {dataset_path}")
57
+ try:
58
+ subprocess.run([
59
+ "dagshub", "upload",
60
+ REPO_PATH,
61
+ dataset_path,
62
+ f"data/{path_obj.name}/",
63
+ "--bucket", "--update", "-v"
64
+ ], check=True)
65
+ print(f"✅ Upload concluído: {dataset_path}")
66
+ except subprocess.CalledProcessError as e:
67
+ print(f"❌ Erro no upload de {dataset_path}: {e.stderr}")
68
+
69
+ if __name__ == "__main__":
70
+ print("🚀 Iniciando upload para o bucket DagsHub...")
71
+
72
+ if not testar_conexao_dagshub(USERNAME, REPO, DAGSHUB_TOKEN):
73
+ raise SystemExit("⛔ Token inválido ou repositório inacessível.")
74
+
75
+ try:
76
+ install_dagshub_client()
77
+ login_dagshub()
78
+ upload_datasets()
79
+ print("✅ Upload finalizado com sucesso!")
80
+ except Exception as e:
81
+ print(f"❌ Erro durante o processo: {e}")
82
+ raise
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ ultralytics>=8.0.0
2
+ scikit-learn
3
+ opencv-python
4
+ python-dotenv
5
+ dvc
6
+ dagshub