Spaces:
Sleeping
Sleeping
Update app2.py
#2
by ChristianSardo - opened
app2.py
CHANGED
|
@@ -11,6 +11,7 @@ from fastapi import FastAPI, File, UploadFile, HTTPException
|
|
| 11 |
from fastapi.middleware.cors import CORSMiddleware
|
| 12 |
from fastapi.responses import JSONResponse
|
| 13 |
from botocore.exceptions import NoCredentialsError
|
|
|
|
| 14 |
|
| 15 |
# ==============================================================================
|
| 16 |
# 1. CONFIGURAÇÃO E CLIENTES (CARREGADOS NA INICIALIZAÇÃO)
|
|
@@ -110,6 +111,23 @@ def process_image_bytes(img_bytes: bytes):
|
|
| 110 |
|
| 111 |
return analysis_results, corrosion_vis_rgb
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
# ==============================================================================
|
| 114 |
# 3. ENDPOINTS DA API
|
| 115 |
# ==============================================================================
|
|
@@ -118,6 +136,7 @@ def process_image_bytes(img_bytes: bytes):
|
|
| 118 |
def read_root():
|
| 119 |
return {"status": "ok", "message": "API de Análise de Corrosão no ar!"}
|
| 120 |
|
|
|
|
| 121 |
@app.post("/analyze")
|
| 122 |
async def analyze(file: UploadFile = File(...)):
|
| 123 |
"""
|
|
|
|
| 11 |
from fastapi.middleware.cors import CORSMiddleware
|
| 12 |
from fastapi.responses import JSONResponse
|
| 13 |
from botocore.exceptions import NoCredentialsError
|
| 14 |
+
from ultralytics import YOLO
|
| 15 |
|
| 16 |
# ==============================================================================
|
| 17 |
# 1. CONFIGURAÇÃO E CLIENTES (CARREGADOS NA INICIALIZAÇÃO)
|
|
|
|
| 111 |
|
| 112 |
return analysis_results, corrosion_vis_rgb
|
| 113 |
|
| 114 |
+
def segmentate():
|
| 115 |
+
|
| 116 |
+
# Predição basead no melhor modelo gerado (best.pt)
|
| 117 |
+
modelo = YOLO('/content/resultado/Parafuso3/weights/best.pt')
|
| 118 |
+
resultados = modelo.predict(
|
| 119 |
+
source='/content/dados/images/train',
|
| 120 |
+
imgsz=1280,
|
| 121 |
+
conf=0.7,
|
| 122 |
+
iou=0.3,
|
| 123 |
+
save=True,
|
| 124 |
+
save_crop=True,
|
| 125 |
+
project='/content/resultado'
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
|
| 131 |
# ==============================================================================
|
| 132 |
# 3. ENDPOINTS DA API
|
| 133 |
# ==============================================================================
|
|
|
|
| 136 |
def read_root():
|
| 137 |
return {"status": "ok", "message": "API de Análise de Corrosão no ar!"}
|
| 138 |
|
| 139 |
+
|
| 140 |
@app.post("/analyze")
|
| 141 |
async def analyze(file: UploadFile = File(...)):
|
| 142 |
"""
|