Creates a new detector with the contents of a zip file. The root folder should contain only directories which will become the labels for detection. Each of these directories should contain only a images corresponding to that label. Zip file structure example:

cat/garfield.jpgnermal.pngdog/odie.tiff

Parameters:

zip_file(String)
—

Path to zip file containing the images to be used in the detector creation

# File 'lib/matroid/detector.rb', line 105defself.create(zip_file,name,detector_type='general')casezip_filewhenStringfile=File.new(zip_file,'rb')whenFilefile=zip_fileelseerr_msg='First argument must be a zip file of the image folders, or a string of the path to the file'raiseError::InvalidQueryError.new(err_msg)endparams={file:file,name:name,detector_type:detector_type}response=Matroid.post('detectors',params)id=response['detector_id']find_by_id(id)end

# File 'lib/matroid/detector.rb', line 36defself.find(args)raiseError::InvalidQueryError.new('Argument must be a hash.')unlessargs.class==Hashquery=args.keys.map{|key|key.to_s+'='+args[key].to_s}.join('&')detectors=Matroid.get('detectors/search?'+query)detectors.map{|params|register(params)}end

# File 'lib/matroid/detector.rb', line 229defclassify_image_files(file_paths)arg_err="Error: Argument must be an array of image file paths"size_err="Error: Total batch size must be under #{BATCH_FILE_SIZE_LIMIT/1024/1024}MB"raisearg_errunlessfile_paths.is_a?(Array)batch_size=file_paths.inject(0){|sum,file|sum+File.size(file)}raisesize_errunlessbatch_size<BATCH_FILE_SIZE_LIMITfiles=file_paths.map{|file_path|['file',File.new(file_path,'rb')]}url="#{Matroid.base_api_uri}detectors/#{@id}/classify_image"client=HTTPClient.newresponse=client.post(url,body:files,header:{'Authorization'=>Matroid.token.authorization_header})Matroid.parse_response(response)# Matroid.post("detectors/#{@id}/classify_image", files) # responds with 'request entity too large' for some reason
end