Google Vision API中的实体在Knowledge Graph API中没有信息

问题描述

我使用Google Vision API来检测图像中的主题,然后使用Knowledge Graph API检索有关这些主题的信息(例如,描述,缩略图和Wikpedia链接)。但是,有时我发现Vision API返回的实体在知识图中没有任何信息。

这里是一个例子。

使用Google Vision API Demo,分析this image

在返回的JSON中,您可以看到“大气现象”作为检测到的标签及其知识图标识符。

public partial class MainWindow : Window
{
    private readonly ViewModel vm;
    public MainWindow()
    {
        InitializeComponent();
        vm = new ViewModel();
        DataContext = vm;

        int max = 1_000_000;
        for(int i=0; i< max; i++)
        {
            vm.Employees.Add(new Person()
            {
                FirstName = "Walter_" + i.ToString(),Lastname = "Winter_" + i.ToString(),Age = i
            });
        }
    }

    private void RunCommand(object sender,RoutedEventArgs e)
    {
        vm.MinAge++;
        Stopwatch sw = new Stopwatch();

        sw.Start();
        vm.EmpView1.Refresh();
        long t1 = sw.ElapsedMilliseconds;
        
        sw.Restart();
        vm.EmpView2.Refresh();
        long t2 = sw.ElapsedMilliseconds;
        
        vm.Message = $"{t1} - {t2}"; 
    }
}

public class ViewModel : ModelBase,IEnumerable<Person>
{
    public IEnumerator<Person> GetEnumerator() => Employees.GetEnumerator();
    IEnumerator IEnumerable.GetEnumerator() => Employees.GetEnumerator();

    private ObservableCollection<Person> employees = new ObservableCollection<Person>();
    public ObservableCollection<Person> Employees { get => employees; set => SetField(ref employees,value); }
    
    private string message;
    public string Message { get => message; set => SetField(ref message,value); }
    public CollectionView EmpView1 { get; private set; }
    public CollectionView EmpView2 { get; private set; }
    public int MinAge { get; set; } = 0;
    public int MaxAge { get; set; } = 100;

    public ViewModel()
    {
        EmpView1 = CollectionViewSource.GetDefaultView(Employees) as CollectionView;
        EmpView2 = CollectionViewSource.GetDefaultView(this) as CollectionView;
        EmpView1.Filter = Filter;
        EmpView2.Filter = Filter;
    }

    public bool Filter(object o)
    {
        Person p = o as Person;
        return p.Age > MinAge && p.Age < MaxAge;
    }
}

public class Person : ModelBase
{
    private string firstname;
    public string FirstName { get => firstname; set => SetField(ref firstname,value); }

    private string lastname;
    public string Lastname { get => lastname; set => SetField(ref lastname,value); }

    private int age;
    public int Age { get => age; set => SetField(ref age,value); }
}

public class ModelBase : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    protected void SetField<T>(ref T field,T value,[CallerMemberName] string propertyName = null)
    {
        if (EqualityComparer<T>.Default.Equals(field,value)) return;
        field = value;
        RaisePropertyChanged(propertyName);
    }

    public void RaisePropertyChanged([CallerMemberName] string propertyName = null) =>
        PropertyChanged?.Invoke(this,new PropertyChangedEventArgs(propertyName));
}

您可以通过以下网址直接在Google上进行搜索,从而验证该实体是否存在。

http://g.co/kg/m/07pw27b

enter image description here

但是,当使用Knowledge Graph API获取有关该实体的信息时,响应为空。

{
  "labelAnnotations": [
    {
      "description": "Atmospheric phenomenon","mid": "/m/07pw27b","score": 0.874821,"topicality": 0.874821
    },// ...
  ],// ...
}

为什么Vision API返回的某些实体在知识图中没有信息?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...