[Bug]: "Send To xxx" action fail with AttributeError: 'NoneType' object has no attribute 'startswith' when using batch mode
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What happened?
When I generate an image with just one result, the Send To actions works just fine. When I either increase the "Batch count" or "Batch size" and I click one of the images, then no image is shown in the Inpaint (for example)
The call stack I get in the console:
Traceback (most recent call last):
File "S:\auto1111\venv\lib\site-packages\gradio\routes.py", line 394, in run_predict
output = await app.get_blocks().process_api(
File "S:\auto1111\venv\lib\site-packages\gradio\blocks.py", line 1075, in process_api
result = await self.call_function(
File "S:\auto1111\venv\lib\site-packages\gradio\blocks.py", line 884, in call_function
prediction = await anyio.to_thread.run_sync(
File "S:\auto1111\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "S:\auto1111\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "S:\auto1111\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
result = context.run(func, *args)
File "S:\auto1111\modules\generation_parameters_copypaste.py", line 79, in image_from_url_text
if filedata.startswith("data:image/png;base64,"):
AttributeError: 'NoneType' object has no attribute 'startswith'
Steps to reproduce the problem
- Type any prompt
- Press Generate with either Batch setting set a value higher than 1
- Press a Send to button, for example "Send to Inpaint"
- Image is not transferred and a console error appears.
What should have happened?
I expected the selected image to be transferred to the Inpaint UI.
Commit where the problem happens
aba5d639fb20df035243246cf5edb143eda94546
What platforms do you use to access the UI ?
Windows
What browsers do you use to access the UI ?
Google Chrome
Command Line Arguments
No
List of extensions
No
Console logs
venv "S:\auto1111\venv\Scripts\Python.exe"
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]
Commit hash: aba5d639fb20df035243246cf5edb143eda94546
Installing requirements for Web UI
Launching Web UI with arguments:
No module 'xformers'. Proceeding without it.
Loading weights [6ce0161689] from S:\auto1111\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors
Creating model from config: S:\auto1111\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying cross attention optimization (Doggettx).
Textual inversion embeddings loaded(0):
Model loaded in 2.9s (load weights from disk: 0.2s, create model: 0.4s, apply weights to model: 0.5s, apply half(): 0.5s, move model to device: 0.5s, load textual inversion embeddings: 0.8s).
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Startup time: 6.9s (import torch: 1.1s, import gradio: 0.8s, import ldm: 0.3s, other imports: 0.7s, load scripts: 0.6s, load SD checkpoint: 3.0s, create ui: 0.3s).
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:06<00:00, 2.99it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:06<00:00, 3.27it/s]
Traceback (most recent call last):█████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:06<00:00, 3.51it/s]
File "S:\auto1111\venv\lib\site-packages\gradio\routes.py", line 394, in run_predict
output = await app.get_blocks().process_api(
File "S:\auto1111\venv\lib\site-packages\gradio\blocks.py", line 1075, in process_api
result = await self.call_function(
File "S:\auto1111\venv\lib\site-packages\gradio\blocks.py", line 884, in call_function
prediction = await anyio.to_thread.run_sync(
File "S:\auto1111\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "S:\auto1111\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "S:\auto1111\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
result = context.run(func, *args)
File "S:\auto1111\modules\generation_parameters_copypaste.py", line 157, in send_image_and_dimensions
img = image_from_url_text(x)
File "S:\auto1111\modules\generation_parameters_copypaste.py", line 70, in image_from_url_text
if filedata.startswith("data:image/png;base64,"):
AttributeError: 'NoneType' object has no attribute 'startswith'
Additional information
No response
same issue here.. any.. fixes yet?

Issue is auto did not update the function selected_gallery_index() in ui.js
https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/91ae48fd7e20c60d6374f340cac0939f56d87048/javascript/ui.js#L10-L18
That .gallery-item class was changed to .thumbnail-item, so the JS does not pass any image to the backend and becomes NoneType
Correct version:
function selected_gallery_index(){
var buttons = gradioApp().querySelectorAll('[style="display: block;"].tabitem div[id$=_gallery] .thumbnails > .thumbnail-item')
var button = gradioApp().querySelector('[style="display: block;"].tabitem div[id$=_gallery] .thumbnails > .thumbnail-item.selected')
var result = -1
buttons.forEach(function(v, i){ if(v==button) { result = i } })
return result
}
Also another bug
There currently has to be a selected image in the gallery for the Send to img2img button to work, if not same error appears. So it should default to sending the first gallery item if none is selected
Fix confirmed. Didn't even have to restart the server! Thanks for a fast response! (only locally ofc)
Issue is auto did not update the function
selected_gallery_index()inui.jshttps://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/91ae48fd7e20c60d6374f340cac0939f56d87048/javascript/ui.js#L10-L18
That
.gallery-itemclass was changed to.thumbnail-item, so the JS does not pass any image to the backend and becomesNoneTypeCorrect version:
function selected_gallery_index(){ var buttons = gradioApp().querySelectorAll('[style="display: block;"].tabitem div[id$=_gallery] .thumbnails > .thumbnail-item') var button = gradioApp().querySelector('[style="display: block;"].tabitem div[id$=_gallery] .thumbnails > .thumbnail-item.selected') var result = -1 buttons.forEach(function(v, i){ if(v==button) { result = i } }) return result }
while the UI is still incredibly laggy, this seems to have worked. can finally send images to text2img. thank you, space-nuko!
Same problem, what's the fix? Ok yup I figured it out you have to edit that file, it works now. I have another issue where the image thing doesnt pop up where you normally save to favorites and stuff in the image2image tab, where it generates the image, normally you click on an image and it magnifies it in a pop up dialog right? That also doesn't pop up, it just clicks through the images now like a next button could this be related?