Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LabelStudioClient.py #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/yolov7_reid/src/LabelStudioClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def upload_file(file_path):
file_id = None
if file_ids is not None and len(file_ids) > 0:
file_id = file_ids[0]
if file_id is not None:
if file_id is not None and response.ok:
mriamnobody marked this conversation as resolved.
Show resolved Hide resolved
get_upload_file_url = f"{labelstudio_url}/api/import/file-upload/{file_id}"
response = requests.get(get_upload_file_url,headers=auth_header)
if response.ok:
logging.debug(response.json())
return response.json()
logging.debug(response.json())
return response.json()

else:
logging.error('cant get uploaded info')
else:
Expand All @@ -39,7 +39,7 @@ def upload_file(file_path):
@staticmethod
def create_task_with_file(file_path):
resp = LabelStudioClient.upload_file(file_path)
if resp != None:
if resp != None and response.ok:
fileurl = '/data/' + resp['file']
mriamnobody marked this conversation as resolved.
Show resolved Hide resolved
task_json = [{
"data": {"image": fileurl},
Expand All @@ -50,10 +50,10 @@ def create_task_with_file(file_path):
auth_header = {'Authorization' : f'Token {labelstudio_token}'}
task_url = f"{labelstudio_url}/api/projects/{labelstudio_pid}/import"
response = requests.post(task_url, json=task_json, headers=auth_header)
if response.ok:
created_task = response.json()
logging.debug(created_task)
return True
created_task = response.json()
logging.debug(created_task)
return True

else:
logging.error('Failed to create Task {}'.format(response))

Expand All @@ -63,4 +63,4 @@ def create_task_with_file(file_path):
# print(resp)

resp =LabelStudioClient.create_task_with_file('./img.jpg')
print(resp)
print(resp)