import os import torch import numpy as np from fairseq import utils,tasks from utils.checkpoint_utils import load_model_ensemble_and_task from models.polyformer import PolyFormerModel import cv2 import torch import numpy as np from fairseq import utils, tasks from fairseq import checkpoint_utils from utils.eval_utils import eval_step from tasks.refcoco import RefcocoTask from models.polyformer import PolyFormerModel from PIL import Image from torchvision import transforms import cv2 import gradio as gr import math from io import BytesIO import base64 import re from demo import visual_grounding title = "PolyFormer" description = """
Project Page | Paper | Github Repo
Demo of PolyFormer for referring image segmentation and referring expression comprehension. Upload your own image or click any one of the examples, and write a description about a certain object. Then click \"Submit\" and wait for the result of grounding.
For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings.