File size: 2,106 Bytes
035c6f2
a9f0f33
035c6f2
a9f0f33
035c6f2
 
a9f0f33
 
035c6f2
 
 
 
 
a9f0f33
035c6f2
 
 
 
 
 
 
 
 
 
 
 
 
a9f0f33
 
 
 
035c6f2
 
27a1da2
 
 
 
 
035c6f2
 
 
a9f0f33
035c6f2
a9f0f33
035c6f2
 
a9f0f33
 
 
035c6f2
a9f0f33
 
 
035c6f2
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import gradio as gr
from delf import DeepLocalFeatures

delf = DeepLocalFeatures()


def predict(image_a, image_b):
    return delf.match(image_a, image_b)


footer = r"""
<center>
<b>
Demo for <a href='https://www.tensorflow.org/hub/tutorials/tf_hub_delf_module'>DELF</a>
</b>
</center>
"""

coffe = r"""
<center>
<a href="https://www.buymeacoffee.com/leonelhs"> <img 
src="https://img.buymeacoffee.com/button-api/?text=Buy me a 
coffee&emoji=&slug=leonelhs&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000
&coffee_colour=ffffff" /></a>
</center>
"""

with gr.Blocks(title="DELF") as app:
    gr.HTML("<center><h1>Match images using DELF</h1></center>")
    gr.HTML("<center><h3>Neural network and logic for processing images to identify keypoints and their "
            "descriptors.</h3></center>")
    with gr.Row(equal_height=False):
        with gr.Column():
            with gr.Row(equal_height=True):
                with gr.Column():
                    input_img_a = gr.Image(type="pil", label="Input image A")
                with gr.Column():
                    input_img_b = gr.Image(type="pil", label="Input image B")
            run_btn = gr.Button(variant="primary")
        with gr.Column():
            output_img = gr.Image(type="pil", label="Output image")
            gr.ClearButton(components=[input_img_a, input_img_b, output_img], variant="stop")

    run_btn.click(predict, [input_img_a, input_img_b], [output_img])

    with gr.Row():
        blobs_a = [[f"examples/image_a/{x:02d}.jpg"] for x in range(1, 5)]
        examples_a = gr.Dataset(components=[input_img_a], samples=blobs_a)
        examples_a.click(lambda x: x[0], [examples_a], [input_img_a])
    with gr.Row():
        blobs_b = [[f"examples/image_b/{x:02d}.jpg"] for x in range(1, 5)]
        examples_b = gr.Dataset(components=[input_img_b], samples=blobs_b)
        examples_b.click(lambda x: x[0], [examples_b], [input_img_b])

    with gr.Row():
        gr.HTML(footer)
    with gr.Row():
        gr.HTML(coffe)

app.launch(share=False, debug=True, show_error=True)
app.queue()