Program 3. /usr/local/bin/calculate-consensus -i $image_id
1. Begins a transaction
Checks that images_received.worker_answers_fetched = true and images_received.workers_evaluated = false.
(this is done using a select ... for update)
There will be a number of distinct mturk workers (distinguished by mturk_worker_id) in the human_reported_mirrorless_images
and the human_reported_mirror_positions tables for this image_id.
For each pair of mturk workers (for each image), calculate-consensus creates a row in the `worker_evaluation` table.
worker1_only_pixel_count is set to width * height from human_reported_mirror_positions, or zero if that worker said
it should be in human_reported_mirrorless_images. Similarly for worker2_only_pixel_count.
Intersection_pixels is a count of the number pixels that they both agree are part of the image, which will be zero
if either worker said the image was mirrorless
Agreement is true if intersection_pixels > 0.8 * worker1_only_pixel_count and
intersection_pixels > 0.8 * worker2_only_pixel_count
It is possible that a record might already exist in the
worker_evaluation table because we might have had to retry a job to
get more consensus, however, any existing record should still be
3. Consensus is reached if there is a worker who has agreement with 50% or more of other workers.
4. If consensus was reached, then run "delete from non_consensus_images where image_id = $image_id"
5. If consensus was reached, then a record is created in either
consensus_mirror_positions or consensus_mirrorless (whichever makes
sense). If it consensus_mirror_positions is being populated, then
top_edge, left_edge, bottom_edge, etc. are the intersection of all the
worker_evaluations where agreement is true.
6. If consensus was reached, the workers who were in agreement with at least one other worker
get `believable` set to true in `human_reported_mirrorless_images` and/or `human_reported_mirror_positions` .
If consensus was reached and there's a worker who was in agreement with no other worker, they get
`believable` set to false.
If there was no consensus, then believable stays NULL.
7. If there was no consensus, then a record is created in non_consensus_images
8. update images_received set workers_evaluated = true, workers_evaluation_timestamp = timenow where image_id = $image_id
9 If there was consensus then
update images_received set consensus_created = true, consensus_creation_time = timenow where image_id = $image_id
10. Commit the transaction
11. If there was consensus trigger a postgresql "NOTIFY consensus, $image_id".
If there wasn't trigger "NOTIFY nonconsensus, $image_id"
Looks like a straightforward project; I love how much detail this description has. I've built tons of master-worker systems before, so you can expect quality. I write clean, readable, easy to maintain code -- not th Daha Fazla
Bu iş için 9 freelancer ortalamada $758 teklif veriyor
Hello. I am an experienced Go dev who can create your calculate-consensus script that will do the consensus calculation Postgres transaction as you have described. Please contact me for further discussion.
Hello, I read carefully about your project. I want to know how you can test the result. I am an expert in golang and linux. I hope to discuss more detail with you by chatting. Best regards.