Wie stelle ich lokale Modellgewichte (Best.pt) für die automatische Annotation bereit, um CVAT zu erhalten?Python

Python-Programme
Anonymous
 Wie stelle ich lokale Modellgewichte (Best.pt) für die automatische Annotation bereit, um CVAT zu erhalten?

Post by Anonymous »

Ich versuche, CVAT lokal mit Docker für die Beschriftung für das Bildnahrungsbox zu verwenden. Um Zeit zu sparen, würde ich gerne Auto-Annotation mit einem teilweise geschulten Modell verwenden. Wenn ich jedoch versuche, das Modell von WSL bereitzustellen, erhalte ich immer wieder einen Fehler mit den Anforderungen. Txt fehlt. Ich bin mir nicht sicher, wie ich vorgehen soll. Jede Hilfe wäre sehr geschätzt. < /P>

Code: Select all

@DESKTOP-HS1UL5Q:~/.nuclio/best-model$ nuctl deploy --project-name cvat --path . --platform local

Ich versuche, das Modell oben auszuführen, aber es kann Anforderungen nicht finden. Das Bild unten zeigt die Dateistruktur. />

Code: Select all

metadata:
name: best-model
namespace: cvat
spec:
runtime: python:3.9
handler: handler:handler
description: YOLOv8 object detector for CVAT
env: []
build:
commands:
- pip install -r requirements.txt
artifacts:
- target: best.pt
- target: handler.py
- target: requirements.txt
triggers:
http:
kind: http
maxWorkers: 1
workerAvailabilityTimeoutMilliseconds: 10000
attributes:
maxRequestBodySize: 33554432
Handler.py

Code: Select all

import io
import json
import numpy as np
import cv2
from PIL import Image
import base64
from ultralytics import YOLO

model = YOLO("best.pt")

def handler(context, event):
body = event.body
img_bytes = np.asarray(bytearray(body), dtype=np.uint8)
img = cv2.imdecode(img_bytes, cv2.IMREAD_COLOR)

results = model(img)[0]
predictions = []

for box in results.boxes:
cls = int(box.cls[0].item())
conf = float(box.conf[0].item())
x1, y1, x2, y2 = map(float, box.xyxy[0].tolist())

predictions.append({
"confidence": conf,
"label": str(cls),
"points": [[x1, y1], [x2, y2]],
"type": "rectangle"
})

return context.Response(body=json.dumps(predictions), headers={},
content_type='application/json', status_code=200)
requirements.txt

Code: Select all

ultralytics==8.1.24
opencv-python
numpy

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post