added options
Browse files
app.py
CHANGED
@@ -34,12 +34,16 @@ model.load_state_dict(state['val_model_dict'])
|
|
34 |
config = resolve_data_config({}, model=vit)
|
35 |
config['no_aug'] = True
|
36 |
config['interpolation'] = 'bilinear'
|
37 |
-
config['crop_pct'] = 1
|
38 |
-
config['crop_mode'] = 'border'
|
39 |
-
transform = create_transform(**config)
|
40 |
|
41 |
# Inference function
|
42 |
-
def query_image(input_img, query, binarize, eval_threshold):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
PIL_image = Image.fromarray(input_img, "RGB")
|
45 |
img = transform(PIL_image)
|
@@ -92,7 +96,8 @@ the model will binarize each propability based on set eval_threshold.
|
|
92 |
demo = gr.Interface(
|
93 |
query_image,
|
94 |
#inputs=[gr.Image(), "text", "checkbox", gr.Slider(0, 1, value=0.25)],
|
95 |
-
inputs=[gr.Image(type='numpy', label='input_img').style(height=
|
|
|
96 |
#outputs="image",
|
97 |
outputs=gr.Image(type='numpy', label='output').style(height=600, width=600),
|
98 |
title="Object Detection Using Textual Queries",
|
|
|
34 |
config = resolve_data_config({}, model=vit)
|
35 |
config['no_aug'] = True
|
36 |
config['interpolation'] = 'bilinear'
|
|
|
|
|
|
|
37 |
|
38 |
# Inference function
|
39 |
+
def query_image(input_img, query, binarize, eval_threshold, crop_mode, crop_pct):
|
40 |
+
|
41 |
+
if crop_mode == 'center':
|
42 |
+
crop_mode = None
|
43 |
+
|
44 |
+
config['crop_pct'] = crop_pct
|
45 |
+
config['crop_mode'] = crop_mode
|
46 |
+
transform = create_transform(**config)
|
47 |
|
48 |
PIL_image = Image.fromarray(input_img, "RGB")
|
49 |
img = transform(PIL_image)
|
|
|
96 |
demo = gr.Interface(
|
97 |
query_image,
|
98 |
#inputs=[gr.Image(), "text", "checkbox", gr.Slider(0, 1, value=0.25)],
|
99 |
+
inputs=[gr.Image(type='numpy', label='input_img').style(height=270, width=600), "text", "checkbox", gr.Slider(0, 1, value=0.25),
|
100 |
+
gr.inputs.Dropdown("center", "squash", "border", label='crop_mode'), gr.Slider(0, 1, value=1)],
|
101 |
#outputs="image",
|
102 |
outputs=gr.Image(type='numpy', label='output').style(height=600, width=600),
|
103 |
title="Object Detection Using Textual Queries",
|