public static void CreateDemoJob_SINGLE_OBJECT_LABLING() { SatyamJob job = new SatyamJob(); Console.WriteLine("here 1"); AzureInformation AzureInfo = new AzureInformation(); AzureInfo.AzureBlobStorageConnectionString = SatyamJobStorageAccountAccess.connection_string; AzureInfo.AzureBlobStorageContainerName = "demo"; AzureInfo.AzureBlobStorageContainerDirectoryName = "testSingleObjectLabelingImages"; AmazonMTurkHITInformation AmazonInfo = new AmazonMTurkHITInformation(); SingleObjectLabelingSubmittedJob template = new SingleObjectLabelingSubmittedJob(); List <string> categories = new List <string>() { "Car", "Bus" }; template.Categories = categories; template.Description = "Car: Includes SUV's, Vans with upto 6 passengers, Jeeps and Pickcups. Click <a href=\"http://satyamtaskpages.azurewebsites.net/CategoryExamplesPageForDemo.aspx\"> here</a> to see examples of the various categories."; job.JobGUIDString = "SINGLE_OBJECT_LABLING_DEMO"; job.amazonHITInformation = AmazonInfo; job.azureInformation = AzureInfo; job.JobSubmitTime = DateTime.Now; job.JobTemplateType = "SINGLE_OBJECT_LABLING_DEMO"; job.UserID = TaskConstants.AdminName; job.JobParameters = JSonUtils.ConvertObjectToJSon <SingleObjectLabelingSubmittedJob>(template); string JobParametersString = JSonUtils.ConvertObjectToJSon <SatyamJob>(job); SatyamJobSubmissionsTableAccess jobDB = new SatyamJobSubmissionsTableAccess(); jobDB.AddEntry(job.JobTemplateType, job.UserID, job.JobGUIDString, JobParametersString, job.JobSubmitTime); jobDB.close(); }
private bool getNewRandomJob() { SatyamTaskTableAccess taskTableDB = new SatyamTaskTableAccess(); SatyamTaskTableEntry entry = taskTableDB.getMinimumTriedEntryByTemplate(TaskConstants.Classification_Image); if (entry != null) { taskTableDB.IncrementDoneScore(entry.ID); SatyamTask task = JSonUtils.ConvertJSonToObject <SatyamTask>(entry.TaskParametersString); string uri = task.SatyamURI; DisplayImage.ImageUrl = uri; SatyamJob jobDefinitionEntry = task.jobEntry; SingleObjectLabelingSubmittedJob job = JSonUtils.ConvertJSonToObject <SingleObjectLabelingSubmittedJob>(jobDefinitionEntry.JobParameters); List <string> categories = job.Categories; CategorySelection_RadioButtonList.Items.Clear(); for (int i = 0; i < categories.Count; i++) { ListItem l = new ListItem(categories[i]); CategorySelection_RadioButtonList.Items.Add(l); } if (job.Description != "") { DescriptionPanel.Visible = true; DescriptionTextPanel.Controls.Add(new LiteralControl(job.Description)); //DescriptionLabel.Text = job.Description; } Hidden_TaskEntryString.Value = JSonUtils.ConvertObjectToJSon <SatyamTaskTableEntry>(entry); Hidden_PageLoadTime.Value = DateTime.Now.ToString(); taskTableDB.close(); return(true); } else { taskTableDB.close(); return(false); } }
public static void CreateDemoJob_SINGLE_OBJECT_LABLING_IN_VIDEO() { SatyamJob job = new SatyamJob(); AzureInformation AzureInfo = new AzureInformation(); AzureInfo.AzureBlobStorageConnectionString = SatyamJobStorageAccountAccess.connection_string; AzureInfo.AzureBlobStorageContainerName = "demo"; AzureInfo.AzureBlobStorageContainerDirectoryName = "TestVideoClassificationMP4"; AmazonMTurkHITInformation AmazonInfo = new AmazonMTurkHITInformation(); SingleObjectLabelingSubmittedJob template = new SingleObjectLabelingSubmittedJob(); List <string> categories = new List <string>() { "Biking", "HorseRiding", "SkateBoarding" }; template.Categories = categories; template.Description = ""; job.JobGUIDString = "SINGLE_OBJECT_LABLING_IN_VIDEO_DEMO"; job.amazonHITInformation = AmazonInfo; job.azureInformation = AzureInfo; job.JobSubmitTime = DateTime.Now; job.JobTemplateType = "SINGLE_OBJECT_LABLING_IN_VIDEO_DEMO"; job.UserID = TaskConstants.AdminName; job.JobParameters = JSonUtils.ConvertObjectToJSon <SingleObjectLabelingSubmittedJob>(template); string JobParametersString = JSonUtils.ConvertObjectToJSon <SatyamJob>(job); SatyamJobSubmissionsTableAccess jobDB = new SatyamJobSubmissionsTableAccess(); jobDB.AddEntry(job.JobTemplateType, job.UserID, job.JobGUIDString, JobParametersString, job.JobSubmitTime); jobDB.close(); }
public static bool ProcessAndUploadToAzureBlob(SatyamJobSubmissionsTableAccessEntry jobEntry) { // Assumpltion: the input is a folder videos, convert to mp4, and upload to satyam blob SatyamJobStorageAccountAccess satyamStorage = new SatyamJobStorageAccountAccess(); string satyamContainerName = SatyamTaskGenerator.JobTemplateToSatyamContainerNameMap[jobEntry.JobTemplateType]; string GUID = jobEntry.JobGUID; string satyamDirectoryName = GUID; SatyamJob job = JSonUtils.ConvertJSonToObject <SatyamJob>(jobEntry.JobParametersString); SingleObjectLabelingSubmittedJob jobParams = JSonUtils.ConvertJSonToObject <SingleObjectLabelingSubmittedJob>(job.JobParameters); BlobContainerManager bcm = new BlobContainerManager(); string status = bcm.Connect(job.azureInformation.AzureBlobStorageConnectionString); List <string> FileTypes = SatyamTaskGenerator.ValidFileTypesByTemplate[job.JobTemplateType]; if (status != "SUCCESS") { return(false); } string guidFolder = DirectoryConstants.defaultTempDirectory + "\\" + GUID; Directory.CreateDirectory(guidFolder); //var client = new WebClient(); List <string> videoUrls = bcm.getURLList(job.azureInformation.AzureBlobStorageContainerName, job.azureInformation.AzureBlobStorageContainerDirectoryName); foreach (string video in videoUrls) { FFMpegWrappers.ConvertVideoURLToMP4(DirectoryConstants.ffmpeg, video, guidFolder); } satyamStorage.uploadALocalFolder(guidFolder, satyamContainerName, satyamDirectoryName); return(true); }
protected void JobSubmitButton_Click(object sender, EventArgs e) { string AzureBlobStorageConnectionString = AzureBlobStorageConnectionStringTextBox.Text; string AzureContainer = AzureBlobStorageContainerNameTextBox.Text; string AzureContainerDirectory = AzureBlobStorageContainerDirectoryNameTextBox.Text; string AmazonAccessKeyIDValue = AmazonAccessKeyID.Text; string AmazonSecretAccessKeyIDValue = AmazonSecretAccessKeyID.Text; string Description = CategoryDescription.Text; double pricePerImage = 0; double price = 0; string jobGuid = NewJobGUID.Text; string AmazonTaskTitle = AmazonTaskTitleTextBox.Text; string AmazonTaskDescription = AmazonTaskDescriptionTextBox.Text; string AmazonTaskKeywords = AmazonTaskKeywordsTextBox.Text; if (AzureBlobStorageConnectionString == "" || AzureContainer == "") { Template_ErrorMessageLabel.Text = "Error : Azure Connection String and Container are mandatory fields."; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } AzureConnectionInfo connectionInfo = new AzureConnectionInfo(AzureBlobStorageConnectionString, AzureContainer, AzureContainerDirectory); int noFiles = connectionInfo.getNoFiles(); if (noFiles == -1) { Template_ErrorMessageLabel.Text = "Error : Invalid Azure Location"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } else if (noFiles == 0) { Template_ErrorMessageLabel.Text = "Error : There are 0 files at the Azure Location"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } if (Hidden_MechanicalTurk.Value == "true") { bool success = Double.TryParse(PriceTextBox.Text, out pricePerImage); if (!success) { Template_ErrorMessageLabel.Text = "Error : Non-numerical price entered"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } pricePerImage = pricePerImage / 100; //convert to dollars price = pricePerImage; //need to round to cents price = Math.Floor(price * 100) / 100; if (price <= 0) { Template_ErrorMessageLabel.Text = "Error : The Price is Zero"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } AmazonMTurkHIT hit = new AmazonMTurkHIT(); success = hit.setAccount(AmazonAccessKeyIDValue, AmazonSecretAccessKeyIDValue, false); if (!success) { Template_ErrorMessageLabel.Text = "Error : Invalid Amazon Turk Account"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } double balance = hit.getAccountBalance(); if (balance < 0) { Template_ErrorMessageLabel.Text = "Error : Invalid Amazon Turk Account"; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } double moneyNeeded = 4 * price * noFiles / TaskConstants.SINGLE_OBJECT_LABLING_MTURK_MAX_IMAGES_PER_TASK; if (balance < moneyNeeded) { Template_ErrorMessageLabel.Text = "Error : Insufficient money in Amazon Turk Account. You will need at least " + moneyNeeded + "$."; Template_ErrorMessageLabel.ForeColor = System.Drawing.Color.Red; Template_ErrorMessageLabel.Font.Bold = true; return; } if (AmazonTaskTitle == "") { Template_ErrorMessageLabel.Text = "Image Classification Task"; } if (AmazonTaskTitle == "") { Template_ErrorMessageLabel.Text = "Quickly earn money by simply selecting what an image looks like!"; } if (AmazonTaskKeywords == "Pictures, Classify, Categorize") { Template_ErrorMessageLabel.Text = ""; } } AzureInformation AzureInfo = new AzureInformation(); AzureInfo.AzureBlobStorageConnectionString = AzureBlobStorageConnectionString; AzureInfo.AzureBlobStorageContainerName = AzureContainer; AzureInfo.AzureBlobStorageContainerDirectoryName = AzureContainerDirectory; AmazonMTurkHITInformation AmazonInfo = new AmazonMTurkHITInformation(); if (Hidden_MechanicalTurk.Value == "true") { AmazonInfo.AmazonAccessKeyID = AmazonAccessKeyIDValue; AmazonInfo.AmazonSecretAccessKeyID = AmazonSecretAccessKeyIDValue; AmazonInfo.Price = price; //in dollars AmazonInfo.AmazonMTurkTaskTitle = AmazonTaskTitle; AmazonInfo.AmazonMTurkTaskDescription = AmazonTaskDescription; AmazonInfo.AmazonMTurkTaskKeywords = AmazonTaskKeywords; } else { AmazonInfo.AmazonAccessKeyID = ""; AmazonInfo.AmazonSecretAccessKeyID = ""; AmazonInfo.Price = 0; AmazonInfo.AmazonMTurkTaskTitle = ""; AmazonInfo.AmazonMTurkTaskDescription = ""; AmazonInfo.AmazonMTurkTaskKeywords = ""; } SingleObjectLabelingSubmittedJob jobParameters = new SingleObjectLabelingSubmittedJob(); jobParameters.Description = Description; SatyamJob job = new SatyamJob(); job.UserID = userName; job.amazonHITInformation = AmazonInfo; job.azureInformation = AzureInfo; job.JobGUIDString = jobGuid; if (Hidden_MechanicalTurk.Value == "true") { job.JobTemplateType = TaskConstants.CameraPoseEsitmation_MTurk; job.TasksPerJob = 1; } else { job.JobTemplateType = TaskConstants.CameraPoseEsitmation; job.TasksPerJob = 0; //does not matter } job.JobSubmitTime = DateTime.Now; job.JobParameters = JSonUtils.ConvertObjectToJSon <SingleObjectLabelingSubmittedJob>(jobParameters); string jobDefinition = JSonUtils.ConvertObjectToJSon <SatyamJob>(job); SatyamJobSubmissionsTableAccess dbAccess = new SatyamJobSubmissionsTableAccess(); dbAccess.AddEntry(job.JobTemplateType, job.UserID, job.JobGUIDString, jobDefinition, job.JobSubmitTime); dbAccess.close(); Response.Redirect("NewJobSubmitted.aspx"); }
private bool getNewRandomJob() { double price = 0; bool success = Double.TryParse(Hidden_Price.Value, out price); if (!success) { price = 0; } SatyamTaskTableAccess taskTableDB = new SatyamTaskTableAccess(); SatyamTaskTableEntry entry = null; if (SubmitButton.Enabled == true) { //entry = taskTableDB.getMinimumTriedEntryByTemplateAndPrice("SINGLE_OBJECT_LABLING_MTURK", price); entry = taskTableDB.getMinimumTriedNewEntryForWorkerIDByTemplateAndPrice(Hidden_AmazonWorkerID.Value, TaskConstants.Classification_Video_MTurk, price); } else { entry = taskTableDB.getMinimumTriedEntryByTemplate(TaskConstants.Classification_Video_MTurk); } if (entry != null) { taskTableDB.IncrementDoneScore(entry.ID); SatyamTask task = JSonUtils.ConvertJSonToObject <SatyamTask>(entry.TaskParametersString); string uri = task.SatyamURI; Hidden_VideoURL.Value = uri; SatyamJob jobDefinitionEntry = task.jobEntry; SingleObjectLabelingSubmittedJob job = JSonUtils.ConvertJSonToObject <SingleObjectLabelingSubmittedJob>(jobDefinitionEntry.JobParameters); List <string> categories = job.Categories; CategorySelection_RadioButtonList.Items.Clear(); for (int i = 0; i < categories.Count; i++) { ListItem l = new ListItem(categories[i]); CategorySelection_RadioButtonList.Items.Add(l); } if (job.Description != "") { DescriptionPanel.Visible = true; DescriptionTextPanel.Controls.Add(new LiteralControl(job.Description)); //DescriptionLabel.Text = job.Description; } Hidden_TasksPerJob.Value = jobDefinitionEntry.TasksPerJob.ToString(); Hidden_TaskEntryString.Value = JSonUtils.ConvertObjectToJSon <SatyamTaskTableEntry>(entry); Hidden_PageLoadTime.Value = DateTime.Now.ToString(); NoLabeled.Text = Hidden_NoImagesDone.Value; taskTableDB.close(); return(true); } else { taskTableDB.close(); return(false); } }