keras search engine
1.0.0
Keras에서 구현 된 간단한 문서 및 이미지 검색 엔진
GOTO KERAS_SEARCH_ENGINE_WEB 디렉토리 및 다음 명령을 실행하십시오.
python flaskr.py이제 브라우저를 http : // localhost : 5000으로 이동하면 시험해 볼 수 있습니다.
Web API 서버가 실행되면 다음 웹 API를 호출하여 새 문서를 색인 할 수 있습니다.
http://localhost:5000/index_text예를 들어 다음은 웹 API를 호출하여 일부 문서를 색인하는 컬 명령입니다.
curl -H ' Content-Type application/json ' -X POST -d ' {"doc":"Whether you think that you can, or that you can ' t, you are usually right. " }' http://localhost:5000/index_text
curl -H 'Content-Type application/json' -X POST -d '{ " doc " : " Try to learn something about everything and everything about something. " }' http://localhost:5000/index_text
curl -H 'Content-Type application/json' -X POST -d '{ " doc " : " You can avoid reality, but you cannot avoid the consequences of avoiding reality. " }' http://localhost:5000/index_text
curl -H 'Content-Type application/json' -X POST -d '{ " doc " : " A mathematician is a device for turning coffee into theorems. " }' http://localhost:5000/index_text
curl -H 'Content-Type application/json' -X POST -d '{ " doc " : " In theory, there is no difference between theory and practice. But in practice, there is. " }' http://localhost:5000/index_text
curl -H 'Content-Type application/json' -X POST -d '{ " doc " : " I find that the harder I work, the more luck I seem to have. " }' http://localhost:5000/index_text웹 API를 사용하여 쿼리하려면 다음 웹 API를 호출 할 수 있습니다.
curl -H ' Content-Type application/json ' -X POST -d ' {"query":"mathematician and coffee", "limit": 3, "model": "glove"} ' http://localhost:5000/search_textWeb API 서버가 실행되면 게시물 요청을 통해 다음 웹 API를 호출하여 새 이미지를 색인 할 수 있습니다.
http://localhost:5000/index_image다음 웹 API 게시물 요청을 호출하여 유사한 이미지를 쿼리 할 수 있습니다.
http://localhost:5000/search_image/10여기서 10은 반환 된 이미지 수의 한계입니다.
keras_search_engine_client에는 searchEngineClient 클래스도 있습니다. 샘플 코드는 다음과 같습니다.
from keras_search_engine_client . search_engine_client import SearchEngineClient
client = SearchEngineClient ()
# text indexing and search
doc_count = client . doc_count ()
if doc_count < 4 :
client . index_text ( 'Whether you think that you can, or that you can.' )
client . index_text ( 'Try to learn something about everything and everything about something.' )
client . index_text ( 'You can avoid reality, but you cannot avoid the consequences of avoiding reality.' )
client . index_text ( 'A mathematician is a device for turning coffee into theorems.' )
client . index_text ( 'In theory, there is no difference between theory and practice. But in practice, there is.' )
client . index_text ( 'I find that the harder I work, the more luck I seem to have.' )
client . search_text ( query = 'mathematician and coffee' , limit = 3 , model = 'glove' )
client . search_text ( query = 'mathematician and coffee' , limit = 3 , model = 'doc-encoder' )
# image indexing and search
client . index_image ( './images/Pokemon7.png' )
client . search_image ( './images/Pokemon1.jpg' , 6 )