File size: 1,658 Bytes
6d1366a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import torch

from .segmentation import InteractiveSegmentationInterface


_HEADER = """
<div style="text-align: center; margin: 10px">
    <h1> ⭐ <span style='color: #4D96FF;'>Gra</span><span style='color: #F9D923;'>Co</span>:
        <span style='color: #4D96FF;'>Gra</span>nularity-<span style='color: #F9D923;'>Co</span>trollable Interactive Segmentation </h1>
</div>
"""
# <p align="center">
#     <a href="https://arxiv.org/pdf/2303.13399.pdf"><img src="http://img.shields.io/badge/Paper-EB455F.svg?logo=arxiv" style="display:inline;"></a>
#     <a href="https://lkhl.github.io/MIS"><img src="http://img.shields.io/badge/Project_Page-7149C6.svg?logo=openproject" style="display:inline;"></a>
#     <a href="https://github.com/lkhl/MIS"><img src="https://img.shields.io/badge/Code-2B2A4C.svg?logo=github" style="display:inline;"></a>
#     <a href="https://lkhl.github.io/MIS"><img src="https://img.shields.io/badge/Video-FC2947.svg?logo=youtube" style="display:inline;"></a>
#     <a href="https://huggingface.co/spaces/lkhl/MIS?duplicate=true"><img src="https://img.shields.io/badge/Duplicate_This_Demo-EA906C?logo=buffer" style="display:inline;"></a>
# </p>


class GraCoWebApplication(object):

    def __init__(self, device: torch.device = None):
        if device is None:
            device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

        with gr.Blocks() as self._blocks:
            gr.Markdown(_HEADER)
            with gr.Tab('Granularity-Cotrollable Interactive Segmentation'):
                InteractiveSegmentationInterface(device=device)

    def launch(self):
        self._blocks.launch()