Skip to content

Commit

Permalink
fix gradio
Browse files Browse the repository at this point in the history
  • Loading branch information
continue-revolution committed Aug 31, 2023
1 parent 62ccb01 commit d0492ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This extension aim for connecting [AUTOMATIC1111 Stable Diffusion WebUI](https:/
- `2023/06/04`: [v1.5.1](https://github.com/continue-revolution/sd-webui-segment-anything/releases/tag/v1.5.1) `Upload Mask to ControlNet Inpainting` comes back in response to [ControlNet inpaint improvement](https://github.com/Mikubill/sd-webui-controlnet/discussions/1464). You should see a new tab beside `AutoSAM` after updating the extension. This feature will again be removed once ControlNet extension has its own uploading feature.
- `2023/06/13`: [v1.6.0](https://github.com/continue-revolution/sd-webui-segment-anything/releases/tag/v1.6.0) [SAM-HQ](https://github.com/SysCV/sam-hq) supported by [@SpenserCai](https://github.com/SpenserCai) and me. This is an "upgraded" SAM, created by researchers at ETH Zurich & HKUST. However, I cannot guarantee which one is better and you should make your own choice based on your own experiments. Go to [Installation](#installation) to get the link to the models.
- `2023/06/29`: [v1.6.1](https://github.com/continue-revolution/sd-webui-segment-anything/releases/tag/v1.6.1) [MobileSAM](https://github.com/ChaoningZhang/MobileSAM) supported. This is a tiny version of SAM, created by researchers at Kyung Hee University. Visit [here](https://github.com/continue-revolution/sd-webui-segment-anything/issues/139) for more information.
- `2023/08/31`: [v1.6.2](https://github.com/continue-revolution/sd-webui-segment-anything/releases/tag/v1.6.2) Support WebUI [v1.6.0](https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/tag/v1.6.0), Gradio v3.41.2

Note that support for some other variations of SAM, such as [Matting-Anything](https://github.com/SHI-Labs/Matting-Anything) and [FastSAM](https://github.com/CASIA-IVA-Lab/FastSAM) are still on the way. Support for these models, unlike MobileSAM, are non-trivial, especially FastSAM, which utilize a completely different pipeline, ultralytics/YOLO. Introducing these new works to the current codebase will make the original ugly-enough codebase more ugly. They will be supported once I finish a major refactor of the current codebase.

Expand Down
8 changes: 4 additions & 4 deletions scripts/sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def ui_dilation(sam_output_mask_gallery, sam_output_chosen_mask, sam_input_image
sam_dilation_checkbox = gr.Checkbox(value=False, label="Expand Mask")
with gr.Column(visible=False) as dilation_column:
sam_dilation_amt = gr.Slider(minimum=0, maximum=100, default=0, value=0, label="Specify the amount that you wish to expand the mask by (recommend 30)")
sam_dilation_output_gallery = gr.Gallery(label="Expanded Mask").style(grid=3)
sam_dilation_output_gallery = gr.Gallery(label="Expanded Mask", columns=3)
sam_dilation_submit = gr.Button(value="Update Mask")
sam_dilation_submit.click(
fn=update_mask,
Expand Down Expand Up @@ -601,7 +601,7 @@ def change_sam_device(use_cpu=False):
inputs=[dino_checkbox],
outputs=[dino_column],
show_progress=False)
sam_output_mask_gallery = gr.Gallery(label='Segment Anything Output').style(grid=3)
sam_output_mask_gallery = gr.Gallery(label='Segment Anything Output', columns=3)
sam_submit = gr.Button(value="Preview Segmentation", elem_id=f"{tab_prefix}run_button")
sam_result = gr.Text(value="", label="Segment Anything status")
sam_submit.click(
Expand Down Expand Up @@ -668,7 +668,7 @@ def change_sam_device(use_cpu=False):
"You can also utilize [Edit-Anything](https://github.com/sail-sg/EditAnything) and generate images according to random segmentation which preserve image layout.")
cnet_seg_processor, cnet_seg_processor_res, cnet_seg_gallery_input, cnet_seg_pixel_perfect, cnet_seg_resize_mode = ui_processor(use_cnet=(max_cn_num() > 0))
cnet_seg_input_image = gr.Image(label="Image for Auto Segmentation", source="upload", type="pil", image_mode="RGBA")
cnet_seg_output_gallery = gr.Gallery(label="Auto segmentation output").style(grid=2)
cnet_seg_output_gallery = gr.Gallery(label="Auto segmentation output", columns=2)
cnet_seg_submit = gr.Button(value="Preview segmentation image")
cnet_seg_status = gr.Text(value="", label="Segmentation status")
cnet_seg_submit.click(
Expand Down Expand Up @@ -716,7 +716,7 @@ def layout_show(mode):
with gr.Tabs():
with gr.TabItem(label="Single Image"):
crop_input_image = gr.Image(label="Image to be masked", source="upload", type="pil", image_mode="RGBA")
crop_output_gallery = gr.Gallery(label="Output").style(grid=3)
crop_output_gallery = gr.Gallery(label="Output", columns=3)
crop_padding = gr.Number(value=-2, visible=False, interactive=False, precision=0)
crop_resized_image = gr.Image(label="Resized image", source="upload", type="pil", image_mode="RGBA", visible=False)
crop_submit = gr.Button(value="Preview mask")
Expand Down

0 comments on commit d0492ac

Please sign in to comment.