Skip to content

Commit

Permalink
🐛fix for gradio 3.23 Image placement
Browse files Browse the repository at this point in the history
  • Loading branch information
gitadmin0608 committed Apr 2, 2023
1 parent 8450b65 commit 6b55dd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ For bugfix related modifications, see https://github.com/ashen-sensored/gradio/t


## Issues
- ~~The extension's mask color sketching function does not work well with chrome(extreme stuttering) due to gradio's Image component bug.~~ See prerequisite above. This fix is no longer suitable for latest webui version at 22bcc7be, with gradio dependency upgraded to 3.23. Please keep the browser scaling at 100% to avoid the bug.
- ~~The extension's mask color sketching function does not work well with chrome(extreme stuttering) due to gradio's Image component bug.~~ Please keep the browser scaling at 100% while creating blank canvas to avoid the bug.
See prerequisite above. The fix is no longer suitable for latest webui version at 22bcc7be, with gradio dependency upgraded to 3.23.


## Credits
Expand Down
2 changes: 1 addition & 1 deletion scripts/two_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def update_mask_denoise_flag(flag):

mask_denoise_checkbox.change(fn=update_mask_denoise_flag, inputs=[mask_denoise_checkbox], outputs=None)
canvas_image = gr.Image(source='upload', mirror_webcam=False, type='numpy', tool='color-sketch',
elem_id='twoshot_canvas_sketch', interactive=True).style(height=400)
elem_id='twoshot_canvas_sketch', interactive=True).style(height=480)
# aspect = gr.Radio(["square", "horizontal", "vertical"], value="square", label="Aspect Ratio",
# visible=False if is_shared_ui else True)
button_run = gr.Button("I've finished my sketch", elem_id="main_button", interactive=True)
Expand Down
6 changes: 6 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@
justify-content: center;
align-items: center;
}

#script_twoshot_tabs .gradio-image > div.fixed-height, #script_twoshot_tabs .gradio-image > div.fixed-height img {
height: 480px !important;
max-height: 480px !important;
min-height: 480px !important;
}

3 comments on commit 6b55dd5

@Lalimec
Copy link

@Lalimec Lalimec commented on 6b55dd5 May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still having problems with the masks I draw. Nothing happens when I click "I've finished my drawing.

image

Traceback (most recent call last):
  File "/home/ubuntu/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/routes.py", line 399, in run_predict
    output = await app.get_blocks().process_api(
  File "/home/ubuntu/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1299, in process_api
    result = await self.call_function(
  File "/home/ubuntu/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1022, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/home/ubuntu/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/home/ubuntu/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/home/ubuntu/stable-diffusion-webui/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/home/ubuntu/stable-diffusion-webui/extensions/stable-diffusion-webui-two-shot/scripts/two_shot.py", line 322, in process_sketch
    visibilities[j] = gr.update(visible=True)
IndexError: list assignment index out of range
Webui and Pythonversion

Python 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:36:39) [GCC 10.4.0]
Commit hash: 5ab7f213bec2f816f9c5644becb32eb72c8ffb89

@zerotwoo002
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will the extension be updated?

@yl-yue
Copy link

@yl-yue yl-yue commented on 6b55dd5 Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gradio>=3.32.0, the following exception will be thrown:

Traceback (most recent call last):
  File "/root/miniconda3/envs/xl_env/lib/python3.10/site-packages/gradio/routes.py", line 422, in run_predict
    output = await app.get_blocks().process_api(
  File "/root/miniconda3/envs/xl_env/lib/python3.10/site-packages/gradio/blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "/root/miniconda3/envs/xl_env/lib/python3.10/site-packages/gradio/blocks.py", line 1260, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
  File "/root/miniconda3/envs/xl_env/lib/python3.10/site-packages/gradio/components.py", line 4457, in postprocess
    file = self.img_array_to_temp_file(img, dir=self.DEFAULT_TEMP_DIR)
  File "/root/miniconda3/envs/xl_env/lib/python3.10/site-packages/gradio/components.py", line 355, in img_array_to_temp_file
    return self.pil_to_temp_file(pil_image, dir, format="png")
TypeError: save_pil_to_file() got an unexpected keyword argument 'format'

Please sign in to comment.