Spaces:
Running
on
T4
Running
on
T4
liuyizhang
commited on
Commit
β’
91f6a3d
1
Parent(s):
b902809
update app.py
Browse files
app.py
CHANGED
@@ -230,6 +230,9 @@ device = "cuda"
|
|
230 |
device = get_device()
|
231 |
print(f'device={device}')
|
232 |
|
|
|
|
|
|
|
233 |
# initialize groundingdino model
|
234 |
logger.info(f"initialize groundingdino model...")
|
235 |
groundingdino_model = load_model_hf(config_file, ckpt_repo_id, ckpt_filenmae)
|
@@ -326,13 +329,14 @@ def run_grounded_sam(input_image, text_prompt, task_type, inpaint_prompt, box_th
|
|
326 |
text_prompt = text_prompt.strip()
|
327 |
if not ((task_type == 'inpainting' or task_type == 'remove') and mask_source_radio == mask_source_draw):
|
328 |
if text_prompt == '':
|
329 |
-
return [], gr.Gallery.update(label='Detection prompt is not found
|
|
|
|
|
|
|
330 |
|
331 |
file_temp = int(time.time())
|
332 |
logger.info(f'run_grounded_sam_[{file_temp}]_{task_type}_[{text_prompt}]_1_')
|
333 |
|
334 |
-
# make dir
|
335 |
-
os.makedirs(output_dir, exist_ok=True)
|
336 |
# load image
|
337 |
input_mask_pil = input_image['mask']
|
338 |
input_mask = np.array(input_mask_pil.convert("L"))
|
@@ -362,8 +366,8 @@ def run_grounded_sam(input_image, text_prompt, task_type, inpaint_prompt, box_th
|
|
362 |
groundingdino_model, image, text_prompt, box_threshold, text_threshold, device=groundingdino_device
|
363 |
)
|
364 |
if boxes_filt.size(0) == 0:
|
365 |
-
logger.info(f'run_grounded_sam_[{file_temp}]_{task_type}_[{text_prompt}]_1_[No objects detected]_')
|
366 |
-
return [], gr.Gallery.update(label='No objects detected, please try others
|
367 |
boxes_filt_ori = copy.deepcopy(boxes_filt)
|
368 |
|
369 |
pred_dict = {
|
|
|
230 |
device = get_device()
|
231 |
print(f'device={device}')
|
232 |
|
233 |
+
# make dir
|
234 |
+
os.makedirs(output_dir, exist_ok=True)
|
235 |
+
|
236 |
# initialize groundingdino model
|
237 |
logger.info(f"initialize groundingdino model...")
|
238 |
groundingdino_model = load_model_hf(config_file, ckpt_repo_id, ckpt_filenmae)
|
|
|
329 |
text_prompt = text_prompt.strip()
|
330 |
if not ((task_type == 'inpainting' or task_type == 'remove') and mask_source_radio == mask_source_draw):
|
331 |
if text_prompt == '':
|
332 |
+
return [], gr.Gallery.update(label='Detection prompt is not found!ππππ')
|
333 |
+
|
334 |
+
if input_image is None:
|
335 |
+
return [], gr.Gallery.update(label='Please upload a image!ππππ')
|
336 |
|
337 |
file_temp = int(time.time())
|
338 |
logger.info(f'run_grounded_sam_[{file_temp}]_{task_type}_[{text_prompt}]_1_')
|
339 |
|
|
|
|
|
340 |
# load image
|
341 |
input_mask_pil = input_image['mask']
|
342 |
input_mask = np.array(input_mask_pil.convert("L"))
|
|
|
366 |
groundingdino_model, image, text_prompt, box_threshold, text_threshold, device=groundingdino_device
|
367 |
)
|
368 |
if boxes_filt.size(0) == 0:
|
369 |
+
logger.info(f'run_grounded_sam_[{file_temp}]_{task_type}_[{text_prompt}]_1_[No objects detected, please try others.]_')
|
370 |
+
return [], gr.Gallery.update(label='No objects detected, please try others.ππππ')
|
371 |
boxes_filt_ori = copy.deepcopy(boxes_filt)
|
372 |
|
373 |
pred_dict = {
|