未验证 提交 398b28da 编写于 作者: B Boris Sekachev 提交者: GitHub

Removed extra endpoints from the server which used only to get client assets (#6663)

<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [ ] I have added a description of my changes into the
[CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md)
file
- [ ] I have updated the documentation accordingly
- [ ] I have added tests to cover my changes
- [ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
上级 50ea19aa
......@@ -12,6 +12,7 @@ module.exports = {
ignorePatterns: [
'.eslintrc.js',
'webpack.config.js',
'src/assets/opencv_4.5.4_dev.js',
'node_modules/**',
'dist/**',
],
......
......@@ -49,7 +49,7 @@
"lru-cache": "^9.1.1",
"moment": "^2.29.2",
"mousetrap": "^1.6.5",
"onnxruntime-web": "^1.14.0",
"onnxruntime-web": "1.15.1",
"platform": "^1.3.6",
"prop-types": "^15.7.2",
"react": "^16.14.0",
......
......@@ -4,6 +4,7 @@
import { InferenceSession, Tensor } from 'onnxruntime-web';
import { LRUCache } from 'lru-cache';
import { Job } from 'cvat-core-wrapper';
import { PluginEntryPoint, APIWrapperEnterOptions, ComponentBuilder } from 'components/plugins-entrypoint';
interface SAMPlugin {
......@@ -186,8 +187,9 @@ const samPlugin: SAMPlugin = {
return result;
}
const job = Object.values(plugin.data.jobs)
.find((_job) => _job.taskId === taskID);
const job = Object.values(plugin.data.jobs).find((_job) => (
_job.taskId === taskID && frame >= _job.startFrame && frame <= _job.stopFrame
)) as Job;
if (!job) {
throw new Error('Could not find a job corresponding to the request');
}
......@@ -267,7 +269,7 @@ const samPlugin: SAMPlugin = {
core: null,
jobs: {},
modelID: 'pth-facebookresearch-sam-vit-h',
modelURL: '/api/lambda/sam_detector.onnx',
modelURL: '/assets/decoder.onnx',
embeddings: new LRUCache({
// float32 tensor [256, 64, 64] is 4 MB, max 512 MB
max: 128,
......
<svg xmlns="http://www.w3.org/2000/svg">
<g xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 40 40">
<ellipse style="fill: rgb(216, 216, 216);" cx="20" cy="20" ry="11" rx="11"></ellipse>
<path d="M 39.462 2.335 C 39.134 2.204 38.755 2.278 38.507 2.518 L 34.866 6.053 C 30.955 2.151 25.733 0 20.162 0 C 18.985 0 17.795 0.098 16.63 0.298 C 8.691 1.637 2.262 7.4 0.248 14.988 C 0.181 15.241 0.24 15.514 0.404 15.722 C 0.572 15.931 0.824 16.053 1.097 16.053 L 6.677 16.053 C 7.043 16.053 7.375 15.829 7.501 15.494 C 9.133 11.155 13.19 7.849 17.837 7.065 C 18.602 6.935 19.38 6.869 20.153 6.869 C 23.845 6.869 27.293 8.302 29.862 10.91 L 26.162 14.502 C 25.914 14.747 25.838 15.11 25.973 15.429 C 26.107 15.747 26.427 15.955 26.78 15.955 L 39.125 15.955 C 39.609 15.955 40 15.576 40 15.106 L 40 3.118 C 40.004 2.776 39.79 2.465 39.462 2.335 Z" data-bx-origin="-0.660719 -0.618451"></path><path d="M 38.907 23.951 L 33.327 23.951 C 32.961 23.951 32.629 24.176 32.503 24.51 C 30.871 28.845 26.814 32.151 22.168 32.935 C 21.402 33.065 20.624 33.131 19.851 33.131 C 16.159 33.131 12.711 31.698 10.142 29.09 L 13.842 25.498 C 14.094 25.253 14.166 24.89 14.031 24.571 C 13.897 24.253 13.577 24.045 13.224 24.045 L 0.875 24.045 C 0.391 24.045 0 24.424 0 24.894 L 0 36.878 C 0 37.22 0.214 37.531 0.542 37.665 C 0.87 37.796 1.245 37.722 1.497 37.482 L 5.138 33.947 C 9.044 37.849 14.267 40 19.842 40 C 21.024 40 22.21 39.898 23.378 39.702 C 31.313 38.367 37.738 32.6 39.752 25.012 C 39.819 24.759 39.76 24.486 39.596 24.278 C 39.432 24.073 39.176 23.951 38.907 23.951 Z" data-bx-origin="-0.655168 -2.110973"></path>
</g>
</svg>
......@@ -64,7 +64,7 @@ export class OpenCVWrapper {
}
private async inject(): Promise<void> {
const response = await fetch(`${baseURL}/opencv/opencv.js`);
const response = await fetch(`${baseURL}/assets/opencv.js`);
if (response.status !== 200) {
throw new Error(`Response status ${response.status}. ${response.statusText}`);
}
......
......@@ -68,7 +68,7 @@ module.exports = (env) => {
{
context: (param) =>
param.match(
/\/api\/.*|git\/.*|opencv\/.*|analytics\/.*|static\/.*|admin(?:\/(.*))?.*|profiler(?:\/(.*))?.*|documentation\/.*|django-rq(?:\/(.*))?/gm,
/\/api\/.*|git\/.*|analytics\/.*|static\/.*|admin(?:\/(.*))?.*|profiler(?:\/(.*))?.*|documentation\/.*|django-rq(?:\/(.*))?/gm,
),
target: env && env.API_URL,
secure: false,
......@@ -209,6 +209,14 @@ module.exports = (env) => {
from: '../node_modules/onnxruntime-web/dist/*.wasm',
to : 'assets/[name][ext]',
},
{
from: 'src/assets/opencv*.js',
to : 'assets/opencv.js',
},
{
from: 'plugins/**/assets/*.(onnx|js)',
to : 'assets/[name][ext]',
}
],
}),
...(sourceMapsToken ? [new webpack.SourceMapDevToolPlugin({
......
......@@ -25,6 +25,5 @@ router.register('requests', views.RequestViewSet, basename='request')
# GET /api/lambda/requests/<int:rid> - get status of the request
# DEL /api/lambda/requests/<int:rid> - cancel a request (don't delete)
urlpatterns = [
path('api/lambda/', include(router.urls)),
path('api/lambda/sam_detector.onnx', views.ONNXDetector)
path('api/lambda/', include(router.urls))
]
......@@ -9,7 +9,6 @@ import base64
import json
import os
import textwrap
import glob
from copy import deepcopy
from enum import Enum
from functools import wraps
......@@ -38,7 +37,6 @@ from cvat.apps.engine.serializers import LabeledDataSerializer
from cvat.apps.lambda_manager.serializers import (
FunctionCallRequestSerializer, FunctionCallSerializer
)
from cvat.apps.engine.utils import sendfile
from cvat.utils.http import make_requests_session
from cvat.apps.iam.permissions import LambdaPermission
from cvat.apps.iam.filters import ORGANIZATION_OPEN_API_PARAMETERS
......@@ -1007,11 +1005,3 @@ class RequestViewSet(viewsets.ViewSet):
queue = LambdaQueue()
rq_job = queue.fetch_job(pk)
rq_job.delete()
def ONNXDetector(request):
dirname = os.path.join(settings.STATIC_ROOT, 'lambda_manager')
pattern = os.path.join(dirname, 'decoder.onnx')
path = glob.glob(pattern)[0]
response = sendfile(request, path)
response['Cache-Control'] = "public, max-age=604800"
return response
# Updating OpenCV.js
The latest version of OpenCV JavaScript library can be pulled from [OpenCV site](https://docs.opencv.org/master/opencv.js).
To install it just push `opencv.js` to <b>cvat/apps/opencv/static/opencv/js</b>
If develop locally, do not forget update static files after pushing `python manage.py collectstatic`
# Copyright (C) 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
# Copyright (C) 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
from django.apps import AppConfig
class OpenCVConfig(AppConfig):
name = 'cvat.apps.opencv'
# Copyright (C) 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
# Copyright (C) 2018-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
from django.urls import path
from . import views
urlpatterns = [
path('opencv.js', views.OpenCVLibrary)
]
import os
import glob
from django.conf import settings
from cvat.apps.engine.utils import sendfile
def OpenCVLibrary(request):
dirname = os.path.join(settings.STATIC_ROOT, 'opencv', 'js')
pattern = os.path.join(dirname, 'opencv_*.js')
path = glob.glob(pattern)[0]
response = sendfile(request, path)
response['Cache-Control'] = "public, max-age=604800"
return response
......@@ -137,7 +137,6 @@ INSTALLED_APPS = [
'cvat.apps.engine',
'cvat.apps.dataset_repo',
'cvat.apps.lambda_manager',
'cvat.apps.opencv',
'cvat.apps.webhooks',
'cvat.apps.health',
'cvat.apps.events',
......
......@@ -40,9 +40,6 @@ if apps.is_installed('cvat.apps.events'):
if apps.is_installed('cvat.apps.lambda_manager'):
urlpatterns.append(path('', include('cvat.apps.lambda_manager.urls')))
if apps.is_installed('cvat.apps.opencv'):
urlpatterns.append(path('opencv/', include('cvat.apps.opencv.urls')))
if apps.is_installed('cvat.apps.webhooks'):
urlpatterns.append(path('api/', include('cvat.apps.webhooks.urls')))
......
......@@ -51,7 +51,7 @@ services:
- traefik.enable=true
- traefik.http.services.cvat.loadbalancer.server.port=8080
- traefik.http.routers.cvat.rule=Host(`${CVAT_HOST:-localhost}`) &&
PathPrefix(`/api/`, `/git/`, `/opencv/`, `/static/`, `/admin`, `/documentation/`, `/django-rq`)
PathPrefix(`/api/`, `/git/`, `/static/`, `/admin`, `/documentation/`, `/django-rq`)
- traefik.http.routers.cvat.entrypoints=web
volumes:
- cvat_data:/home/django/data
......
......@@ -379,11 +379,6 @@ ingress:
# service:
# name: backend-service
# port: 8080
# - path: /opencv
# pathType: "Prefix"
# service:
# name: backend-service
# port: 8080
# - path: /profiler
# pathType: "Prefix"
# service:
......
......@@ -146,7 +146,7 @@ To do this, you will need to edit `traefik.http.<router>.cvat.rule` docker label
cvat:
labels:
- traefik.http.routers.cvat.rule=(Host(`example1.com`) || Host(`example2.com`)) &&
PathPrefix(`/api/`, `/git/`, `/opencv/`, `/analytics/`, `/static/`, `/admin`, `/documentation/`, `/django-rq`)
PathPrefix(`/api/`, `/git/`, `/analytics/`, `/static/`, `/admin`, `/documentation/`, `/django-rq`)
cvat_ui:
labels:
......
......@@ -2073,7 +2073,7 @@
resolved "https://registry.yarnpkg.com/@types/polylabel/-/polylabel-1.0.5.tgz#9262f269de36f1e9248aeb9dee0ee9d10065e043"
integrity sha512-gnaNmo1OJiYNBFAZMZdqLZ3hKx2ee4ksAzqhKWBxuQ61PmhINHMcvIqsGmyCD1WFKCkwRt9NFhMSmKE6AgYY+w==
"@types/prettier@2.4.1", "@types/prettier@^2.1.5":
"@types/prettier@^2.1.5":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.4.1.tgz#e1303048d5389563e130f5bdd89d37a99acb75eb"
integrity sha512-Fo79ojj3vdEZOHg3wR9ksAMRz4P3S5fDB5e/YWZiFnyFQI1WY2Vftu9XoXVVtJfxB7Bpce/QTqWSSntkz2Znrw==
......@@ -2111,12 +2111,12 @@
"@types/react" "*"
"@types/reactcss" "*"
"@types/react-dom@^16.9.14", "@types/react-dom@^18.0.5":
version "18.2.7"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.7.tgz#67222a08c0a6ae0a0da33c3532348277c70abb63"
integrity sha512-GRaAEriuT4zp9N4p1i8BDBYmEyfo+xQ3yHjJU4eiK5NDa1RmUZG+unZABUTK4/Ox/M+GaHwb6Ow8rUITrtjszA==
"@types/react-dom@^16.9.14":
version "16.9.19"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.19.tgz#6a139c26b02dec533a7fa131f084561babb10a8f"
integrity sha512-xC8D280Bf6p0zguJ8g62jcEOKZiUbx9sIe6O3tT/lKfR87A7A6g65q13z6D5QUMIa/6yFPkNhqjF5z/VVZEYqQ==
dependencies:
"@types/react" "*"
"@types/react" "^16"
"@types/react-grid-layout@^1.3.2":
version "1.3.2"
......@@ -2125,7 +2125,7 @@
dependencies:
"@types/react" "*"
"@types/react-redux@^7.1.18", "@types/react-redux@^7.1.24":
"@types/react-redux@^7.1.18":
version "7.1.25"
resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.25.tgz#de841631205b24f9dfb4967dd4a7901e048f9a88"
integrity sha512-bAGh4e+w5D8dajd6InASVIyCo4pZLJ66oLb80F9OBLO1gKESbZcRCJpTT6uLXX+HAB57zw1WTdwJdAsewuTweg==
......@@ -2135,7 +2135,7 @@
hoist-non-react-statics "^3.3.0"
redux "^4.0.0"
"@types/react-router-dom@^5.1.9", "@types/react-router-dom@^5.3.3":
"@types/react-router-dom@^5.1.9":
version "5.3.3"
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.3.3.tgz#e9d6b4a66fcdbd651a5f106c2656a30088cc1e83"
integrity sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw==
......@@ -2159,7 +2159,7 @@
dependencies:
"@types/react" "*"
"@types/react@*", "@types/react@^16.14.15", "@types/react@^17.0.30":
"@types/react@*":
version "17.0.62"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.62.tgz#2efe8ddf8533500ec44b1334dd1a97caa2f860e3"
integrity sha512-eANCyz9DG8p/Vdhr0ZKST8JV12PhH2ACCDYlFw6DIO+D+ca+uP4jtEDEpVqXZrh/uZdXQGwk7whJa3ah5DtyLw==
......@@ -2168,6 +2168,15 @@
"@types/scheduler" "*"
csstype "^3.0.2"
"@types/react@^16", "@types/react@^16.14.15":
version "16.14.45"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.14.45.tgz#c505c96adf959971fc97b4687187c871765a6ae4"
integrity sha512-XFtKkY3yuPO5VJSE6Lru9yLkVQvYE+l6NbmLp6IWCg4jo5S8Ijbpke8wC9q4NmQ5pJErT8KKboG5eY7n5n718A==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
csstype "^3.0.2"
"@types/reactcss@*":
version "1.2.6"
resolved "https://registry.yarnpkg.com/@types/reactcss/-/reactcss-1.2.6.tgz#133c1e7e896f2726370d1d5a26bf06a30a038bcc"
......@@ -8789,21 +8798,21 @@ onnx-proto@^4.0.4:
dependencies:
protobufjs "^6.8.8"
onnxruntime-common@~1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/onnxruntime-common/-/onnxruntime-common-1.14.0.tgz#2bb5dac5261269779aa5fb6536ca379657de8bf6"
integrity sha512-3LJpegM2iMNRX2wUmtYfeX/ytfOzNwAWKSq1HbRrKc9+uqG/FsEA0bbKZl1btQeZaXhC26l44NWpNUeXPII7Ew==
onnxruntime-common@~1.15.1:
version "1.15.1"
resolved "https://registry.yarnpkg.com/onnxruntime-common/-/onnxruntime-common-1.15.1.tgz#1b8af102409b5465811a7faef31cf438bded5425"
integrity sha512-Y89eJ8QmaRsPZPWLaX7mfqhj63ny47rSkQe80hIo+lvBQdrdXYR9VO362xvZulk9DFkCnXmGidprvgJ07bKsIQ==
onnxruntime-web@^1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/onnxruntime-web/-/onnxruntime-web-1.14.0.tgz#c8cee538781b1d4c1c6b043934f4a3e6ddf1466e"
integrity sha512-Kcqf43UMfW8mCydVGcX9OMXI2VN17c0p6XvR7IPSZzBf/6lteBzXHvcEVWDPmCKuGombl997HgLqj91F11DzXw==
onnxruntime-web@1.15.1:
version "1.15.1"
resolved "https://registry.yarnpkg.com/onnxruntime-web/-/onnxruntime-web-1.15.1.tgz#483fcde978fb89b139f60ed9025595dff778be33"
integrity sha512-Ky4AXFLFyiGRu5KQJdDcbhdNcO0f2ND/8IPmTEwcKKIHpCwH6/Q9UoMpcoFz78lxGvnmmy+FFgA/Bs1HjdM6LA==
dependencies:
flatbuffers "^1.12.0"
guid-typescript "^1.0.9"
long "^4.0.0"
onnx-proto "^4.0.4"
onnxruntime-common "~1.14.0"
onnxruntime-common "~1.15.1"
platform "^1.3.6"
open@^8.0.9:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册