stable-diffusion-webui
stable-diffusion-webui copied to clipboard
[Feature Request]: enable a webcam as image input
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What would your feature do ?
grab an image from a webcam and use it for processing then grabbing a new image when done.
Proposed workflow
- Go to .... the img2img tab
- Press .... an not yet excisting "use camera" button
- Press .... an not yet excisting "loop" toggle ui element if desired
- Press ... Generate
Additional information
https://www.youtube.com/watch?v=g75ipNzWnbo the video here gives an impression of the process im sure lots of us would enjoy
Yes this would be a great experience
This feature world be usefull for me.
+1
You can easily make the UI take a webcam as input by modifying this one line
https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/5ab7f213bec2f816f9c5644becb32eb72c8ffb89/modules/ui.py#L707
change your local stable-diffusion-webui/modules/ui.py to say webcam i.e.
init_img = gr.Image(label="Image for img2img", elem_id="img2img_image", show_label=False, source="webcam", interactive=True, type="pil", tool="editor", image_mode="RGBA").style(height=480)
then restart ./webui.sh. Tested and works on MacOS.
You can easily make the UI take a webcam as input by modifying this one line
https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/5ab7f213bec2f816f9c5644becb32eb72c8ffb89/modules/ui.py#L707
change your local
stable-diffusion-webui/modules/ui.pyto saywebcami.e.init_img = gr.Image(label="Image for img2img", elem_id="img2img_image", show_label=False, source="webcam", interactive=True, type="pil", tool="editor", image_mode="RGBA").style(height=480)then restart
./webui.sh. Tested and works on MacOS.
thanks, I can see the webcam but when I hit 'generate' I get an error "AttributeError: 'NoneType' object has no attribute 'split' "
+1
You can easily make the UI take a webcam as input by modifying this one line
https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/5ab7f213bec2f816f9c5644becb32eb72c8ffb89/modules/ui.py#L707
change your local
stable-diffusion-webui/modules/ui.pyto saywebcami.e.init_img = gr.Image(label="Image for img2img", elem_id="img2img_image", show_label=False, source="webcam", interactive=True, type="pil", tool="editor", image_mode="RGBA").style(height=480)then restart
./webui.sh. Tested and works on MacOS.
sounds like OP means they'd like a live webcam input that loops like a video, rather than taking a simple image and generating based off of that
You get "AttributeError: 'NoneType' object has no attribute 'split' " because it doesn't return an image unless you press the camera icon.
Worked for me with the following change. Which combined with "generate forever" option gives a constantly updating render.
init_img = gr.Image(label="Image for img2img", elem_id="img2img_image", streaming=True, show_label=False, mirror_webcam=False, source="webcam", interactive=True, type="pil", tool="editor", image_mode="RGBA", height=opts.img2img_editor_height)
You get "AttributeError: 'NoneType' object has no attribute 'split' " because it doesn't return an image unless you press the camera icon.
Worked for me with the following change. Which combined with "generate forever" option gives a constantly updating render.
init_img = gr.Image(label="Image for img2img", elem_id="img2img_image", streaming=True, show_label=False, mirror_webcam=False, source="webcam", interactive=True, type="pil", tool="editor", image_mode="RGBA", height=opts.img2img_editor_height)
thanks that worked, how are you toggling between normal image upload and webcam? it'll be great if there was a new tab for the input type to be webcam
You get "AttributeError: 'NoneType' object has no attribute 'split' " because it doesn't return an image unless you press the camera icon. Worked for me with the following change. Which combined with "generate forever" option gives a constantly updating render.
init_img = gr.Image(label="Image for img2img", elem_id="img2img_image", streaming=True, show_label=False, mirror_webcam=False, source="webcam", interactive=True, type="pil", tool="editor", image_mode="RGBA", height=opts.img2img_editor_height)thanks that worked, how are you toggling between normal image upload and webcam? it'll be great if there was a new tab for the input type to be webcam
I'm not. Yeah to do that would require a new tab. Which shouldn't be too hard to implement.
thanks, I tried mucking around with it, the easiest way is just to replace the input in the sketch tab since I dont use the sketch function anyway, works great
Many helps! But here is a new question, if I want to change the source to virtual camera such as OBS, how can I set it?