Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 80c4fe8

Browse files
committedOct 20, 2022
update the web demo
1 parent 357c9de commit 80c4fe8

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed
 

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dataset/
22
**__pycache__**
33
.vscode
4+
*.DS_Store

‎kg_query/main.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import argparse
88
import numpy as np
99
from tqdm import tqdm
10+
from pprint import pprint
1011

1112
from .query_embds import QueryEmbds
1213
from img_models.generate_features import ImgFeatures
@@ -153,7 +154,24 @@ def generate_img_results(self, image_path, num_img=10):
153154
default='/scratch/sid/dataset_embeddings',
154155
help='Path to the directory containing the embeddings',
155156
)
157+
parser.add_argument(
158+
'-n',
159+
default=10,
160+
type=int,
161+
help='Number of results to show',
162+
)
163+
parser.add_argument(
164+
'-p',
165+
required=True,
166+
help='Path to the image for quering the DBpedia articles',
167+
)
156168
args = parser.parse_args()
157169
ranked_list = RankedList()
158-
images_ranked_list, uris_ranked_list = ranked_list.generate_results(0)
159-
print(images_ranked_list[:10])
170+
images_ranked_list, uris_ranked_list = ranked_list.generate_img_results(
171+
image_path=args.p,
172+
num_img=args.n,
173+
)
174+
print('List of DBpedia articles...')
175+
print(f'Rank\tURI')
176+
for i, uri in enumerate(uris_ranked_list):
177+
print(f'{i+1}\t{uri}')

‎website_demo/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
ranked_list = RankedList()
1111

1212

13-
@app.route('/upload')
13+
@app.route('/')
1414
def upload_file_():
1515
return render_template('upload.html')
1616

‎website_demo/templates/results.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Image-based DBpedia Search</title>
5+
<title>Image-based Knowledge Graph Query Framework</title>
66
</head>
77
<body>
88
<form action="/" method="get">
9-
<h1 align="center">Image-based DBpedia Search</h1>
9+
<h1 align="center">Image-based Knowledge Graph Query Framework</h1>
1010

1111
<div style="display:flex">
1212
<div style="flex:1;padding-right:5px;padding-left:5px">

0 commit comments

Comments
 (0)