I am trying to create a labelling job on SageMaker for labelling the images by drawing a bounding box around it. I have successfully created one from the AWS console but I am unable to make it successful using the boto3 function create_labeling_job() .
Here is the code and the function parameters I used. They are similar to the example from the GitHub amazon-sagemaker-examples but unfortunately it did not work as expected. I can create the job, label the images and the status of the job gets completed. But the output manifest file does not store the annotations numbers.
task_description = "Draw bounding box around the images"
task_keywords = ['Images', 'bounding boxes', 'object detection']
task_title = "Bounding Box task"
job_name = "test-labeling-job"
acs_arn = "arn:aws:lambda:eu-west-1:568282634449:function:ACS-BoundingBox"
prehuman_arn = "arn:aws:lambda:eu-west-1:568282634449:function:PRE-BoundingBox"
human_task_config = {
"AnnotationConsolidationConfig": {
"AnnotationConsolidationLambdaArn": acs_arn,
},
"PreHumanTaskLambdaArn": prehuman_arn,
"MaxConcurrentTaskCount": 1000, # 200 images will be sent at a time to the workteam.
"NumberOfHumanWorkersPerDataObject": 1, # 3 separate workers will be required to label each image.
"TaskAvailabilityLifetimeInSeconds": 864000, # Your workteam has 6 hours to complete all pending tasks.
"TaskDescription": task_description,
"TaskKeywords": task_keywords,
"TaskTimeLimitInSeconds": 3600, # Each image must be labeled within 5 minutes.
"TaskTitle": task_title,
"UiConfig": {
"UiTemplateS3Uri": "s3://bucket-name/bounding-box.liquid.html",
},
"WorkteamArn": "arn:aws:sagemaker:eu-west-1:xxxxxxxxx:workteam/private-crowd/Labellers"
}
ground_truth_request = {
"InputConfig": {
"DataSource": {
"S3DataSource": {
"ManifestS3Uri": "s3://bucket-name/manifest-vic-2.manifest",
}
},
"DataAttributes": {
"ContentClassifiers": []
},
},
"OutputConfig": {
"S3OutputPath": "s3://sagemaker-bucket-name/folder-name-07-12-2022/",
},
"StoppingConditions":{
'MaxPercentageOfInputDatasetLabeled': 100
},
"HumanTaskConfig": human_task_config,
"LabelingJobName": job_name,
"RoleArn": "arn:aws:iam::xxxxxxxxx:role/service-role/AmazonSageMaker-ExecutionRole-xxxxxxxxxx",
"LabelAttributeName": job_name,
"LabelCategoryConfigS3Uri": "s3://bucket-name/label-config.json",
}
sagemaker_client = boto3.client("sagemaker")
sagemaker_client.create_labeling_job(**ground_truth_request)
My label config file looks like the following:
{
"document-version": "2018-11-28",
"labels": [{"label": "animal"}, {"label": "no-animal"}]
}
The manifest file looks like:
{'source-ref': 's3://sagemaker-inout-folder/2022-10-10-12:50:59/A.jpg'}
{'source-ref': 's3://sagemaker-inout-folder/2022-10-10-12:50:59/B.jpg'}
{'source-ref': 's3://sagemaker-inout-folder/2022-10-10-12:50:59/C.jpg'}
And the HTML file is a standard crowd liquid files taken from the github sagemaker examples:
<script src="https://assets.crowd.aws/crowd-html-elements.js"></script>
<crowd-form>
<crowd-bounding-box
name="annotatedResult"
src="{{ task.input.taskObject | grant_read_access }}"
header="Draw bounding boxes around all the cats and dogs in this image"
labels="['Animal', 'No-animal']"
>
<full-instructions header="Bounding Box Instructions" >
<p>Use the bounding box tool to draw boxes around the requested target of interest:</p>
<ol>
<li>Draw a rectangle using your mouse over each instance of the target.</li>
<li>Make sure the box does not cut into the target, leave a 2 - 3 pixel margin</li>
<li>
When targets are overlapping, draw a box around each object,
include all contiguous parts of the target in the box.
Do not include parts that are completely overlapped by another object.
</li>
<li>
Do not include parts of the target that cannot be seen,
even though you think you can interpolate the whole shape of the target.
</li>
<li>Avoid shadows, they're not considered as a part of the target.</li>
<li>If the target goes off the screen, label up to the edge of the image.</li>
</ol>
</full-instructions>
<short-instructions>
Draw boxes around the requested target of interest.
</short-instructions>
</crowd-bounding-box>
</crowd-form>
Once this function is executd, I am able to label the images and the labelling job status changes to 'COMPLETE'. But the output manifest files looks like the following:
{
"source-ref": "s3://sagemaker-inout-folder/2022-10-10-12:50:59/A.jpg",
"test-labeling-job": {
"image_size": [
{ "width": 0, "height": 0, "depth": 3 } ],
"annotations": [] },
"test-labeling-job-metadata": {
"objects": [],
"class-map": {},
"type": "groundtruth/object-detection",
"human-annotated": "yes",
"creation-date": "2022-12-01T08:09:07.933647",
"job-name": "labeling-job/test-labeling-job"
}
}
The image size is weird and the annotations are empty.
Can someone help me if I am doing anything wrong and how do I make this work?
Thank you in advance!
Related
Can any one help me through react native gifted chat? I want to share files like (.pdf, docs, .txt, .jpg.) How to do that?
You have to use renderCustomView (Function) - Custom view inside the bubble prop.
And add some meta information into your message data like this is a SPECIAL message and finally test in renderCustomView if you are in the case of a special message.
https://github.com/FaridSafi/react-native-gifted-chat/blob/master/App.tsx#L128
https://github.com/FaridSafi/react-native-gifted-chat/blob/master/example-expo/CustomView.tsx
react-native-gifted-chat already includes support for images and videos, using the properties video and image of IMessage, just past pass the the link of the resource
{
_id: 1,
text: 'My message',
createdAt: new Date(Date.UTC(2016, 5, 11, 17, 20, 0)),
user: {
_id: 2,
name: 'React Native',
avatar: 'https://facebook.github.io/react/img/logo_og.png',
},
image: 'https://facebook.github.io/react/img/logo_og.png',
// You can also add a video prop:
video: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4',
// Mark the message as sent, using one tick
sent: true,
// Mark the message as received, using two tick
received: true,
// Mark the message as pending with a clock loader
pending: true,
// Any additional custom parameters are passed through
}
For the rest of types you have to implement your own logic, using one of the render functions, i think you could renderMessageImage with a link to the icon of the resources and add a description, also you should handle the click event to start download
I have used primeNg component on bootstrap's bs-modal,i used scrollbar for multiple notes. when click on p-calendar component, calendar is hiding behind scroll bar. As per showing in image.
Add following dependacnies
HostListener from angular-core
import $ from 'jquery';
and write following code to your ts component file.
#HostListener('document:click', ['$event'])
openCloseCalendar(ev) {
if("P-CALENDAR" == ev.path[2].tagName || ev.path[3].tagName){
let calElem = ev.path[2] || ev.path[3];
let target = $(calElem).find(".ui-datepicker")[0];
let calTop = $($(calElem).find("input")[0]).offset();
if(calTop && calTop.top){
$(target).css({"display":"block", "min-width": "200px", "position": "fixed", "top": calTop.top, left: ev.offsetY})
}
}
}
Try adding [appendTo]: 'body' in your p-calendar.
I have two questions using JWPLAYER. I have searched in many places but didn't get the answer, especially regarding audio streaming in JWPLAYER.
Question1:
I am working on transcoding the video files into m3u8 and ts chunks using aws-elastic-transcoder and successfull streaming videos.
Now, I want to stream the audio files.
Does audio files follow the same process of dividing into m3u8 and ts chunks. What extra configurations does it need. What audio files are supported, I also need audio HD quality toggling in audio. How do I achieve it?
Question2:
I want to customize my JWPLAYER, especially AUDIO player. I want to add different buttons into the control-bar.
A shuffle button
An image in the control bar
A download button
A button to show the current queue list.( How to add an audio file
HLS to queue)
A repeat button
A settings Button
So, basically I want to customize the complete player. How can I achieve this. How can I change the whole JWPLAYER HTML.
Please give any reference URL if available.
Here are my options,
JWOptions = {
id: "myPlayer2",
"playlist": [{
"file": "https://s3.amazonaws.com/mypath1/index.m3u8",
"image": "assets/img/bg1.jpg",
"title": "Sintel Trailer",
"mediaid": "ddra573"
}, {
"file": "https://s3.amazonaws.com/mypath2/index.m3u8",
"image": "assets/img/bg2.jpg",
"title": "Big Buck Bunny Trailer",
"mediaid": "ddrx3v2"
}],
width: 800,
height: 40,
}
Thank You.
about 1): you can convert in AAC (m4a) audio files like for video. You can use AAC-LC codec for non high quality, and HE-AAC for high quality audio. jwPlayer setup is the same of video, it works, but you can setup better according to your needs.
about 2): you can add an item to the controlbar like in this example http://codepen.io/fdambrosio/pen/XRpBvW but I think that adding 4 or 5 more items does not fit well into the default jwplayer controlbar, because in mobile/small size the controlbar is minimal and jwplayer shows items with different style thank desktop.
HTML:
<body>
<div id='radioplayer'></div>
</body>
CSS:
#change-speed {font-size: 16px; color: white; padding-left: 5px; margin-right: 5px;}
JS:
var playerInstance = jwplayer("radioplayer");
playerInstance.setup({
file:'//video.radioradicale.it:1935/store-86/_definst_/mp4:2015/01/MQ781257.mp4/playlist.m3u8',
width:544,
height: 306,
androidhls: true,
autostart: true,
});
var tag;
jwplayer("radioplayer").on('ready', function(){
if (jwplayer("radioplayer").getProvider().name == "html5" | jwplayer("radioplayer").getProvider().name == "shaka") {
console.log('1X');
var normale = document.createElement("div");
normale.id = "change-speed";
normale.setAttribute('class','jw-reset jw-text jw-icon-inline');
normale.innerHTML = "1x";
document.getElementsByClassName('jw-controlbar-right-group')[0].appendChild(normale);
tag = document.querySelector('video');
tag.defaultPlaybackRate = 1.0;
tag.playbackRate = 1.0;
$('#change-speed').on('click', function() {
console.log('test');
speed_bfr = tag.playbackRate;
console.log(speed_bfr, 'prima');
switch(speed_bfr) {
case 1.0:
console.log('1.0');
normale.innerHTML = "1.5x";
tag.playbackRate = 1.5;
break;
case 1.5:
console.log('1.5');
normale.innerHTML = "1x";
tag.playbackRate = 1.0;
break;
}
});
}
});
You can also add only one button (ex. download) over poster image, as described here: https://developer.jwplayer.com/jw-player/demos/basic/add-download-button/
Otherwise you can develop your custom controlbar, or adding buttons near the player, using JwPlayer API: https://developer.jwplayer.com/jw-player/docs/javascript-api-reference/
I am having two problems with KOgrid.
1) I could not get scroll bars in the kogrid .It is very difficult to do data entry without scroll bars.
2) I also could not get kogrid to working wihout specifying hard coded height and width.In my application I can not have a fixed height and width.
Did anybody else had the same issue ?
I tried a workaround suggestion from this thread ( using jQuery fix as last line in my viewmodel).
KO Grid Display Isseues, On resize Gird shows one row. Images also included
that just increased that size of the grid but it did not display any data . However, when I resize the page data shows up.
Below are my HTML and kogrid options ( I tried with and without paging options, Ideally I do not want to use paging )
<div data-bind="koGrid: gridOptions"
style="height: 800px; background-color: none;width: 1850px;">
</div>
self.gridOptions = {
data: self.mydatarray,
footerVisible: true,
displaySelectionCheckbox: true,
afterSelectionChange: self.RowSelectionChange,
rowHeight: 50,
selectWithCheckboxOnly: true,
enableSorting: false,
multiSelect: true,
selectedItems: self.SelectedRows,
enableColumnResize: true,
showFilter: false,
canSelectRows: true,
enablePaging: true,
pagingOptions: {
currentPage: ko.observable(1),
pageSize: ko.observable(3),
pageSizes: ko.observableArray([3, 6, 9])
},
rowTemplate: errrowtmpl,
columnDefs: [
{ field: 'Customer', displayName: 'Customer', cellTemplate: Customersddedittmpl, headerCellTemplate: headercelltmpl },
...
...
{ field: 'GenNotes', displayName: 'GenNotes', cellTemplate: simpleedittmpl, headerCellTemplate: headercelltmpl }
]
}
Please let me know if you need any more information
Thanks
Kenner Dev
I found a solution to the problems I am facing.
1) I used Jquery to add scroll bar. I added code line below as last line of my data loading function. I am not sure id this breaks any other KOGrid functionality.In my application I did some basic testing and it seems to be working fine.
$("div.kgViewport").css("overflow", "scroll");
2) I still dont know how to solve this problem 100%. It still does not work unless fixed width and height are mentioned in style. In my app I used vw and vh as opposed fixed width and height to solve the problem of making it work on all screen sizes.
<div data-bind="koGrid: gridOptions"
style="height: 73vh;overflow:scroll;width: 96vw;"></div>
I have an iggrid that is using a JSON data source for the main grid data and the combo box in one of my fields.
I have created the grid and the combo and the data is there. When I change the combo value and commit the grid the main grid column value does not change. I can see this by assigning a default value to the column and then changing it via a combo box.
I am working off of this example.
http://www.infragistics.com/products/jquery/sample/combo-box/grid-editor
Combo Data
occCodeData = [
{ "ID": "0", "OccCode": "Food" },
{ "ID": "1", "OccCode": "Beverages" },
{ "ID": "2", "OccCode": "Electronics" },
{ "ID": "3", "OccCode": "Cookies" }
];
My grid data is stored in a JSON variable in javascript pulled from a web api. I have verified the data is valid using a console write.
Does anyone have this working with standard JSON, JS, and HTML? This main issue is when I change the combo value it does not update my JSON data behind the scenes. The GUI grid changes fine.
When you have editing in the grid, by default the autoCommit option is set to false (meaning the UI updates but the values are not committed to the data source). You can change this to true in order to automatically commit to the data:
//Initialize
$(".selector").igGrid({
autoCommit : true
});
//Get
var commit = $(".selector").igGrid("option", "autoCommit");
Or you can call the commit method manually:
$(".selector").igGrid("commit");
I figured it out. My Sample occCodeData data did not match my current value.
So my default value pulled from the database was 129 but my possible values were 0,1,2,3. This was causing the combo not to change the value because it did not have a match in it's own listing.