Spaces:
Sleeping
Sleeping
woodserino
commited on
Commit
·
d71e8fa
1
Parent(s):
310e607
Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,18 @@ import os
|
|
3 |
import random
|
4 |
from src.model import simlarity_model as model
|
5 |
from src.similarity.similarity import Similarity
|
|
|
|
|
6 |
|
7 |
similarity = Similarity()
|
8 |
models = similarity.get_models()
|
9 |
|
10 |
-
def check(img_main,
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
return result
|
13 |
|
14 |
with gr.Blocks() as demo:
|
@@ -27,6 +33,6 @@ with gr.Blocks() as demo:
|
|
27 |
).style(grid=[2], height="auto")
|
28 |
|
29 |
submit_btn = gr.Button('Check Similarity')
|
30 |
-
submit_btn.click(fn=check,inputs=[img_main,
|
31 |
|
32 |
demo.launch()
|
|
|
3 |
import random
|
4 |
from src.model import simlarity_model as model
|
5 |
from src.similarity.similarity import Similarity
|
6 |
+
from PIL import Image
|
7 |
+
import glob
|
8 |
|
9 |
similarity = Similarity()
|
10 |
models = similarity.get_models()
|
11 |
|
12 |
+
def check(img_main, model_idx):
|
13 |
+
image_list = []
|
14 |
+
for filename in glob.glob('images/*.jpg'):
|
15 |
+
im=Image.open(filename)
|
16 |
+
image_list.append(im)
|
17 |
+
result = similarity.check_similarity([img_main] + image_list, models[model_idx])
|
18 |
return result
|
19 |
|
20 |
with gr.Blocks() as demo:
|
|
|
33 |
).style(grid=[2], height="auto")
|
34 |
|
35 |
submit_btn = gr.Button('Check Similarity')
|
36 |
+
submit_btn.click(fn=check,inputs=[img_main, model], outputs=gallery)
|
37 |
|
38 |
demo.launch()
|