Refactoring some stuff
Browse files
main.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
import os
|
| 2 |
import shutil
|
| 3 |
-
import joblib
|
| 4 |
-
import numpy as np
|
| 5 |
from fastapi import FastAPI, File, UploadFile, Depends, HTTPException, status
|
| 6 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 7 |
-
from feature_extractor_single import process_single_image
|
| 8 |
|
| 9 |
#1. CONFIGURAÇÃO DA APLICAÇÃO E AUTENTICAÇÃO
|
| 10 |
app = FastAPI(title="SojaClassifierAPI")
|
|
@@ -60,14 +60,14 @@ async def classify_image(file: UploadFile = File(...), token: str = Depends(veri
|
|
| 60 |
|
| 61 |
try:
|
| 62 |
#Extrai Features (ConvNext - 1536 dimensões)
|
| 63 |
-
#(process_single_image vem do
|
| 64 |
features_array = process_single_image(temp_path)
|
| 65 |
|
| 66 |
-
#Prepara o vetor para
|
| 67 |
#O sklearn espera um array 2D (1, 1536) e não (1536,)
|
| 68 |
nova_feature = features_array.reshape(1, -1)
|
| 69 |
|
| 70 |
-
#Executa o
|
| 71 |
#Normaliza a nova feature com o mesmo scaler usado no treino
|
| 72 |
nova_feature_scaled = SCALER.transform(nova_feature)
|
| 73 |
|
|
|
|
| 1 |
import os
|
| 2 |
import shutil
|
| 3 |
+
import joblib
|
| 4 |
+
import numpy as np
|
| 5 |
from fastapi import FastAPI, File, UploadFile, Depends, HTTPException, status
|
| 6 |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
| 7 |
+
from feature_extractor_single import process_single_image
|
| 8 |
|
| 9 |
#1. CONFIGURAÇÃO DA APLICAÇÃO E AUTENTICAÇÃO
|
| 10 |
app = FastAPI(title="SojaClassifierAPI")
|
|
|
|
| 60 |
|
| 61 |
try:
|
| 62 |
#Extrai Features (ConvNext - 1536 dimensões)
|
| 63 |
+
#(process_single_image vem do feature_extractor_single.py)
|
| 64 |
features_array = process_single_image(temp_path)
|
| 65 |
|
| 66 |
+
#Prepara o vetor para Scikit-learn
|
| 67 |
#O sklearn espera um array 2D (1, 1536) e não (1536,)
|
| 68 |
nova_feature = features_array.reshape(1, -1)
|
| 69 |
|
| 70 |
+
#Executa o pipeline de classificação
|
| 71 |
#Normaliza a nova feature com o mesmo scaler usado no treino
|
| 72 |
nova_feature_scaled = SCALER.transform(nova_feature)
|
| 73 |
|