Closed bagherig closed 1 year ago
issue self-fixed, was another comma problem in the spec field (removed it)
проблема устранена самостоятельно, была еще одна проблема с запятой в поле спецификации (удалена)
@Errin890 Hi, can you tell me where you put your custom weights and how? I want to cast my yolov5 model, but I can't do it.
main.py
metadata:
name: ultralytics-yolov5
namespace: cvat
annotations:
name: YOLO v5
type: detector
framework: pytorch
spec: |
[
{ "id": 0, "name": "person" },
{ "id": 1, "name": "Kitty" }
]
spec:
description: YOLO v5 via pytorch hub
runtime: 'python:3.6'
handler: main:handler
eventTimeout: 30s
build:
image: cvat.ultralytics-yolov5
baseImage: ultralytics/yolov5:latest-cpu
directives:
preCopy:
- kind: USER
value: root
- kind: RUN
value: apt update && apt install --no-install-recommends -y libglib2.0-0
- kind: WORKDIR
value: /opt/nuclio
triggers:
myHttpTrigger:
maxWorkers: 2
kind: 'http'
workerAvailabilityTimeoutMilliseconds: 10000
attributes:
maxRequestBodySize: 33554432 # 32MB
platform:
attributes:
restartPolicy:
name: always
maximumRetryCount: 3
mountMode: volume
function.yaml
import json
import base64
from PIL import Image
import io
import torch
def init_context(context):
context.logger.info("Init context... 0%")
# Read the DL model
model = torch.hub.load('ultralyics/yolov5', '/opt/nuclio/weights.pt')
context.user_data.model = model
context.logger.info("Init context...100%")
def handler(context, event):
context.logger.info("Run yolo-v5 model")
data = event.body
buf = io.BytesIO(base64.b64decode(data["image"]))
threshold = float(data.get("threshold", 0.5))
context.user_data.model.conf = threshold
image = Image.open(buf)
yolo_results_json = context.user_data.model(image).pandas().xyxy[0].to_dict(orient='records')
encoded_results = []
for result in yolo_results_json:
encoded_results.append({
'confidence': result['confidence'],
'label': result['name'],
'points': [
result['xmin'],
result['ymin'],
result['xmax'],
result['ymax']
],
'type': 'rectangle'
})
return context.Response(body=json.dumps(encoded_results), headers={},
content_type='application/json', status_code=200)
@Errin890 Hi, I would like also to know how and where do you put your model weights .pt
file?
In your function.yaml
, it doesn't include this. Thanks!
@nfrvnikita Have your figured out where and how? Thanks!
issue self-fixed, was another comma problem in the spec field (removed it)
This error from the cvat_server docker file logs was caused by a trailing comma-
json.decoder.JSONDecodeError: Expecting value: line 5 column 1 (char 106)
Thank goodness for your note on this @Errin890 . Here is troublesome code snippet.
metadata:
name: 3c-yolov8
namespace: cvat
annotations:
name: 3c-yolov8
type: detector
framework: pytorch
spec: |
[
{ "id": 0, "name": c1"},
{ "id": 1, "name": "c2"},
{ "id": 2, "name": "c3"},
]
Fixed by removing the comma on { "id": 2, "name": "c3"},
I am trying to deploy a custom model on cvat. The docker container runs successfully.
but I am unable to load the model on the web.
Error: Request failed with status code 500. "\n<!doctype html>\n<html lang=\"en\">\n<head>\n <title>Server Error (500)</title>\n</head>\n<body>\n <h1>Server Error (500)</h1><p></p>\n</body>\n</html>\n".
Here are my docker logs:
Here is my .yaml file:
and main.py file: