def prepareBatch(self):
	print "mturkLayoutID", self.amusic.conf['mturkLayoutID']
        if not self.amusic.conf['mturkLayoutID']:
            print "LayoutID not set"
            return
        l = [i[0] for i in self.amusic.engine.execute('SELECT title FROM song WHERE population="%s";'%(self.title)).fetchall()]
        for d,i in enumerate(l):
            print 'Song %d/%d (%s)'%(d+1,len(l),i)
            s = Song(self,i)
            s.fromDB()
            s.synth(i+'.mp3' if i.find('.')==-1 else i[:i.find('.')]+'.mp3',upload=True)
        print "Creating HITs..."
        print "host:", self.amusic.mtc.host
        s = "http://%s.s3.amazonaws.com/tracks/" % (self.amusic.conf['bucket'])
        n=1
        for d,i in enumerate(l):
            for j in l[d+1:]:
                f1 = i+'.mp3' if i.find('.')==-1 else i[:i.find('.')]+'.mp3'
                f2 = j+'.mp3' if j.find('.')==-1 else j[:j.find('.')]+'.mp3'
                print "\tHIT %d/%d (%s,%s)" % (n,len(l)*(len(l)-1)/2,f1,f2)
                params = LayoutParameters()
                params.add(LayoutParameter('file1',s+f1))
                params.add(LayoutParameter('file2',s+f2))
                self.amusic.mtc.create_hit(hit_layout=self.amusic.conf['mturkLayoutID'],layout_params=params,reward=self.amusic.conf['hitRewardPerAssignment'],title=self.amusic.conf['hitTitle'],description=self.amusic.conf['hitDescription'],keywords=self.amusic.conf['hitKeywords'])
                n+=1
Exemple #2
0
    def prepareBatch(self):
	print "mturkLayoutID", self.amusic.conf['mturkLayoutID']
        if not self.amusic.conf['mturkLayoutID']:
            print "LayoutID not set"
            return
        l = [i[0] for i in self.amusic.engine.execute('SELECT title FROM song WHERE population="%s";'%(self.title)).fetchall()]
        for d,i in enumerate(l):
            print 'Song %d/%d (%s)'%(d+1,len(l),i)
            s = Song(self,i)
            s.fromDB()
            s.synth(i+'.mp3' if i.find('.')==-1 else i[:i.find('.')]+'.mp3',upload=True)
        print "Creating HITs..."
        print "host:", self.amusic.mtc.host
        s = "http://%s.s3.amazonaws.com/tracks/" % (self.amusic.conf['bucket'])
        n=1
        for d,i in enumerate(l):
            for j in l[d+1:]:
                f1 = i+'.mp3' if i.find('.')==-1 else i[:i.find('.')]+'.mp3'
                f2 = j+'.mp3' if j.find('.')==-1 else j[:j.find('.')]+'.mp3'
                print "\tHIT %d/%d (%s,%s)" % (n,len(l)*(len(l)-1)/2,f1,f2)
                params = LayoutParameters()
                params.add(LayoutParameter('file1',s+f1))
                params.add(LayoutParameter('file2',s+f2))
                #self.amusic.mtc.create_hit(hit_layout=self.amusic.conf['mturkLayoutID'],layout_params=params,reward=self.amusic.conf['hitRewardPerAssignment'],title=self.amusic.conf['hitTitle'],description=self.amusic.conf['hitDescription'],keywords=self.amusic.conf['hitKeywords'],duration=timedelta(minutes=4),lifetime=timedelta(minutes=40))
                self.amusic.mtc.create_hit(hit_layout=self.amusic.conf['mturkLayoutID'],layout_params=params,reward=0.03,title=self.amusic.conf['hitTitle'],description=self.amusic.conf['hitDescription'],keywords=self.amusic.conf['hitKeywords'],duration=timedelta(minutes=4),lifetime=timedelta(minutes=40))
                n+=1
Exemple #3
0
 def prepareBatch(self):
     if not self.amusic.conf['mturkLayoutID']:
         print "LayoutID not set"
         return
     l = [i[0] for i in self.amusic.engine.execute('SELECT title FROM song WHERE population="%s";'%(self.title)).fetchall()]
     for d,i in enumerate(l):
         print 'Song %d/%d (%s)'%(d+1,len(l),i)
         s = Song(self,i)
         s.fromDB()
         s.synth(i+'.mp3' if i.find('.')==-1 else i[:i.find('.')]+'.mp3',upload=True)
     print "Creating HITs..."
     hostName = 'mechanicalturk.amazonaws.com'
     #hostName = 'mechanicalturk.sandbox.amazonaws.com'
     mtc = MTurkConnection(self.amusic.ACCESS_ID,self.amusic.SECRET_KEY,host=hostName)#,debug=5)
     print "host:", hostName
     s = "http://%s.s3.amazonaws.com/tracks/" % (self.amusic.conf['bucket'])
     n=1
     for d,i in enumerate(l):
         for j in l[d+1:]:
             f1 = i+'.mp3' if i.find('.')==-1 else i[:i.find('.')]+'.mp3'
             f2 = j+'.mp3' if j.find('.')==-1 else j[:j.find('.')]+'.mp3'
             print "\tHIT %d/%d (%s,%s)" % (n,len(l)*(len(l)-1)/2,f1,f2)
             params = LayoutParameters()
             params.add(LayoutParameter('file1',s+f1))
             params.add(LayoutParameter('file2',s+f2))
             mtc.create_hit(hit_layout=self.amusic.conf['mturkLayoutID'],layout_params=params,reward=self.amusic.conf['hitRewardPerAssignment'],title=self.amusic.conf['hitTitle'],description=self.amusic.conf['hitDescription'],keywords=self.amusic.conf['hitKeywords'])
             n+=1
Exemple #4
0
from boto.mturk.connection import MTurkConnection
from boto.mturk.question import HTMLQuestion
from boto.mturk.layoutparam import LayoutParameter
from boto.mturk.layoutparam import LayoutParameters

hit_url_file = open("hit-url.list", "w")
hit_id_file = open("hit-id.list", "a")
img_list = [
    line.rstrip("\n") for line in open("C:/Users/David/autoturk/image.list")
]
num_img = len(img_list)
for i in range(num_img):
    img_src = "https://s3.us-east-2.amazonaws.com/drone-net/" + img_list[i]
    mtc = MTurkConnection(aws_access_key_id="[Your_access_key_ID]",
                          aws_secret_access_key="[Your_secret_access_key]",
                          host="mechanicalturk.amazonaws.com")
    image_url = LayoutParameter("image_url", img_src)
    obj_to_find = LayoutParameter("objects_to_find", "drone")
    params = LayoutParameters([image_url, obj_to_find])
    response = mtc.create_hit(hit_layout="[Your_hit_layout]",
                              layout_params=params,
                              hit_type="[Your_hit_type]")
    hit_type_id = response[0].HITTypeId
    hit_id = response[0].HITId
    hit_id_file.write(hit_id + "\n")
    print("HIT ID: {}".format(hit_id))
hit_url_file.write("https://www.mturk.com/mturk/preview?groupId=" +
                   hit_type_id + "\n")
print("HIT URL: https://www.mturk.com/mturk/preview?groupId={}".format(
    hit_type_id))
Exemple #5
0
def createHIT(parameter, max_assignments=1):

    quals = Qualifications();
    quals.add(PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo", "97"))
    quals.add(NumberHitsApprovedRequirement("GreaterThanOrEqualTo", "100"))

    if not(useSandbox):
        #quals.add(Requirement("2VNUKQOYGNIW2Y6UN6R177SVGBOZHD", "GreaterThanOrEqualTo", "24"))
        #quals.add(Requirement("26C2D21O3W5XIBXBOI92RYEPLVQ9FH", "GreaterThanOrEqualTo", "24"))
        quals.add(Requirement("22V6DG67D1X3WBT6Z2FK9JE1MAQ9GG", "GreaterThanOrEqualTo", "25"))

    #f1 = 'hello1.txt'
    #f2 = 'hello2.txt'
    params = LayoutParameters()
    params.add(LayoutParameter('image1', parameter))
    #params.add(LayoutParameter('file2',f2))
    #print "creating HIT"
    retryDelay = 400
    print "mtc create hit"
    hitWasCreated = False
    for repeat in range(0, 20):
        print "repeat", repeat
        try:
        #if 1:
            print "creating hit"
            resultSet = mtc.create_hit(hit_layout=ZProcessLayoutID,
                                       layout_params=params,
                                       reward=0.01,
                                       title="Does the dot stay inside the cell",
                                       description="Does the dot stay inside the cell",
                                       keywords="image, tag",
                                       duration=timedelta(minutes=2),
                                       lifetime=timedelta(minutes=60*48),
                                       qualifications=quals,
                                       max_assignments=max_assignments)
            hitWasCreated = True
            break
        except Exception:
            traceback.print_exc()
            #if repeat == 19: raise Exception("messed up")
            print "mechanical turk failed to create HIT, trying again in %d seconds" % retryDelay
            time.sleep(retryDelay)
        except:
            traceback.print_exc()
            #if repeat == 19: raise Exception("messed up")
            print "mechanical turk failed to create HIT, trying again in %d seconds" % retryDelay
            time.sleep(retryDelay)
        else:
            traceback.print_exc()
            #if repeat == 19: raise Exception("messed up")
            print "mechanical turk failed to create HIT, trying again in %d seconds" % retryDelay
            time.sleep(retryDelay)

    if not hitWasCreated:
        # do this to generate the error message
        resultSet = mtc.create_hit(hit_layout=ZProcessLayoutID,
                                   layout_params=params,
                                   reward=0.01,
                                   title="Does the dot stay inside the cell",
                                   description="Does the dot stay inside the cell",
                                   keywords="image, tag",
                                   duration=timedelta(minutes=1),
                                   lifetime=timedelta(minutes=40),
                                   qualifications=quals,
                                   max_assignments=max_assignments)
        sys.exit(1)



    print "mtc create hit finished"
    return resultSet
Exemple #6
0
 def get_boto_layout_params(self):
   params = LayoutParameters()
   for k, v in self.layout_params.items():
     params.add(LayoutParameter(k, v))
   return params