How to use det method in wpt

Best JavaScript code snippet using wpt

dBox.js

Source:dBox.js Github

copy

Full Screen

1var Core = require('./Core.js').Core;2var dBox = function(opt) {3 var nArgs = opt ? opt : {};4 Core.call(this, nArgs);5 this.drawn = false;6}7dBox.prototype = Object.create(Core.prototype);8dBox.prototype.constructor = dBox;9dBox.prototype.toggleSubmissionButtonState = function (){10 //this function disable the button edition and request if select doesn't exist in the DOM11 var elems = $(this.getNode()).find('select');12 if ( $(this.getNode()).find('select').length == 0 ) {13 $(this.getNode()).find('.buttonEdition,.buttonRequest').addClass('disabled');14 }15 else {16 $(this.getNode()).find('.buttonEdition,.buttonRequest').removeClass('disabled');17 }18};19dBox.prototype.animationBox = function(){20 var self = this;21 console.log("bouge cette boite");22 $(this.getNode()).animate({23 //position: absolute,24 top: "100",25 }, 1500, function() {26 //console.dir(self);27 self.emiter.emit("moved");28 console.log("boite a terminé de bouger");29 $(self.getNode()).css('top', 0);30 // $(self.getNode()).offset({ top : 320 });31 });32}33dBox.prototype.validationAndListDet = function(){34 //this function test the field input.dNumber and save each detname and qt in detListToServer35 var self = this;36 self.detList = [];37 var validateField = true;38 var re = /^[0-9]+$/; // only integer allowed39 $(self.getNode()).find('select').parent().each(function(){40 var qt = $(this).find('input.dNumber').val();41 if(qt===""){42 console.log("empty field");43 validateField = false;44 $(this).find(" .dNumber").addClass("error");45 } else if (! re.test(qt)) {46 validateField = false;47 $(this).find(" .dNumber").addClass("error");48 } else if(parseFloat(qt) < 1){49 $(this).find(" .dNumber").addClass("error");50 validateField = false;51 }52 var name = $(this).find("option:selected").text();53 self.detList.push({ "detName" : name, "qt" : qt });54 });55 return validateField;56}57dBox.prototype.drawEmptySectionAndButton = function(dbDetAvailable) {58 //create the DOM of deterBox59 var self = this;60 $(this.getNode()).61 append(62 '<div class="DeterSubmitDiv">'63 + '<h3>Choose your detergent set</h3>'64 + '<div class="enterDet"></div>'65 + '<div class="buttonNew"></div>'66 + '</div>');67 $(this.getNode()).find(".buttonNew").append('<button type="button" class="btn btn-primary btn-sm newDet">Add a new detergent</button><span class="abbreviations pull-right"><a href="assets/abbreviations.pdf" target="_blank">abbreviations</a></span>');68 this.emiter.emit('display');69 $(this.getNode()).find(".newDet").click(function(){ // if we click on the newDet button70 if (self.availableDetNumber() == 0) return;71 self.drawSelectDet(dbDetAvailable);72 self.drawButtonRequest();73 self.toggleSubmissionButtonState();74 });75}76dBox.prototype.availableDetNumber = function () {77 var l = 0;78 for (var k in this.availableDet) {79 l += this.availableDet[k].length;80 }81 return l;82}83dBox.prototype.drawButtonRequest = function(){84 //draw button request + ppmBox and assign event for click and check85 var self = this;86 this.PPMBoxTag = 'PPMBox_' + self.idNum;87 if( ($(".buttonRequest").length) || (this.modeEdition===true) ) return;88 $(this.getNode()).find('.DeterSubmitDiv').append('<div class="buttonGo"></div>');89 $(this.getNode()).find(".buttonGo")90 .append('<button type="button" class="btn btn-success buttonRequest">Visualize detergent belt</button>'91 +'<div class="ppmCheckBoxDiv"><input type="checkbox" id="' + self.PPMBoxTag + '">'92 +'<label style="padding-left: 0.5em;" for="' + self.PPMBoxTag + '"> PDB file was processed by <a href="http://opm.phar.umich.edu/server.php">PPM server</a> </label></div>'93 +'<div class=note>(faster as it requires less calculation) </div> '94 );95 $(this.getNode()).find("div.ppmCheckBoxDiv input").prop('checked', true);96 $(this.getNode()).find("div.ppmCheckBoxDiv input").attr("disabled", true);97 $(this.getNode()).find(".buttonRequest").click(function(event){98 if ( $(self.getNode()).find('select').length == 0 ) return;99 var validQt = self.validationAndListDet(); // detergent quantity100 if (!validQt) return false;101 if(document.getElementById(self.PPMBoxTag).checked){ self.requestPPM = false }102 else { self.requestPPM = true }103 $(self.getNode()).find(".ppmCheckBoxDiv").remove();104 $(self.getNode()).find(".note").remove();105 // Disable submission and click when user send request106 $(this).addClass('disabled');107 $(this).off("click");108 $(self.getNode()).find('.newDet').addClass('disabled');109 self.emiter.emit("submit", self.requestPPM , self.detList);110 });111}112dBox.prototype.dataTransfert = function(data){113 //when the server send the reponse send event result and draw buttonEdition and buttonRefresh114 //data is the var containing the reponse of the server115 var self = this;116 console.log("données corona transférées : " );117 console.dir(data.data);118 var pdbText = data.fileContent;119 this.coronaData = data.data;120 self.modeEdition = true;121 self.emiter.emit("result", pdbText, this.coronaData, self.detList);122 console.log("a émis result");123 $(self.getNode()).find(".buttonRequest").remove();124 $(self.getNode()).find('.ppmCheckBoxDiv').remove();125 $(self.getNode()).find(".buttonGo").append('<button type="button" class="btn btn-success btn-sm buttonEdition">Recompute the belt</button>');126 $(self.getNode()).find(".buttonGo").append('<button type="button" class="btn btn-warning btn-sm buttonRefresh">Try another protein</button>');127 $(self.getNode()).find(".newDet").removeClass('disabled = true');128 $(self.getNode()).find(".buttonEdition").click(function(){129 if ( $(self.getNode()).find('select').length == 0 ) {130 return;131 }132 var validQt = self.validationAndListDet();133 if (!validQt) return false;134 self.emiter.emit("edition", self.detList);135 console.log("a émis edition");136 });137 $(self.getNode()).find(".buttonRefresh").click(function(){138 window.location.reload();139 });140}141dBox.prototype.mapper = function(opt) {142 if (opt.hasOwnProperty('detergent')) {143 for (var category in this.detergentRefLitt)144 for (var deterDatum in this.detergentRefDict[category])145 if (deterDatum.name === opt.detergent) return category;146 }147};148dBox.prototype.display = function(jsonFile,dbDetAvailable) {149 //this function browse the JSONFile and store his data in the variable dataDetergentFromJson.150 //create the variable availableData151 if (this.drawn) return;152 var self = this;153 this.boxNumber = 0;154 this.availableDet = [];155 this.detergentRefLitt = {};156 $.getJSON(jsonFile, function (jsonData) {157 self.dataDetergentFromJson = jsonData.data;158 for (var detCategory in self.dataDetergentFromJson) {159 self.detergentRefLitt[detCategory] = self.dataDetergentFromJson[detCategory].map(function(i){return i.name;});160 }161 /*162 self.detergentRefList = self.dataDetergentFromJson.map(function(e){163 var list = e.map(function(i){return i.name;});164 return { "categoy" : e.name , "detergents" : list };165 });166 */167 self.availableDet = JSON.parse(JSON.stringify(self.detergentRefLitt));168 // return;169 // Initial component graphical state170 self.drawEmptySectionAndButton(dbDetAvailable);171 self.draw = true;172 })173 .fail(function() {174 console.log( "error loading detergent file at " + jsonFile );175 });176}177dBox.prototype.addAvailable = function (detLitt) {178 console.log("addAvailable");179 console.log(detLitt);180 //this function addAvailable (in the object availableDet) the detergent who is giving in argument181 var detExist = false;182 this.availableDet[detLitt.category].forEach(function(e){183 if(e === detLitt.name) detExist = true;184 });185 if(!detExist) this.availableDet[detLitt.category].push(detLitt.name);186 $(this.getNode()).find('select.selDetName')187 .filter(function(){ // Filter selectboxes which lack the added det188 var ok = true;189 $(this).find('option').each(function(){190 if ($(this).attr('value') === detLitt.name) ok = false;191 });192 return ok;193 }).each(function(){194 console.log('Reinjecting in a select');195 if( $(this).find('option').filter(function(){return $(this).text() == detLitt.category; }).length == 0 ) {196 console.log("writing " + detLitt.category);197 $(this).append('<option disabled>' + detLitt.category + '</option>'198 + '<option category="' + detLitt.category + '" value=' + detLitt.name + '>' + detLitt.name + '</option>');199 return;200 }201 console.log("Appending");202 $(this).find('option').filter(function(){ return $(this).text() == detLitt.category; })203 .after('<option category=' + detLitt.category + ' value=' + detLitt.name + '>' + detLitt.name + '</option>');204 });205}206dBox.prototype.delAvailable = function (detLitt, sCategoryPrev) {207 var self = this;208 console.log("delAvailable");209 console.log(detLitt);210 // Remove detergent name from buffer211 var m = this.availableDet[detLitt.category].indexOf(detLitt.name);212 if (m === -1) return;213 this.availableDet[detLitt.category].splice(m, 1);214 // List all category of currently selected detergents215 var currSelCatList = $(this.getNode()).find('select.selDetName option:selected').map(function(){216 return $(this).attr("category"); })217 .get()218 .filter( function(value, index, self) {return self.indexOf(value) === index;});219 console.log("-->"); console.dir(currSelCatList);220 var currSelCatName = detLitt.category;221// detLitt.name .category222// Foreach box remove detergeant mention223// Also removes its category mention if the category is empty224// AND if one of its detergent is not selected in current box225 $(this.getNode()).find('select.selDetName')226 .each(function(){227 var sCategory = $(this).find('option:selected').attr("category");228 // Treating "category" options229 $(this).find('option:disabled').filter( function(i){230 var catName = $(this).text();231 if (sCategoryPrev)232 return self.availableDet[catName].length == 0 && catName !== sCategory && catName !== sCategoryPrev;233 return self.availableDet[catName].length == 0 && catName !== sCategory;234 }).remove();235 // Treating "detergent" options236 $(this).find('option:not(:disabled)').filter(function(i){237 if($(this).is(':selected')) return false;238 /*console.log($(this));239 console.log($(this).attr('value') + " === " + detLitt.name);240 console.log($(this).attr('value') === detLitt.name);*/241 return $(this).attr('value') === detLitt.name;242 }).remove();243 });244/*245 console.log("Trying to remove " + detLitt.name);246 $(this.getNode()).find('select.selDetName option')247 .filter(function(i){248 if($(this).is(':selected')) return false;249 return $(this).attr('value') === detLitt.name;250 })251 .remove();252 var self = this;253 //var currSelCatName = $(this.getNode()).find('select.selDetName option:selected').attr("category");254 $(this.getNode()).find('select.selDetName option:disabled').filter(function(i) {255 var catName = $(this).text();256 return self.availableDet[catName].length == 0 && catName !== currSelCatName;}257 ).remove();258 */259 }260dBox.prototype.drawSelectDet = function(dbDetAvailable) {261 //draw an selectDet box from availableDet262 var self = this;263 var boxID = 'divSelectDet_' + this.boxNumber;264 this.boxNumber++;265 $(self.getNode()).find(".enterDet")266 .append(267 '<div id="' + boxID + '" class="input-group my-group">'268 +'<button class="btn btn-default infos" type="submit">'269 + '<i class="fa fa-info"></i>'270 +'</button>'271 + '<div class="errordNumber">'272 + '<select class="selDetName selectpicker form-control" data-live-search="true"></select>'273 +' <input type="number" class="form-control dNumber" placeholder="quantity">'274 + '<span class="input-group-btn deleteDet">'275 + '<button class="btn btn-default" type="submit">'276 + '<span class="fa-stack"><i class="fa fa-circle-o fa-stack-2x"></i>'277 + '<i class="fa fa-remove fa-stack-1x"></i>'278 + '</span>'279 + '</button>'280 +'</span>'281 +'</div>'282 +'</div>'283 )284 .find('.deleteDet').click(function(){285 var detName = $(this).siblings('select').find('option:selected').text();286 var detCat = $(this).siblings('select').find('option:selected').attr('category');287 console.log("Adding " + detName + ' , ' + detCat);288 self.addAvailable({name : detName, category : detCat });289 $(this).parents().eq(1).remove();290 self.toggleSubmissionButtonState();291 });292 $(self.getNode()).find(".enterDet").find('#'+ boxID +' .infos').click(function(){293 //console.log($(this).next().find('select')[0]["value"])294 if($("advanced-sheet-handler").length === 0){295 self.emiter.emit("askInfos",$(this).next().find('select')[0]["value"])296 $(self.getNode()).append("<advanced-sheet-handler nglview></advanced-sheet-handler>")297 }298 else{299 self.emiter.emit("askInfos",$(this).next().find('select')[0]["value"])300 }301 302 });303 var defaultDet = null;304 $(self.getNode()).find('#' + boxID + ' .selDetName').each(function(){305 var elem = this;306 for (var category in self.availableDet) {307 //$(elem).append('<option disabled>Choose a ligand</option>');308 if (self.availableDet[category].length == 0) continue;309 $(elem).append('<option disabled>' + category + '</option>');310 self.availableDet[category].forEach(function(e, i){311 if(dbDetAvailable.includes(e)){312 defaultDet = !defaultDet ? { 'name' : e, 'category' : category } : defaultDet;313 $(elem).append('<option value=' + e +' category="' + category + '">' + e + '</option>'); 314 }315 });316 }317/*318 self.availableDet.forEach(function(e, i){319 $(elem).append('<option disabled> titit toto tata</option>');320 $(elem).append('<option value=' + e+'>' + e + '</option>');321 });322*/323 self.delAvailable(defaultDet, null);324 var prevDetSelected, prevCatSelected;325 $(elem).on('click',function(){326 prevDetSelected = $(this).find('option:selected').text();327 prevCatSelected = $(this).find('option:selected').attr('category');328 })329 $(elem).on('change',function(){330 var detSelected = $(this).find('option:selected').text();331 var catSelected = $(this).find('option:selected').attr('category');332 console.log("Changing From");333 console.log(prevDetSelected + " " + prevCatSelected);334 console.log("To");335 console.log(detSelected + " " + catSelected);336 self.delAvailable({ name : detSelected, category : catSelected }, prevCatSelected);337 //return;338 //return;339 self.addAvailable({ name : prevDetSelected, category : prevCatSelected});340 console.log("fixed");341 });342 });343 $(self.getNode()).find("input.dNumber").on('click',344 function() {345 $(this).removeClass("error");346 });347}348dBox.prototype.addClass = function(uneClass) {349 $("#w_"+this.idNum).addClass(uneClass);350}351dBox.prototype.removeClass = function(uneClass) {352 $("#w_"+this.idNum).removeClass(uneClass);353}354module.exports = {355 new : function (opt) {356 // opt safety assignment357 var obj = new dBox(opt);358 return obj;359 }...

Full Screen

Full Screen

detect.py

Source:detect.py Github

copy

Full Screen

1import torch2import numpy as np3import cv24import os5from .face_ssd import build_ssd6from .config import resnet152_model_config7from . import torch_utils8class DSFDDetector:9 def __init__(10 self,11 weight_path="dsfd/weights/WIDERFace_DSFD_RES152.pth",12 nms_iou_threshold=.3,13 ):14 self.nms_iou_threshold = nms_iou_threshold15 self.load_model(weight_path)16 def load_model(self, weight_path):17 cfg = resnet152_model_config18 net = build_ssd(cfg) # initialize SSD19 weight_path = weight_path20 net.load_state_dict(torch.load(weight_path,21 map_location=torch_utils.get_device()))22 torch_utils.to_cuda(net)23 net.eval()24 print('Finished loading model!')25 self.net = net26 def detect_face(self, image, confidence_threshold, shrink=1.0):27 x = image28 if shrink != 1:29 x = cv2.resize(image, None, None, fx=shrink, fy=shrink,30 interpolation=cv2.INTER_LINEAR)31 height, width = x.shape[:2]32 x = x.astype(np.float32)33 x -= np.array([104, 117, 123], dtype=np.float32)34 x = torch_utils.image_to_torch(x, cuda=True)35 with torch.no_grad():36 y = self.net(x, confidence_threshold, self.nms_iou_threshold)37 detections = y.data.cpu().numpy()38 scale = np.array([width, height, width, height])39 detections[:, :, 1:] *= (scale / shrink)40 # Move axis such that we get #[xmin, ymin, xmax, ymax, det_conf]41 dets = np.roll(detections, 4, axis=-1)42 return dets[0]43 def multi_scale_test(self, image, confidence_threshold, max_im_shrink):44 # shrink detecting and shrink only detect big face45 st = 0.5 if max_im_shrink >= 0.75 else 0.5 * max_im_shrink46 det_s = self.detect_face(image, confidence_threshold, shrink=st)47 if max_im_shrink > 0.75:48 det2 = self.detect_face(image, confidence_threshold, shrink=0.75)49 det_s = np.row_stack((det_s, det2))50 index = np.where(np.maximum(det_s[:, 2] - det_s[:, 0] + 1, det_s[:, 3] - det_s[:, 1] + 1) > 30)[0]51 det_s = det_s[index, :]52 # enlarge one times53 bt = min(2, max_im_shrink) if max_im_shrink > 1 else (st + max_im_shrink) / 254 det_b = self.detect_face(image, confidence_threshold, shrink=bt)55 # enlarge small iamge x times for small face56 if max_im_shrink > 1.5:57 det3 = self.detect_face(image, confidence_threshold, shrink=1.5)58 det_b = np.row_stack((det_b, det3))59 if max_im_shrink > 2:60 bt *= 261 while bt < max_im_shrink: # and bt <= 2:62 det4 = self.detect_face(image, confidence_threshold, shrink=bt)63 det_b = np.row_stack((det_b, det4))64 bt *= 265 det5 = self.detect_face(image, confidence_threshold,66 shrink=max_im_shrink)67 det_b = np.row_stack((det_b, det5))68 # enlarge only detect small face69 if bt > 1:70 index = np.where(np.minimum(det_b[:, 2] - det_b[:, 0] + 1, det_b[:, 3] - det_b[:, 1] + 1) < 100)[0]71 det_b = det_b[index, :]72 else:73 index = np.where(np.maximum(det_b[:, 2] - det_b[:, 0] + 1, det_b[:, 3] - det_b[:, 1] + 1) > 30)[0]74 det_b = det_b[index, :]75 return det_s, det_b76 def multi_scale_test_pyramid(self, image, confidence_threshold, max_shrink):77 # shrink detecting and shrink only detect big face78 det_b = self.detect_face(image, confidence_threshold, shrink=0.25)79 index = np.where(80 np.maximum(det_b[:, 2] - det_b[:, 0] + 1, det_b[:, 3] - det_b[:, 1] + 1)81 > 30)[0]82 det_b = det_b[index, :]83 st = [1.25, 1.75, 2.25]84 for i in range(len(st)):85 if (st[i] <= max_shrink):86 det_temp = self.detect_face(image, confidence_threshold,87 shrink=st[i])88 # enlarge only detect small face89 if st[i] > 1:90 index = np.where(91 np.minimum(det_temp[:, 2] - det_temp[:, 0] + 1,92 det_temp[:, 3] - det_temp[:, 1] + 1) < 100)[0]93 det_temp = det_temp[index, :]94 else:95 index = np.where(96 np.maximum(det_temp[:, 2] - det_temp[:, 0] + 1,97 det_temp[:, 3] - det_temp[:, 1] + 1) > 30)[0]98 det_temp = det_temp[index, :]99 det_b = np.row_stack((det_b, det_temp))100 return det_b101 def flip_test(self, image, confidence_threshold, shrink):102 image_f = cv2.flip(image, 1)103 det_f = self.detect_face(image_f, confidence_threshold, shrink=shrink)104 det_t = np.zeros(det_f.shape)105 det_t[:, 0] = image.shape[1] - det_f[:, 2]106 det_t[:, 1] = det_f[:, 1]107 det_t[:, 2] = image.shape[1] - det_f[:, 0]108 det_t[:, 3] = det_f[:, 3]109 det_t[:, 4] = det_f[:, 4]110 return det_t111def bbox_vote(det):112 order = det[:, 4].ravel().argsort()[::-1]113 det = det[order, :]114 if det.shape[0] == 0:115 return det[0:750, :]116 dets = None117 while det.shape[0] > 0:118 # IOU119 area = (det[:, 2] - det[:, 0] + 1) * (det[:, 3] - det[:, 1] + 1)120 xx1 = np.maximum(det[0, 0], det[:, 0])121 yy1 = np.maximum(det[0, 1], det[:, 1])122 xx2 = np.minimum(det[0, 2], det[:, 2])123 yy2 = np.minimum(det[0, 3], det[:, 3])124 w = np.maximum(0.0, xx2 - xx1 + 1)125 h = np.maximum(0.0, yy2 - yy1 + 1)126 inter = w * h127 o = inter / (area[0] + area[:] - inter)128 # get needed merge det and delete these det129 merge_index = np.where(o >= 0.3)[0]130 det_accu = det[merge_index, :]131 det = np.delete(det, merge_index, 0)132 if merge_index.shape[0] <= 1:133 continue134 det_accu[:, 0:4] = det_accu[:, 0:4] * np.tile(det_accu[:, -1:], (1, 4))135 max_score = np.max(det_accu[:, 4])136 det_accu_sum = np.zeros((1, 5))137 det_accu_sum[:, 0:4] = np.sum(det_accu[:, 0:4], axis=0) / np.sum(det_accu[:, -1:])138 det_accu_sum[:, 4] = max_score139 if dets is None:140 dets = det_accu_sum141 else:142 dets = np.row_stack((dets, det_accu_sum))143 if dets is None:144 dets = det145 return dets[:750, :]146def get_face_detections(detector,147 image,148 confidence_threshold,149 use_multiscale_detect=False,150 use_image_pyramid_detect=False,151 use_flip_detect=False):152 max_im_shrink = (0x7fffffff / 200.0 / (image.shape[0] * image.shape[1])) ** 0.5 # the max size of input image for caffe153 max_im_shrink = 3 if max_im_shrink > 3 else max_im_shrink154 shrink = max_im_shrink if max_im_shrink < 1 else 1155 dets = []156 det0 = detector.detect_face(image, confidence_threshold, shrink)157 dets.append(det0)158 if use_flip_detect:159 det1 = detector.flip_test(image, confidence_threshold, shrink)160 dets.append(det1)161 if use_multiscale_detect:162 det2, det3 = detector.multi_scale_test(image, confidence_threshold,163 max_im_shrink)164 dets.extend([det2, det3])165 if use_image_pyramid_detect:166 det4 = detector.multi_scale_test_pyramid(image, confidence_threshold,167 max_im_shrink)168 dets.append(det4)169 if len(dets) > 1:170 dets = np.row_stack(dets)171 dets = bbox_vote(dets)172 else:173 dets = dets[0]...

Full Screen

Full Screen

trident_roi_head.py

Source:trident_roi_head.py Github

copy

Full Screen

1import torch2from mmcv.ops import batched_nms3from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, merge_aug_bboxes,4 multiclass_nms)5from mmdet.models.roi_heads.standard_roi_head import StandardRoIHead6from ..builder import HEADS7@HEADS.register_module()8class TridentRoIHead(StandardRoIHead):9 """Trident roi head.10 Args:11 num_branch (int): Number of branches in TridentNet.12 test_branch_idx (int): In inference, all 3 branches will be used13 if `test_branch_idx==-1`, otherwise only branch with index14 `test_branch_idx` will be used.15 """16 def __init__(self, num_branch, test_branch_idx, **kwargs):17 self.num_branch = num_branch18 self.test_branch_idx = test_branch_idx19 super(TridentRoIHead, self).__init__(**kwargs)20 def merge_trident_bboxes(self, trident_det_bboxes, trident_det_labels):21 """Merge bbox predictions of each branch."""22 if trident_det_bboxes.numel() == 0:23 det_bboxes = trident_det_bboxes.new_zeros((0, 5))24 det_labels = trident_det_bboxes.new_zeros((0, ), dtype=torch.long)25 else:26 nms_bboxes = trident_det_bboxes[:, :4]27 nms_scores = trident_det_bboxes[:, 4].contiguous()28 nms_inds = trident_det_labels29 nms_cfg = self.test_cfg['nms']30 det_bboxes, keep = batched_nms(nms_bboxes, nms_scores, nms_inds,31 nms_cfg)32 det_labels = trident_det_labels[keep]33 if self.test_cfg['max_per_img'] > 0:34 det_labels = det_labels[:self.test_cfg['max_per_img']]35 det_bboxes = det_bboxes[:self.test_cfg['max_per_img']]36 return det_bboxes, det_labels37 def simple_test(self,38 x,39 proposal_list,40 img_metas,41 proposals=None,42 rescale=False):43 """Test without augmentation as follows:44 1. Compute prediction bbox and label per branch.45 2. Merge predictions of each branch according to scores of46 bboxes, i.e., bboxes with higher score are kept to give47 top-k prediction.48 """49 assert self.with_bbox, 'Bbox head must be implemented.'50 det_bboxes_list, det_labels_list = self.simple_test_bboxes(51 x, img_metas, proposal_list, self.test_cfg, rescale=rescale)52 num_branch = self.num_branch if self.test_branch_idx == -1 else 153 for _ in range(len(det_bboxes_list)):54 if det_bboxes_list[_].shape[0] == 0:55 det_bboxes_list[_] = det_bboxes_list[_].new_empty((0, 5))56 det_bboxes, det_labels = [], []57 for i in range(len(img_metas) // num_branch):58 det_result = self.merge_trident_bboxes(59 torch.cat(det_bboxes_list[i * num_branch:(i + 1) *60 num_branch]),61 torch.cat(det_labels_list[i * num_branch:(i + 1) *62 num_branch]))63 det_bboxes.append(det_result[0])64 det_labels.append(det_result[1])65 bbox_results = [66 bbox2result(det_bboxes[i], det_labels[i],67 self.bbox_head.num_classes)68 for i in range(len(det_bboxes))69 ]70 return bbox_results71 def aug_test_bboxes(self, feats, img_metas, proposal_list, rcnn_test_cfg):72 """Test det bboxes with test time augmentation."""73 aug_bboxes = []74 aug_scores = []75 for x, img_meta in zip(feats, img_metas):76 # only one image in the batch77 img_shape = img_meta[0]['img_shape']78 scale_factor = img_meta[0]['scale_factor']79 flip = img_meta[0]['flip']80 flip_direction = img_meta[0]['flip_direction']81 trident_bboxes, trident_scores = [], []82 for branch_idx in range(len(proposal_list)):83 proposals = bbox_mapping(proposal_list[0][:, :4], img_shape,84 scale_factor, flip, flip_direction)85 rois = bbox2roi([proposals])86 bbox_results = self._bbox_forward(x, rois)87 bboxes, scores = self.bbox_head.get_bboxes(88 rois,89 bbox_results['cls_score'],90 bbox_results['bbox_pred'],91 img_shape,92 scale_factor,93 rescale=False,94 cfg=None)95 trident_bboxes.append(bboxes)96 trident_scores.append(scores)97 aug_bboxes.append(torch.cat(trident_bboxes, 0))98 aug_scores.append(torch.cat(trident_scores, 0))99 # after merging, bboxes will be rescaled to the original image size100 merged_bboxes, merged_scores = merge_aug_bboxes(101 aug_bboxes, aug_scores, img_metas, rcnn_test_cfg)102 det_bboxes, det_labels = multiclass_nms(merged_bboxes, merged_scores,103 rcnn_test_cfg.score_thr,104 rcnn_test_cfg.nms,105 rcnn_test_cfg.max_per_img)...

Full Screen

Full Screen

cld.gyp

Source:cld.gyp Github

copy

Full Screen

1# Copyright (c) 2012 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4{5 'includes': [6 '../../build/win_precompile.gypi',7 ],8 'targets': [9 {10 'target_name': 'cld',11 'type': 'static_library',12 'dependencies': [13 '../icu/icu.gyp:icuuc',14 ],15 'export_dependent_settings': [16 '../icu/icu.gyp:icuuc',17 ],18 'include_dirs': [19 '.',20 ],21 'defines': [22 'CLD_WINDOWS',23 ],24 'sources': [25 'encodings/compact_lang_det/cldutil.cc',26 'encodings/compact_lang_det/cldutil.h',27 'encodings/compact_lang_det/cldutil_dbg.h',28 'encodings/compact_lang_det/cldutil_dbg_empty.cc',29 'encodings/compact_lang_det/compact_lang_det.cc',30 'encodings/compact_lang_det/compact_lang_det.h',31 'encodings/compact_lang_det/compact_lang_det_impl.cc',32 'encodings/compact_lang_det/compact_lang_det_impl.h',33 'encodings/compact_lang_det/ext_lang_enc.cc',34 'encodings/compact_lang_det/ext_lang_enc.h',35 'encodings/compact_lang_det/getonescriptspan.cc',36 'encodings/compact_lang_det/getonescriptspan.h',37 'encodings/compact_lang_det/letterscript_enum.cc',38 'encodings/compact_lang_det/letterscript_enum.h',39 'encodings/compact_lang_det/string_byte_sink.cc',40 'encodings/compact_lang_det/string_byte_sink.h',41 'encodings/compact_lang_det/subsetsequence.cc',42 'encodings/compact_lang_det/subsetsequence.h',43 'encodings/compact_lang_det/tote.cc',44 'encodings/compact_lang_det/tote.h',45 'encodings/compact_lang_det/utf8propjustletter.h',46 'encodings/compact_lang_det/utf8propletterscriptnum.h',47 'encodings/compact_lang_det/utf8scannotjustletterspecial.h',48 'encodings/compact_lang_det/generated/cld_generated_score_quadchrome_0406.cc',49 'encodings/compact_lang_det/generated/compact_lang_det_generated_cjkbis_0.cc',50 'encodings/compact_lang_det/generated/compact_lang_det_generated_ctjkvz.cc',51 'encodings/compact_lang_det/generated/compact_lang_det_generated_deltaoctachrome.cc',52 'encodings/compact_lang_det/generated/compact_lang_det_generated_meanscore.h',53 'encodings/compact_lang_det/generated/compact_lang_det_generated_quadschrome.cc',54 'encodings/compact_lang_det/win/cld_basictypes.h',55 'encodings/compact_lang_det/win/cld_commandlineflags.h',56 'encodings/compact_lang_det/win/cld_google.h',57 'encodings/compact_lang_det/win/cld_htmlutils.h',58 'encodings/compact_lang_det/win/cld_htmlutils_windows.cc',59 'encodings/compact_lang_det/win/cld_logging.h',60 'encodings/compact_lang_det/win/cld_macros.h',61 'encodings/compact_lang_det/win/cld_strtoint.h',62 'encodings/compact_lang_det/win/cld_unicodetext.cc',63 'encodings/compact_lang_det/win/cld_unicodetext.h',64 'encodings/compact_lang_det/win/cld_unilib.h',65 'encodings/compact_lang_det/win/cld_unilib_windows.cc',66 'encodings/compact_lang_det/win/cld_utf.h',67 'encodings/compact_lang_det/win/cld_utf8statetable.cc',68 'encodings/compact_lang_det/win/cld_utf8statetable.h',69 'encodings/compact_lang_det/win/cld_utf8utils.h',70 'encodings/compact_lang_det/win/cld_utf8utils_windows.cc',71 'encodings/internal/encodings.cc',72 'encodings/proto/encodings.pb.h',73 'encodings/public/encodings.h',74 'languages/internal/languages.cc',75 'languages/proto/languages.pb.h',76 'languages/public/languages.h',77 'base/basictypes.h',78 'base/build_config.h',79 'base/casts.h',80 'base/commandlineflags.h',81 'base/global_strip_options.h',82 'base/logging.h',83 'base/macros.h',84 'base/port.h',85 'base/crash.h',86 'base/dynamic_annotations.h',87 'base/scoped_ptr.h',88 'base/stl_decl_msvc.h',89 'base/log_severity.h',90 'base/strtoint.h',91 'base/vlog_is_on.h',92 'base/string_util.h',93 'base/type_traits.h',94 'base/template_util.h',95 ],96 'direct_dependent_settings': {97 'defines': [98 'CLD_WINDOWS',99 ],100 'include_dirs': [101 '.',102 ],103 },104 'conditions': [105 ['OS=="win"', {106 'direct_dependent_settings': {107 'defines': [108 'COMPILER_MSVC',109 ],110 },111 # TODO(jschuh): C4267: http://crbug.com/167187 size_t -> int112 'msvs_disabled_warnings': [4005, 4006, 4018, 4244, 4309, 4800, 4267],113 }, {114 'direct_dependent_settings': {115 'defines': [116 'COMPILER_GCC',117 ],118 },119 }],120 ],121 },122 ],...

Full Screen

Full Screen

mobile_swipe.js

Source:mobile_swipe.js Github

copy

Full Screen

1function detectswipe(el,func) {2 swipe_det = new Object();3 swipe_det.sX = 0; swipe_det.sY = 0; swipe_det.eX = 0; swipe_det.eY = 0;4 var min_x = 30; //min x swipe for horizontal swipe5 var max_x = 30; //max x difference for vertical swipe6 var min_y = 50; //min y swipe for vertical swipe7 var max_y = 60; //max y difference for horizontal swipe8 var direc = "";9 ele = document.getElementById(el);10 ele.addEventListener('touchstart',function(e){11 var t = e.touches[0];12 swipe_det.sX = t.screenX;13 swipe_det.sY = t.screenY;14 },false);15 ele.addEventListener('touchmove',function(e){16 e.preventDefault();17 var t = e.touches[0];18 swipe_det.eX = t.screenX;19 swipe_det.eY = t.screenY;20 },false);21 ele.addEventListener('touchend',function(e){22 //horizontal detection23 if ((((swipe_det.eX - min_x > swipe_det.sX) || (swipe_det.eX + min_x < swipe_det.sX)) && ((swipe_det.eY < swipe_det.sY + max_y) && (swipe_det.sY > swipe_det.eY - max_y) && (swipe_det.eX > 0)))) {24 if(swipe_det.eX > swipe_det.sX) direc = "r";25 else direc = "l";26 }27 //vertical detection28 else if ((((swipe_det.eY - min_y > swipe_det.sY) || (swipe_det.eY + min_y < swipe_det.sY)) && ((swipe_det.eX < swipe_det.sX + max_x) && (swipe_det.sX > swipe_det.eX - max_x) && (swipe_det.eY > 0)))) {29 if(swipe_det.eY > swipe_det.sY) direc = "d";30 else direc = "u";31 }32 if (direc != "") {33 if(typeof func == 'function') func(el,direc);34 }35 direc = "";36 swipe_det.sX = 0; swipe_det.sY = 0; swipe_det.eX = 0; swipe_det.eY = 0;37 },false);38}39function myfunction(el,d) {40 if (d == 'r'){41 const listChild = document.querySelector('.carousel-inner').children;42 for (i=0;i<listChild.length;i++) {43 if (listChild[i].classList.contains('active')){44 if (i == 0){45 listChild[listChild.length - 1].classList.add('active');46 listChild[i].classList.remove('active');47 }else{48 listChild[i-1].classList.add('active');49 listChild[i].classList.remove('active');50 }51 }52 }53 } else if (d == 'l'){54 const listChild = document.querySelector('.carousel-inner').children;55 for (i=0;i<listChild.length;i++) {56 if (listChild[i].classList.contains('active')){57 if (i == listChild.length - 1){58 listChild[0].classList.add('active');59 listChild[i].classList.remove('active');60 }else{61 listChild[i+1].classList.add('active');62 listChild[i].classList.remove('active');63 }64 }65 }66 }67}68if (document.getElementById('artists-carousel')){69 document.addEventListener('DOMContentLoaded', (e)=>{70 detectswipe('artists-carousel',myfunction);71 })72 document.querySelectorAll('.link-tab').forEach(function(e){73 e.addEventListener('click',(e)=> {74 detectswipe('artists-carousel',myfunction);75 })76 })...

Full Screen

Full Screen

definicao-escopo-grupo-tecnico.module.ts

Source:definicao-escopo-grupo-tecnico.module.ts Github

copy

Full Screen

1// tslint:disable:max-line-length2import { NgModule } from '@angular/core';3import { CommonModule } from '@angular/common';4import { DefinicaoEscopoGrupoTecnicoComponent } from './definicao-escopo-grupo-tecnico.component';5import { SharedModule } from '@aw-shared/shared.module';6import { AwComponentsModule } from '@aw-components/aw-components.module';7import { DefinicaoEscopoSharedModule } from '../definicao-escopo/shared/definicao-escopo-shared.module';8import { NgxsModule } from '@ngxs/store';9import { DefinicaoEscopoGrupoTecnicoState } from './state/definicao-escopo-grupo-tecnico.state';10import { DetGrupoItemComponent } from './det-grupo-item/det-grupo-item.component';11import { DetGrupoItemListComponent } from './det-grupo-item-list/det-grupo-item-list.component';12import { DetGrupoItemAcoesComponent } from './det-grupo-item/det-grupo-item-acoes/det-grupo-item-acoes.component';13import { DetGrupoItemContentComponent } from './det-grupo-item/det-grupo-item-content/det-grupo-item-content.component';14import { DetGrupoItemFilhoComponent } from './det-grupo-item-filho/det-grupo-item-filho.component';15import { DetGrupoItemFilhoContentComponent } from './det-grupo-item-filho/det-grupo-item-filho-content/det-grupo-item-filho-content.component';16import { DefinicaoEscopoLojaInsumoSharedModule } from '../definicao-escopo-loja-insumo/shared/definicao-escopo-loja-insumo-shared.module';17import { DetGrupoItemFilhoQuantificarComponent } from './det-grupo-item-filho/det-grupo-item-filho-quantificar/det-grupo-item-filho-quantificar.component';18import { DetGrupoItemFilhoAmbientesComponent } from './det-grupo-item-filho/det-grupo-item-filho-ambientes/det-grupo-item-filho-ambientes.component';19import { DetGrupoItemFilhoAmbientesModalComponent } from './det-grupo-item-filho/det-grupo-item-filho-ambientes-modal/det-grupo-item-filho-ambientes-modal.component';20@NgModule({21 declarations: [22 DefinicaoEscopoGrupoTecnicoComponent,23 DetGrupoItemComponent,24 DetGrupoItemListComponent,25 DetGrupoItemAcoesComponent,26 DetGrupoItemContentComponent,27 DetGrupoItemFilhoQuantificarComponent,28 DetGrupoItemFilhoComponent,29 DetGrupoItemFilhoContentComponent,30 DetGrupoItemFilhoAmbientesComponent,31 DetGrupoItemFilhoAmbientesModalComponent,32 ],33 imports: [34 CommonModule,35 NgxsModule.forFeature([DefinicaoEscopoGrupoTecnicoState]),36 SharedModule,37 AwComponentsModule,38 DefinicaoEscopoSharedModule,39 DefinicaoEscopoLojaInsumoSharedModule,40 ],41 exports: [DefinicaoEscopoGrupoTecnicoComponent],42})...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptool = require('wptool');2var det = wptool.det;3var m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];4console.log(det(m));5var wptool = require('wptool');6var det = wptool.det;7var m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];8console.log(det(m));9var wptool = require('wptool');10var det = wptool.det;11var m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];12console.log(det(m));13var wptool = require('wptool');14var det = wptool.det;15var m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];16console.log(det(m));17var wptool = require('wptool');18var det = wptool.det;19var m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];20console.log(det(m));21var wptool = require('wptool');22var det = wptool.det;23var m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];24console.log(det(m));25var wptool = require('wptool');26var det = wptool.det;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2 if (err) return console.log(err);3 wpt.getTestResults(data.data.testId, function(err, data) {4 if (err) return console.log(err);5 console.log(data);6 });7});8var wpt = require('webpagetest');9 if (err) return console.log(err);10 wpt.getTestResults(data.data.testId, function(err, data) {11 if (err) return console.log(err);12 console.log(data);13 });14});15var wpt = require('webpagetest');16 if (err) return console.log(err);17 wpt.getTestResults(data.data.testId, function(err, data) {18 if (err) return console.log(err);19 console.log(data);20 });21});22var wpt = require('webpagetest');23 if (err) return console.log(err);24 wpt.getTestResults(data.data.testId, function(err, data) {25 if (err) return console.log(err);26 console.log(data);27 });28});29var wpt = require('webpagetest');30 if (err) return console.log(err);31 wpt.getTestResults(data.data.testId, function(err, data) {32 if (err) return console

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptool = require('wptool');2var wp = new wptool();3wp.det(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, function(err, result) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log('Result: ' + result);8 }9});10var wptool = require('wptool');11var wp = new wptool();12wp.det(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, function(err, result) {13 if (err) {14 console.log('Error: ' + err);15 } else {16 console.log('Result: ' + result);17 }18});19var wptool = require('wptool');20var wp = new wptool();21wp.det(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, function(err, result) {22 if (err) {23 console.log('Error: ' + err);24 } else {25 console.log('Result: ' + result);26 }27});28var wptool = require('wptool');29var wp = new wptool();30wp.det(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, function(err, result) {31 if (err) {32 console.log('Error: ' + err);33 } else {34 console.log('Result: ' + result);35 }36});37var wptool = require('wptool');38var wp = new wptool();39wp.det(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, function(err, result) {40 if (err) {41 console.log('Error:

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = new WebPageTest('www.webpagetest.org');10wpt.getTestStatus('140627_BA_4e4a4e4d7b4e4c0a7b4e4c0a7b4e4c0a', function(err, data) {11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = new WebPageTest('www.webpagetest.org');18wpt.getTestResults('140627_BA_4e4a4e4d7b4e4c0a7b4e4c0a7b4e4c0a', function(err, data) {19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = new WebPageTest('www.webpagetest.org');26wpt.getLocations(function(err, data) {27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var wpt = new WebPageTest('www.webpagetest.org');34wpt.getTesters(function(err, data) {35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = new WebPageTest('www.webpagetest.org');42wpt.getLocations(function(err, data) {43 if (err) {44 console.log(err);45 } else {46 console.log(data);47 }48});49var wpt = new WebPageTest('www.webpagetest.org');50wpt.getLocations(function(err, data) {51 if (err) {52 console.log(err);53 } else {54 console.log(data);55 }56});57var wpt = new WebPageTest('www.webpagetest.org');58wpt.getLocations(function(err, data) {59 if (err) {60 console.log(err);61 } else {62 console.log(data);63 }64});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.page('Barack Obama').get(function(err, resp) {3 console.log(resp);4});5wptools.page('Barack Obama').det(function(err, resp) {6 console.log(resp);7});8var wptools = require('wptools');9wptools.page('Barack Obama').get(function(err, resp) {10 console.log(resp);11});12wptools.page('Barack Obama').det(function(err, resp) {13 console.log(resp);14});15var wptools = require('wptools');16wptools.page('Barack Obama').get(function(err, resp) {17 console.log(resp);18});19wptools.page('Barack Obama').det(function(err, resp) {20 console.log(resp);21});22var wptools = require('wptools');23wptools.page('Barack Obama').get(function(err, resp) {24 console.log(resp);25});26wptools.page('Barack Obama').det(function(err, resp) {27 console.log(resp);28});29var wptools = require('wptools');30wptools.page('Barack Obama').get(function(err, resp) {31 console.log(resp);32});33wptools.page('Barack Obama').det(function(err, resp) {34 console.log(resp);35});36var wptools = require('wptools');37wptools.page('Barack Obama').get(function(err, resp) {38 console.log(resp);39});40wptools.page('Barack Obama').det(function(err, resp) {41 console.log(resp);42});

Full Screen

Using AI Code Generation

copy

Full Screen

1var WebPageTest = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6');3wpt.getTestStatus('160122_6A_2d3', function(err, data) {4 console.log(data);5});6var WebPageTest = require('webpagetest');7var wpt = new WebPageTest('www.webpagetest.org', 'A.1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6');8wpt.getTestStatus('160122_6A_2d3', function(err, data) {9 console.log(data);10});11var WebPageTest = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org', 'A.1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6');13wpt.getTestStatus('160122_6A_2d3', function(err, data) {14 console.log(data);15});16var WebPageTest = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org', 'A.1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6');18wpt.getTestStatus('160122_6

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful