Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when run gradio_demo.py #95

Open
JingyuanBai opened this issue Nov 27, 2024 · 6 comments
Open

Error when run gradio_demo.py #95

JingyuanBai opened this issue Nov 27, 2024 · 6 comments

Comments

@JingyuanBai
Copy link

I cannot get the result picture when I run in the ubuntu or Windows os, It ocuurs
as "TypeError: 'NoneType' object cannot be interpreted as an integer"
If someone knows this error ,please tell me how to solve this problem, thank you !
All information as follows:
image 1/1 /root/OmniParser/imgs/saved_image_demo.png: 384x640 54 0s, 96.9ms
Speed: 3.7ms preprocess, 96.9ms inference, 209.1ms postprocess per image at shape (1, 3, 384, 640)
Traceback (most recent call last):
File "/home/vipuser/miniconda3/envs/omni/lib/python3.12/site-packages/gradio/queueing.py", line 624, in process_events
response = await route_utils.call_process_api(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vipuser/miniconda3/envs/omni/lib/python3.12/site-packages/gradio/route_utils.py", line 323, in call_process_api
output = await app.get_blocks().process_api(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vipuser/miniconda3/envs/omni/lib/python3.12/site-packages/gradio/blocks.py", line 2015, in process_api
result = await self.call_function(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vipuser/miniconda3/envs/omni/lib/python3.12/site-packages/gradio/blocks.py", line 1562, in call_function
prediction = await anyio.to_thread.run_sync( # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vipuser/miniconda3/envs/omni/lib/python3.12/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vipuser/miniconda3/envs/omni/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "/home/vipuser/miniconda3/envs/omni/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vipuser/miniconda3/envs/omni/lib/python3.12/site-packages/gradio/utils.py", line 865, in wrapper
response = f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/root/OmniParser/gradio_demo.py", line 60, in process
dino_labled_img, label_coordinates, parsed_content_list = get_som_labeled_img(image_save_path, yolo_model, BOX_TRESHOLD = box_threshold, output_coord_in_ratio=True, ocr_bbox=ocr_bbox,draw_bbox_config=draw_bbox_config, caption_model_processor=caption_model_processor, ocr_text=text,iou_threshold=iou_threshold, imgsz=imgsz)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/OmniParser/utils.py", line 442, in get_som_labeled_img
parsed_content_icon = get_parsed_content_icon(filtered_boxes, starting_idx, image_source, caption_model_processor, prompt=prompt,batch_size=batch_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vipuser/miniconda3/envs/omni/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/root/OmniParser/utils.py", line 102, in get_parsed_content_icon
for i in range(0, len(croped_pil_image), batch_size):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object cannot be interpreted as an integer

Image
Image

@Chirag-Mphasis
Copy link

I have the same issue. Were you able to resolve it?

@JingyuanBai
Copy link
Author

I have the same issue. Were you able to resolve it?

not yet. I am trying to find out where goes wrong

@xiaoyao9184
Copy link

xiaoyao9184 commented Dec 1, 2024

def get_som_labeled_img(img_path, model=None, BOX_TRESHOLD = 0.01, output_coord_in_ratio=False, ocr_bbox=None, text_scale=0.4, text_padding=5, draw_bbox_config=None, caption_model_processor=None, ocr_text=[], use_local_semantics=True, iou_threshold=0.9,prompt=None, scale_img=False, imgsz=None, batch_size=None):

change batch_size=32

but there are still other errors.

You can revert to version ba4e04f.

@fdciabdul
Copy link

same issue

is there any solutioin yet?

@asklar
Copy link
Member

asklar commented Dec 7, 2024

git checkout ba4e04fccb67070c718530e65570703f9f68a347 worked to convert the safetensors to pt step, and after that I could run the gradio demo

@asklar
Copy link
Member

asklar commented Jan 22, 2025

From owners:

With the latest code, to run gradio demo, simply run:

# For v1
python gradio_demo.py --icon_detect_model weights/icon_detect/best.pt --icon_caption_model florence2 
# For v1.5 
python gradio_demo.py --icon_detect_model weights/icon_detect_v1_5/model_v1_5.pt --icon_caption_model florence2 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants