百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

liresolr

> 编程语言
开源

将 LIRE 添加到 Solr 中 - 一个正在进行的项目

187 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

将 LIRE 添加到 Solr 中 - 一个正在进行的项目

LIRE Solr Integration Project

This is a Solr plugin for the LIRE content based image retrieval library, so basically it's for indexing images and then finding similar (looking) ones. The original library can be found at Github

The LIRE Solr plugin includes a RequestHandler for searching, an EntityProcessor for indexing, a ValueSource Parser for content based re-ranking and a parallel indexing application.

An outdated demo can be found at http://demo-itec.uni-klu.ac.at/liredemo/. If you want to give it a try yourself, there is a docker image, which you use to run a pre-configured core on a Solr server. There's also a tool to create import XML files from Flickr. More information is available at src/main/docs/docker.md.

If you need help on the plugin, please use the mailing list at lire-dev mailing list to ask questions. Additional documentation is available on src/main/docs/index.md If you need help with your project, please contact me, we also offer consulting services.

If you use LIRE Solr for scientific purposes, please cite the following paper:

Mathias Lux and Glenn Macstravic "The LIRE Request Handler: A Solr Plug-In for Large Scale Content Based Image Retrieval." MultiMedia Modeling. Springer International Publishing, 2014. Springer

The RequestHandler supports the following different types of queries

  1. Get random images ...
  2. Get images that are looking like the one with id ...
  3. Get images looking like the one found at url ...
  4. Get images with a feature vector like ...
  5. Extract histogram and hashes from an image URL ...

Preliminaries

Supported values for feature field parameters, e.g. lireq?field=cl are ...

  • ph .. PHOG (pyramid histogram of oriented gradients)
  • oh .. OpponentHistogram (simple color his togram in the opponent color space)
  • cl .. ColorLayout (from MPEG-7)
  • sc .. ScalableColor (from MPEG-7)
  • eh .. EdgeHistogram (from MPEG-7)
  • ce .. CEDD (very compact and accurate joint descriptor)
  • fc .. FCTH (more accurate, less compact than CEDD)
  • jc .. JCD (joined descriptor of CEDD and FCTH)
  • ac .. AutoColorCorrelogram (color to color correlation histogram)
  • pc .. SPCEDD (pyramid histogram of CEDD)
  • fo .. FuzzyOpponentHistogram (fuzzy color histogram)
  • sf .. GenericGlobalShortFeature (generic feature used to search for deep features in LireSolr)

Also consult the Lire project and the documentation of features there. You can also extend the list of features by changing the FeatureRegistry in the LireSolr source.

The field parameter (partially) works with the LIRE request handler:

  • fl .. Fields, give them as a comma or space separated list, like "fl=title,id,score". Note that "*" is denoting all fields and score adds the distance (which already comes with the "d" fields) in an additional score field.
  • fq .. Filter query, give them as a comma separated list in the format "fq=tags:dog tags:funny". No wildcards and no spaces in terms supported for now.

Getting random images

Returns randomly chosen images from the index. While it does not seem extremely helpful, it's actually great to find images to be used for example queries.

Parameters:

  • rows ... indicates how many results should be returned (optional, default=60). Example: lireq?rows=30

Search by ID

Returns images that look like the one with the given ID.

Parameters:

  • id .. the ID of the image used as a query as stored in the "id" field in the index.
  • field .. gives the feature field to search for (optional, default=cl_ha, values see above)
  • rows .. indicates how many results should be returned (optional, default=60).
  • ms .. prefer MetricSpaces over BitSampling (optional, default=false).
  • accuracy .. double in [0.05, 1] indicates how many accurate the results should be (optional, default=0.33, less is less accurate, but faster).
  • candidates .. int in [100, 100000] indicates how many accurate the results should be (optional, default=10000, less is less accurate, but faster).

Search by URL

Returns images that look like the one found at the given URL.

Parameters:

  • url .. the URL of the image used as a query. Note that the image has to be accessible by the web server Java has to be able to read it.
  • field .. gives the feature field to search for (optional, default=cl_ha, values see above)
  • rows .. indicates how many results should be returned (optional, default=60).
  • ms .. prefer MetricSpaces over BitSampling (optional, default=false).
  • accuracy .. double in [0.05, 1] indicates how many accurate the results should be (optional, default=0.33, less is less accurate, but faster).
  • candidates .. int in [100, 100000] indicates how many accurate the results should be (optional, default=10000, less is less accurate, but faster).

Search by feature vector

Returns an image that looks like the one the given features were extracted. This method is used if the client extracts the features from the image, which makes sense if the image should not be submitted.

Parameters:

  • hashes .. Hashes of the image feature as returned by BitSampling#generateHashes(double[]) as a String of white space separated numbers.
  • feature .. Base64 encoded feature histogram from LireFeature#getByteArrayRepresentation().
  • field .. gives the feature field to search for (optional, default=cl_ha, values see above)
  • rows .. indicates how many results should be returned (optional, default=60).
  • ms .. prefer MetricSpaces over BitSampling (optional, default=false).
  • accuracy .. double in [0.05, 1] indicates how many accurate the results should be (optional, default=0.33, less is less accurate, but faster).
  • candidates .. int in [100, 100000] indicates how many accurate the results should be (optional, default=10000, less is less accurate, but faster).

Examples:

/lireq?feature=FQY5Cw8PDRQQEBEUEg4MDREQEA0OEREgEBAQEBAgEBAQEBA=&hashes=df0%20d5e%20726%205cf%204c6%20d58%2025b%2050b%202%20d%2041f%2022c%20985%208aa%20a42%2014f%20571%20b67%2077d%2025d%20210%205cb...&field=cl

Extracting histograms

Extracts the histogram and the hashes of an image for use with the Lire sorting function. It will give you hashes and a truncated query for BitSampling (bs_list and bs_query) and MetricSpaces (ms_list and ms_query), but the latter only if it's available. the return values for bs_list and ms_list are ordered by ascending document frequency (BitSampling) and distance from the image to the respective reference point.

This can also be used to convert generic feature like the ones used for deep features, into base64 encoded feature strings and to obtain the appropriate queries for hashing based queries. If the field is sf_ha (or just sf), it is assumed that the extract parameter contains a comma separated list of doubles to be converted in a GenericGlobalShortFeatureVector.

Parameters:

  • extract .. the URL of the image. Note that the image has to be accessible by the web server Java has to be able to read it.
  • field .. gives the feature field to search for (optional, default=cl_ha, values see above, works also without the _ha suffix.)
  • accuracy .. double in [0.05, 1] indicates how many query terms should be in the queries (optional, default=0.33).

Examples:

Extraction from an image file:

lireq?extract=http://url.to/image.png&field=eh

results in

{
  "responseHeader":{
    "status":0,
    "QTime":141,
    "params":{
      "q":"*:*",
      "extract":"http://localhost:8983/solr/test/US76287460.png",
      "field":"eh",
      "_":"1544015258504"}},
  "histogram":"s7PQsraSkuCAkbG0xMPkk7PAgICww6K01YKRkICAosTSxMeFtOGjpQ==",
  "bs_list":["957","a26", "4a2", "276", ... ],
  "bs_query":"957 a26 4a2 276 e19 bf0 8b9 b2 ...",
  "ms_list":["R001902", "R001640", "R000511", ...],
  "ms_query":"R001902^1.00 R001640^0.88 ..."
  }

Extraction from a double histogram:

lireq?extract=0,0,0,1,1,1,1&field=sf

results in

{
  "responseHeader": {
    "status": 0,
    "QTime": 2,
    "params": {
      "q": "*:*",
      "extract": "0,0,0,1,1,1,1",
      "field": "sf",
      "_": "1544015258504"
    }
  },
  "histogram": "AAAAAAAAAf8B\/wH\/Af8=",
  "bs_list": ["cd2", "2a5", "612", "d8", "510", "3e1", "d95", ...
  ],
  "bs_query": "cd2 2a5 612 d8 510 ..."
}

Function queries with lirefunc

The function lirefunc(arg1,arg2) is available for function queries. Two arguments are necessary and are defined as:

  • Feature to be used for computing the distance between result and reference image. Possible values are {cl, ph, eh, jc}
  • Actual Base64 encoded feature vector of the reference image. It can be obtained by calling LireFeature.getByteRepresentation() and by Base64 encoding the resulting byte[] data or by using the extract feature of the RequestHandler
  • Optional maximum distance for those data items that cannot be processed, ie. don't feature the respective field.

Note that if you send the parameters using an URL you might take extra care of the URL encoding, ie. white space, the "=" sign, etc.

Examples:

  • [solrurl]/select?q=*:*&fl=id,lirefunc(cl,"FQY5DhMYDg...AQEBA=") – adding the distance to the reference image to the results
  • [solrurl]/select?q=*:*&sort=lirefunc(cl,"FQY5DhMYDg...AQEBA=")+asc – sorting the results based on the distance to the reference image

If you extract the features yourself, use code like his one:

// ColorLayout
ColorLayout cl = new ColorLayout();
cl.extract(ImageIO.read(new File("...")));
String arg1 = "cl";
String arg2 = Base64.getEncoder().encodeToString(cl.getByteArrayRepresentation());

// PHOG
PHOG ph = new PHOG();
ph.extract(ImageIO.read(new File("...")));
String arg1 = "ph";
String arg2 = Base64.getEncoder().encodeToString(ph.getByteArrayRepresentation());

If you experiencing problems with a query having always the same results after changing the lirefunc parameters, you have to disable the cache of ordered search results by setting the size of the queryResultCacheto 0. The downside of this approach is that for paging the query has to be run through Solr over and over again.

Installation

We assume you have a Solr server installed and running and you have already added a core. If not, check src/main/docs/install.md or don't even try but go for the docker image. First run the dist task by gradlew distForSolr command in folder where the build.gradle file is found to create a plugin jar. Then copy jars: cp ./dist/*.jar /opt/solr/server/solr-webapp/webapp/WEB-INF/lib/. Then add the new RequestHandler and the ValueSourceParser have to be registered in the solrconfig.xml file:

        explicit
        json
        true

Use of the request handler is detailed above.

You'll also need the respective fields in the managed-schema file:

Do not forget to add the custom field at the very same file:

Indexing

Check ParallelSolrIndexer.java for indexing. It creates XML documents (either one per image or one single large file) to be sent to the Solr Server.

ParallelSolrIndexer

This help text is shown if you s

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaimage-retrievalliresolr-pluginsolr-server

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言