microsoft / SoM

Set-of-Mark Prompting for GPT-4V and LMMs
MIT License
1.17k stars 95 forks source link

Run the program without gradio #35

Open oxygen-berry opened 5 months ago

oxygen-berry commented 5 months ago

Dear sir, I want to run the program directly locally, that is, input the image and output the segmented and marked image without using Gradio to generate the website. Is there any corresponding file? I try to modify the demo_som.py file, but I always get an error because of these two lines. _image = image['background'].convert('RGB') _mask = image['layers'][0].convert('L') if image['layers'] else None Can you give me some tips please?Thank you.

abrichr commented 5 months ago

If you're getting an error there, you're most likely using an outdated version of gradio. Make sure to pip install gradio==4.17.0 as per the Dockerfile.

Regarding running the project without gradio, you can take a look at how https://github.com/microsoft/SoM/blob/main/demo_som.py#L109 and https://github.com/microsoft/SoM/blob/main/demo_gpt4v_som.py#L131 are implemented, i.e. with calls to inference_semsam_m2m_auto, inference_sam_m2m_auto, etc.

The easiest way to use the project is with deploy.py. If you don't want to run it on EC2, you can simply follow the commands in the script section of https://github.com/microsoft/SoM/blob/main/docker-build-ec2.yml.j2#L25. Running this locally would look something like this:

            # Build the image
            sudo nvidia-docker build -t som .

            # Run the image
            sudo docker run -d -p 6092:6092 --gpus all --name som-container som