Spaces:
Runtime error
Runtime error
| import fiftyone as fo | |
| import requests | |
| DATASET_NAME = "VIC_AND_THE_BOYZ" | |
| CVAT_PROJECT_NAME = "VIC_AND_THE_BOYZ" | |
| # Replace with your CVAT credentials and URL | |
| cvat_url = "http://app.cvat.ai" | |
| username = 'daniel.fortunato' | |
| password = 'Lasanha123' | |
| def load_vic_and_boyz_dataset(dataset_name=DATASET_NAME): | |
| if dataset_name in fo.list_datasets(): | |
| dataset_name = fo.load_dataset(dataset_name) | |
| else: | |
| dataset_name = fo.Dataset(name=dataset_name, persistent=True, overwrite=True) | |
| def bad_image_upload(dataset: fo.Dataset, image_filepath, description): | |
| sample = fo.Sample(filepath=image_filepath, description=description) | |
| dataset.add_sample(sample) | |
| def upload_image_to_cvat(image_path, description="HEY"): | |
| auth_data = { | |
| 'username': username, | |
| 'password': password | |
| } | |
| response = requests.post(f'{cvat_url}/api/auth/login', json=auth_data) | |
| response.raise_for_status() | |
| token = response.json()['key'] | |
| response = requests.get(f'{cvat_url}/api/projects', headers={'Authorization': f'Token {token}'}) | |
| response.raise_for_status() | |
| projects = response.json()["results"] | |
| task_name = description | |
| project_id = projects[0]['id'] # replace with your specific project ID on the official CVAT server | |
| headers = {'Authorization': f'Token {token}'} | |
| task_data = { | |
| "name": task_name, | |
| "project_id": project_id | |
| } | |
| task_response = requests.post(f"{cvat_url}/api/tasks", headers=headers, json=task_data) | |
| task_id = task_response.json()["id"] | |
| print("TASK ID: ", task_id) | |
| with open('/Users/danielfortunato/Documents/Git/VicAndTheBoys/flagged/0647ac81eec7ca0472cbefb31326eb75bc33941e/tmpgbwsvy4t.png', 'rb') as f: | |
| files = {'image': f} | |
| upload_response = requests.post(f"{cvat_url}/api/tasks/{task_id}/data", headers=headers, files=files, data={"image_quality": 50}) | |
| print("UPLOAD RESPONSE: ", upload_response.json()) |