Update demo/mask_utils.py
Browse files- demo/mask_utils.py +0 -25
demo/mask_utils.py
CHANGED
@@ -4,31 +4,6 @@ import numpy as np
|
|
4 |
import torch
|
5 |
import gradio as gr
|
6 |
|
7 |
-
class ImageSketcher(gr.Image):
|
8 |
-
"""
|
9 |
-
Code is from https://github.com/jshilong/GPT4RoI/blob/7c157b5f33914f21cfbc804fb301d3ce06324193/gpt4roi/app.py#L365
|
10 |
-
|
11 |
-
Fix the bug of gradio.Image that cannot upload with tool == 'sketch'.
|
12 |
-
"""
|
13 |
-
|
14 |
-
is_template = True # Magic to make this work with gradio.Block, don't remove unless you know what you're doing.
|
15 |
-
|
16 |
-
def __init__(self, **kwargs):
|
17 |
-
super().__init__(tool='boxes', **kwargs)
|
18 |
-
|
19 |
-
def preprocess(self, x):
|
20 |
-
if x is None:
|
21 |
-
return x
|
22 |
-
if self.tool == 'boxes' and self.source in ['upload', 'webcam']:
|
23 |
-
if isinstance(x, str):
|
24 |
-
x = {'image': x, 'boxes': []}
|
25 |
-
else:
|
26 |
-
assert isinstance(x, dict)
|
27 |
-
assert isinstance(x['image'], str)
|
28 |
-
assert isinstance(x['boxes'], list)
|
29 |
-
x = super().preprocess(x)
|
30 |
-
return x
|
31 |
-
|
32 |
def process_mask_to_show(mask):
|
33 |
'''
|
34 |
Process the mask to show on the gradio.Image
|
|
|
4 |
import torch
|
5 |
import gradio as gr
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
def process_mask_to_show(mask):
|
8 |
'''
|
9 |
Process the mask to show on the gradio.Image
|