Comments (7)
Hi,
it is important to provide an URL with the proper protocol identifier. While your local installation is plain http the cvat instance in your initial post seems to rely on https only (with a http to https redirect) while you are providing a http-url in your configuration. http://example.com and https://example.com were considered as independent scopes in view of security.
ps:
your second example could be simplified (it is not necessary to retrieve the api key or login explicitly):
# Set up an API client
# Read Configuration class docs for more info about parameters and authentication methods
from pprint import pprint
from cvat_sdk.api_client import Configuration, ApiClient, exceptions
configuration = Configuration(
host='https://hostname/',
username="user",
password="password"
)
with ApiClient(configuration) as api_client:
cvat_id = 585
format = 'CVAT for images 1.1'
try:
(data, response) = api_client.tasks_api.retrieve_annotations(cvat_id, _parse_response=False)
pprint(data)
except exceptions.ApiException as e:
print("Exception when calling TasksApi.retrieve_annotations(): %s\n" % e)
from cvat.
Hi, please check this function. Consider using the high-level API, if it's possible in your use case.
from cvat.
Hi,
I have tried using the high-level API but, I still get the same error.
from cvat_sdk import Config, Client
config = Config()
# set up some config fields ...
with Client('http://cvat-intern.clkgmbh.de/', config=config) as client:
client.login(('username', 'password'))
# Retrieve annotations using the authenticated client
cvat_id = 585
try:
# Fetch annotations for the specified task
annotations = client.tasks.retrieve(cvat_id)
pprint(annotations)
except Exception as e:
print(f"Exception when calling retrieve_annotations: {e}")
Exception when calling retrieve_annotations: Status Code: 401
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Server': 'nginx', 'Date': 'Tue, 16 Jul 2024 13:27:50 GMT', 'Content-Type': 'application/vnd.cvat+json', 'Content-Length': '58', 'Connection': 'keep-alive', 'Allow': 'GET, PATCH, DELETE, HEAD, OPTIONS', 'Cross-Origin-Opener-Policy': 'same-origin', 'Referrer-Policy': 'same-origin, strict-origin-when-cross-origin', 'Vary': 'Accept, Origin, Cookie', 'Www-Authenticate': 'Token', 'X-Content-Type-Options': 'nosniff, nosniff', 'X-Frame-Options': 'DENY', 'X-Request-Id': '43e5b767-681b-44ec-b036-28da310d1f0c'})
HTTP response body: {"detail":"Authentication credentials were not provided."}
from cvat.
Please try to add an extra header like this:
client.api_client.set_default_header("X-Csrftoken", client.api_client.cookies.get("csrftoken"))
from cvat.
After adding an extra header:
client.api_client.set_default_header("X-Csrftoken", client.api_client.cookies.get("csrftoken"))
I get the following error:
Exception when calling retrieve_annotations: expected string or bytes-like object, got 'dict'
I have also installed a local CVAT version for further debugging. With high-level API:
from cvat_sdk import Config, Client
config = Config()
# set up some config fields ...
with Client('http://localhost:8080/', config=config) as client:
client.login(('abc', 'abc1234!'))
# Retrieve annotations using the authenticated client
cvat_id = 1
# client.api_client.set_default_header("X-Csrftoken", client.api_client.cookies.get("csrftoken"))
try:
# Fetch annotations for the specified task
annotations = client.tasks.retrieve(cvat_id)
pprint(annotations)
except Exception as e:
print(f"Exception when calling retrieve_annotations: {e}")
I get the following output:
<Task: id=1>
Using the following method:
# Set up an API client
# Read Configuration class docs for more info about parameters and authentication methods
configuration = Configuration(
host = 'http://localhost:8080/',
username = 'abc',
password = 'abc1234!'
)
# Login
with ApiClient(configuration) as api_client:
login_serializer_ex_request = LoginSerializerExRequest(
username="abc",
email="",
password="abc1234!"
)
cvat_id = 1
try:
(data, response) = api_client.auth_api.create_login(login_serializer_ex_request)
pprint(data)
except exceptions.ApiException as e:
print("Exception when calling AuthApi.create_login(): %s\n" % e)
format = 'CVAT for images 1.1'
try:
(data, response) = api_client.tasks_api.retrieve_annotations(cvat_id, _parse_response=False)
pprint(data)
except exceptions.ApiException as e:
print("Exception when calling TasksApi.retrieve_annotations(): %s\n" % e)
I get the following output:
{'key': '890deec95b28a82e0b7bd70720ce06723686a412'}
None
from cvat.
I get the following error:
Exception when calling retrieve_annotations: expected string or bytes-like object, got 'dict'
It's hard to guess without the stack trace. It seems like the response contained some data, which could not be parsed, probably you should have used the _parse_response=False
parameter in the request parameters.
I have also installed a local CVAT version for further debugging. With high-level API: [...]
I get the following output:
<Task: id=1>
Ok, it seems to be working in that test. The comments in the code snippet speak about annotations, but you requested a task, and it was successfully retrieved.
Using the following method: [...]
I get the following output:
{'key': '890deec95b28a82e0b7bd70720ce06723686a412'}
None
I see you got no error for the second request, so it also seems to be working. None
was returned for data
because of _parse_response=False
in the request parameters. If you're using this parameter, you need to check response.data
for returned contents.
Overall, it seems like some proxy server / firewall problem with the deployed instance.
from cvat.
@zhiltsov-max and @descilla Authentication issue has been resolved.
from cvat.
Related Issues (20)
- Serverless function works from Task menu (selecting Automatic Annotation), but not from AI Tools in the Jobs section
- Organization name HOT 5
- Error at Export job dataset HOT 2
- Error 500 when trying to create Ground truth job with python SDK HOT 2
- Export job dataset on cvat.ai website HOT 1
- 503 Server Error: Service Unavailable for url: http://host.docker.internal:32770/ HOT 4
- Unable to upload images with the same file name HOT 1
- Cuboid only on point cloud? HOT 1
- Revert change to "Finish the job" behavior on app.cvat.com HOT 4
- Am I the only one whose client events are not being saved in k8s? HOT 1
- 'Deny: Private Range'. destination address was denied by rule HOT 3
- When I want to use semi-automatic annotations,there's a problem accurred weith serverless. HOT 1
- LambdaFunction does not map attrs of skeleton sublabels HOT 1
- How to create upload annotation of polygon points to a job to create polygon tracks for multiple frames? HOT 1
- python sdk api_client.jobs_api.create_annotations to import annotations of COCO format HOT 3
- CVAT SDK does not return XML format HOT 2
- Correction of export to COCO format in CVAT version 2.4.7 HOT 2
- install nuclo cvat AI SAM tool in local hosted CVAT on windows HOT 3
- CVAT downloads the deleted images when exporting the dataset. HOT 4
- List add on appearnce block in cvat-ui
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cvat.