This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Detection> origNms(List<Detection> detections, double threshold) { | |
if (detections.length <= 0) return []; | |
List<double> x1 = new List(); | |
List<double> x2 = new List(); | |
List<double> y1 = new List(); | |
List<double> y2 = new List(); | |
List<double> s = new List(); | |
detections.forEach((detection) { | |
x1.add(detection.xMin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array decodeBox( | |
List<double> rawBoxes, int i, List<Anchor> anchors, OptionsFace options) { | |
Array boxData = Array(List<double>.generate(options.numCoords, (i) => 0.0)); | |
int boxOffset = i * options.numCoords + options.boxCoordOffset; | |
double yCenter = rawBoxes[boxOffset]; | |
double xCenter = rawBoxes[boxOffset + 1]; | |
double h = rawBoxes[boxOffset + 2]; | |
double w = rawBoxes[boxOffset + 3]; | |
if (options.reverseOutputOrder) { | |
xCenter = rawBoxes[boxOffset]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Detection convertToDetection(double boxYMin, double boxXMin, double boxYMax, | |
double boxXMax, double score, int classID, bool flipVertically) { | |
double _yMin; | |
if (flipVertically) | |
_yMin = 1.0 - boxYMax; | |
else | |
_yMin = boxYMin; | |
return new Detection(score, classID, boxXMin, _yMin, (boxXMax - boxXMin), | |
(boxXMax - boxYMin)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Anchor> getAnchors(AnchorOption options) { | |
List<Anchor> _anchors = new List(); | |
if (options.stridesSize != options.numLayers) { | |
print('strides_size and num_layers must be equal.'); | |
return []; | |
} | |
int layerID = 0; | |
while (layerID < options.stridesSize) { | |
List<double> anchorHeight = new List(); | |
List<double> anchorWidth = new List(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Detection> process( | |
{OptionsFace options, | |
List<double> rawScores, | |
List<double> rawBoxes, | |
List<Anchor> anchors}) { | |
List<double> detectionScores = new List(); | |
List<int> detectionClasses = new List(); | |
int boxes = options.numBoxes; | |
for (int i = 0; i < boxes; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load model | |
void _loadModel() async { | |
_anchors = UtilsFace().getAnchors(anchors); | |
_interpreter = | |
await Interpreter.fromAsset("models/face_detection_front.tflite"); | |
_inputShape = _interpreter.getInputTensor(0).shape; | |
_imageProcessor = ImageProcessorBuilder() | |
.add(ResizeOp( | |
_inputShape[1], _inputShape[2], ResizeMethod.NEAREST_NEIGHBOUR)) | |
.add(_normalizeInput) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Detection { | |
final double score; | |
final int classID; | |
final double xMin; | |
final double yMin; | |
final double width; | |
final double height; | |
Detection( | |
this.score, this.classID, this.xMin, this.yMin, this.width, this.height); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AnchorOption { | |
final int inputSizeWidth; | |
final int inputSizeHeight; | |
final double minScale; | |
final double maxScale; | |
final double anchorOffsetX; | |
final double anchorOffsetY; | |
final int numLayers; | |
final List<int> featureMapWidth; | |
final List<int> featureMapHeight; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OptionsFace { | |
final int numClasses; | |
final int numBoxes; | |
final int numCoords; | |
final int keypointCoordOffset; | |
final List<int> ignoreClasses; | |
final double scoreClippingThresh; | |
final double minScoreThresh; | |
final int numKeypoints; | |
final int numValuesPerKeypoint; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Bitcoin address validation - xellDart. | |
* | |
*/ | |
import 'package:crypto/crypto.dart'; | |
class Bitcoin { | |
final String ALPHABET = | |
"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; |