/// <summary> /// Initialises this class /// </summary> private void Awake() { // Allows this instance to behave like a singleton Instance = this; predictionEndpoint = "https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Prediction/1f2ce23d-d05f-46b6-9592-5441df2c3991/image"; }
/// <summary> /// Initializes this class /// </summary> private void Awake() { // Allows this instance to behave like a singleton Instance = this; navManager = GameObject.Find("Managers").GetComponent <NavManager>(); firebaseManager = GameObject.Find("Managers").GetComponent <FirebaseManager>(); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Admin, "get", "post", Route = null)] HttpRequest req, ILogger log, ExecutionContext context) { var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .Build(); log.LogInformation("Get Product Image Tags function triggered"); var db = TailwindContext.CreateNew(config.GetConnectionString("Tailwind")); int id = 0; int.TryParse(req.Query["ProductId"], out id); string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); string bodyid = data ?? data?.CommentId; if (!string.IsNullOrEmpty(bodyid)) { int.TryParse(bodyid, out id); } // using the product Id, get the database entry var product = db.Products.FirstOrDefault(c => c.Id == id); // Get analysis of the text var analyser = new CustomVisionAnalyser(config["customVisionSubscriptionKey"], new Guid(config["customVisionProjectId"])); var tags = analyser.GetImageTagPredictions(product.ImageUrl); log.LogInformation("Tag predictions: {Tags}", tags); // get the confidence tag var bestTag = (tags.OrderByDescending(t => t.Confidence).FirstOrDefault()); if (tags.Any(t => t.Tag != bestTag.Tag && bestTag.Confidence - t.Confidence < 30)) { // take a bit off for having another tag so close bestTag.Confidence -= Math.Min(bestTag.Confidence, 20); log.LogInformation("Two tags were close together so we're reducing the confidence"); } product.Tags = bestTag.Tag; product.AutoTagConfidence = bestTag.Confidence; db.SaveChanges(); return((ActionResult) new OkObjectResult(tags)); }
/// <summary> /// Initializes this class /// </summary> private void Awake() { // Allows this instance to behave like a singleton Instance = this; }
/// <summary> /// Initialises this class /// </summary> private void Awake() { // このクラスのインスタンスをシングルトンとして利用する。 Instance = this; }
/// <summary> /// Initializes this class /// </summary> private void Awake() { // Allows this instance to behave like a singleton Instance = this; //m_Image = GetComponent<Image>(); }
void Awake() { //确保该实例为单例 Instance = this; }
private void Awake() { Instance = this; }