"No media data found" when trying to create a task via SDK
See original GitHub issueMy actions before raising this issue
- Read/searched the docs
- Searched past issues
I want to create a task including a file from shared disk via the SDK, but i receive a error that the file is not found:
Error: Request failed with status code 500. “ValueError: No media data found\n”.
Expected Behaviour
The Task should be created
Current Behaviour
No task creation possible.
Possible Solution
I think there is a error in the shared files implementation. Could it be that there is a error in the file path generation with the Quotation marks as seen in the log of the buttom of the issue ? Looks suspicous to me, but beside the quotation marks the path would be correct.
Steps to Reproduce (for bugs)
- Create a uploader script
from cvat_sdk import make_client, models
from cvat_sdk.core.proxies.tasks import ResourceType, Task
user="xxx"
pw="xxx"
host="xxx"
# Create a Client instance bound to a local server and authenticate using basic auth
with make_client(host=host, credentials=(user, pw), port=8080) as client:
# Let's create a new task.
# Fill in task parameters first.
# Models are used the same way as in the layer 1.
task_spec = {
"name": "example task",
"labels": [
{
"name": "car",
"color": "#ff00ff",
"attributes": [
{
"name": "a",
"mutable": True,
"input_type": "number",
"default_value": "5",
"values": ["4", "5", "6"],
}
],
}
],
}
oneFile ="flightdata/2022-08-13T09-00-00-payload-images-helgoland/cam-l/2022-06-15T08-21-49.975755.jpg" # i am not 100perc sure about this, but i created a task via UI including this file and used the shared folder path which was shown in UI on the top
task = client.tasks.create_from_data(
spec=task_spec,
resource_type=ResourceType.SHARE,
resources=[oneFile]
)
- Run the script
- Response:
(cvat) xxx@asfasf:~/cvat_task_creator$ python3 creator.py
Traceback (most recent call last):
File "/rzhome/xxx/cvat_task_creator/creator.py", line 42, in <module>
task = client.tasks.create_from_data(
File "/rzhome/xxx/miniconda3/envs/cvat/lib/python3.9/site-packages/cvat_sdk/core/proxies/tasks.py", line 311, in create_from_data
raise exceptions.ApiException(
cvat_sdk.api_client.exceptions.ApiException: Status Code: 200
Reason: OK
HTTP response headers: HTTPHeaderDict({'Allow': 'GET, HEAD, OPTIONS', 'Content-Length': '77', 'Content-Type': 'application/vnd.cvat+json', 'Date': 'Thu, 03 Nov 2022 18:52:43 GMT', 'Referrer-Policy': 'same-origin', 'Server': 'Apache', 'Vary': 'Accept,Origin', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'DENY'})
HTTP response body: b'{"state":"Failed","message":"ValueError: No media data found","progress":0.0}'
Context
I want to create tasks automatically without using the UI, the folders with the images include also other files . In the UI its too much work explicitly excluding all non-images, so i want to have a SDK way to create tasks. The CLI also doesnt work for me due to https://github.com/opencv/cvat/issues/4962 ( i think i need to wait for the next release be able to use it?)
Your Environment
- Running via
CVAT_VERSION=dev docker-compose up -d - Git hash commit (
git log -1):
commit 2311b10b800a5c564af3af547472541e9b9b7cde (HEAD -> develop, origin/develop, origin/HEAD)
Author: Anastasia Yasakova <yasakova_anastasiya@mail.ru>
Date: Fri Oct 21 12:52:36 2022 +0300
Fix an issue with Imagenet dataset import (#4861)
- Docker version
docker version(e.g. Docker 17.0.05): Docker 20.10.12 - Are you using Docker Swarm or Kubernetes? No
- Operating System and version (e.g. Linux, Windows, MacOS): Debian
- Code example or link to GitHub repo or gist to reproduce problem: No
- Other diagnostic information / logs:
django@c58e8b630737:~$ cat logs/cvat_server.log
....
[2022-11-03 18:52:38,760] INFO cvat.server: create task #117
[2022-11-03 18:52:38,766] WARNING cvat.server: Skip '/home/django/share/"flightdata/2022-08-13T09-00-00-payload-images-helgoland/cam-l/2022-06-15T08-21-49.975755.jpg"' file (its mime type doesn't correspond to supported MIME file type)
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top Related StackOverflow Question
I’ve tried running your reproduction script with the development version of the SDK (swapping out the image path for my own), and it worked for me. So make sure you’re using the development version of the SDK. For example, check
cvat_sdk/core/proxies/tasks.pyand make sure it has no mentions of “multipart”.I think (not expert in this) i was able to compile the sdk on my own using the official schema from https://app.cvat.ai/api/docs/ and the howto from https://opencv.github.io/cvat/docs/api_sdk/sdk/developer-guide/
But i still get the same problem in the log:
[2022-11-05 16:55:49,722] WARNING cvat.server: Skip '/home/django/share/"flightdata/2022-08-13T09-00-00-payload-images-helgoland/cam-l/2022-06-15T08-21-49.975755.jpg"' file (its mime type doesn't correspond to supported MIME file type)Does this mean that the SDK recompilation cant be succesful or the issue might be somewhere else?
When will be the 2.3 pypi sdk release with the bugfix?