public void CrawlerRoundtrip() { var crawler = new InstagramCrawler(); var images = crawler.CrawlImages(10); var tagger = new ClarifaiImageTagger(); var db = new LiteDbAutoTaggerStorage("fullImportedImages.ldb"); IEnumerable <string> lastMTags = null; IEnumerable <string> lastHTags = null; foreach (var crawlerImage in images) { this.TestConsole.WriteLine( crawlerImage.ImageId + ">L" + crawlerImage.Likes + ">C" + crawlerImage.Comments + " >>> " + string.Join(", ", crawlerImage.HumanoidTags)); var tags = tagger.GetTagsForImageUrl(crawlerImage.ImageUrl).ToList(); lastMTags = tags; lastHTags = crawlerImage.HumanoidTags; Console.WriteLine("Tags: " + string.Join(", ", tags)); db.InsertOrUpdate(crawlerImage.ImageId, tags, crawlerImage.HumanoidTags); } Assert.NotNull(lastMTags); var foundHTags = db.FindHumanoidTags(lastMTags).ToList(); this.TestConsole.WriteLine(string.Join(", ", lastMTags) + " >>> " + string.Join(", ", foundHTags)); // var similar = lastHTags.Count(lastHTag => foundHTags.Contains(lastHTag)); // Assert.True(similar > 2, "not enough similar tags"); }
private static void ClarifaiTest() { var imageLink = "https://images.pexels.com/photos/211707/pexels-photo-211707.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"; Console.WriteLine("Clarifai Test"); var tagger = new ClarifaiImageTagger(); var tags = tagger.GetTagsForImageUrl(imageLink); Console.WriteLine("Tags: " + string.Join(", ", tags)); }
private static void Main(string[] args) { var imageTagger = new ClarifaiImageTagger(); Console.WriteLine("Insert a link:"); while (true) { var link = Console.ReadLine(); Console.WriteLine("inserted: " + link); var tags = imageTagger.GetTagsForImageUrl(link); var output = JsonConvert.SerializeObject(tags); Console.WriteLine(output); } }
public static void ImportInstagramTags() { var linkWithTags = File.ReadLines("./imageLinks.txt").ToList(); foreach (var linkWithTag in linkWithTags) { var splitted = linkWithTag.Split(','); var link = splitted.First(); var humanoidTags = splitted.Skip(1).First().Split('/'); var tagger = new ClarifaiImageTagger(); var repository = new CosmosAutoTaggerStorage(); var machineTags = tagger.GetTagsForImageUrl(link); repository.InsertOrUpdate(link, machineTags, humanoidTags); } }