gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.41k stars 2.53k forks source link

upgrade from 3.45 to 4.3, with lots of warning , and frontend stuck in loading status #6445

Closed luoweb closed 11 months ago

luoweb commented 11 months ago

Describe the bug

upgrade from 3.45 to 4.3, with lots of warning , and frontend stuck in loading status

Have you searched existing issues? 🔎

Reproduction

upgrade from 3.45 to 4.3, with lots of warning , and frontend stuck in loading status

![Uploading image.png…]()

Screenshot

![Uploading image.png…]()

Logs

frontend ERROR:

css.ts:18 

        GET http://localhost/assets/index-a7ca4fc2.css net::ERR_ABORTED 404 (Not Found)
(anonymous) @ css.ts:18
mount_css @ css.ts:12
connectedCallback @ main.ts:95
await in connectedCallback (async)
create_custom_element @ main.ts:211
(anonymous) @ main.ts:214
css.ts:15  Unable to preload CSS for http://localhost/assets/index-a7ca4fc2.css
(anonymous) @ css.ts:15
error (async)
(anonymous) @ css.ts:14
mount_css @ css.ts:12
connectedCallback @ main.ts:95
await in connectedCallback (async)
create_custom_element @ main.ts:211
(anonymous) @ main.ts:214
Gallery.svelte:226  Uncaught (in promise) TypeError: Cannot read properties of null (reading 'url')
    at Object.c (Gallery.svelte:226:37)
    at Object.c (Gallery.svelte:234:11)
    at Object.c (Gallery.svelte:276:10)
    at Object.c (Gallery.svelte:185:62)
    at create_component (svelte.js:3135:17)
    at Object.c (Index.svelte:88:20)
    at Object.c (Block.svelte:22:11)
    at Object.c (Block.svelte:22:11)
    at create_component (svelte.js:3135:17)
    at Object.c (Index.svelte:62:57)

backend ERROR:
2023-11-16 09:16:38.866 | INFO     | __main__:<module>:1365 - Gr State:[]
2023-11-16T09:16:38.866157+0800 INFO Gr State:[]
/Users/block/anaconda3/envs/grapp430/lib/python3.11/site-packages/gradio/blocks.py:928: UserWarning: api_name lambda already exists, using lambda_1
  warnings.warn(f"api_name {api_name} already exists, using {api_name_}")
/Users/block/anaconda3/envs/grapp430/lib/python3.11/site-packages/gradio/blocks.py:928: UserWarning: api_name lambda already exists, using lambda_2
  warnings.warn(f"api_name {api_name} already exists, using {api_name_}")
/Users/block/anaconda3/envs/grapp430/lib/python3.11/site-packages/gradio/blocks.py:928: UserWarning: api_name lambda already exists, using lambda_3
  warnings.warn(f"api_name {api_name} already exists, using {api_name_}")
/Users/block/anaconda3/envs/grapp430/lib/python3.11/site-packages/gradio/blocks.py:928: UserWarning: api_name lambda already exists, using lambda_4

System Info

Mac OS 13

Severity

I can work around it

abidlabs commented 11 months ago

Hi @luoweb can you please provide the code for your Gradio app that you are trying to upgrade? Or at least a minimal code example that we can use to reproduce the issue above? See: https://stackoverflow.com/help/minimal-reproducible-example

luoweb commented 11 months ago

Hi @luoweb can you please provide the code for your Gradio app that you are trying to upgrade? Or at least a minimal code example that we can use to reproduce the issue above? See: https://stackoverflow.com/help/minimal-reproducible-example

minimal reproduce code as follow, it's normal in 3.45 but stuck in 4.3

defined gallery ui and load with gallery value

with gr.Blocks(
    title="TestDemo",
    analytics_enabled=False,
    css=app_csslib.css,
    theme=gr.themes.Monochrome(
        primary_hue=gr.themes.colors.red, secondary_hue=gr.themes.colors.pink
    ),
) as chatapp:
    logger.info("Starting ChatApp...")
    outputGallery = gr.Gallery(
        label="Generated images",
        show_label=False,
        visible=True,
        elem_id="outputGallery",
        columns=1,
        rows=2,
        object_fit="none",#"contain", "cover", "fill", "none", or "scale-down"
        height="auto",
        scale=1,
        min_width=50,
        show_download_button=True,
        preview=True,
        selected_index=1
    )
    outputGallery.value = ast.literal_eval("[('https://7072-prod-6gml0tp96725fdc6-1302632202.tcb.qcloud.la/homegallery/IMG_3149.PNG?sign=0c8850014a78e3a3725d132b7298da09&t=1697089390','Hash Id: QmZ3NwdttMXQSErMGsWuaikmffdM3hH5py4ryZwRSzDFAv')]")
freddyaboulton commented 11 months ago

Hi @luoweb !

I think the issue is setting the value outside of the init. Also, the value is not a valid value for the gallery as the second entry of the list is not an image url or file. The following code works for me ( I had to remove reference to the css file)

with gr.Blocks(
    title="TestDemo",
    analytics_enabled=False,
    theme=gr.themes.Monochrome(
        primary_hue=gr.themes.colors.red, secondary_hue=gr.themes.colors.pink
    ),
) as chatapp:
    outputGallery = gr.Gallery(
        label="Generated images",
        show_label=False,
        visible=True,
        elem_id="outputGallery",
        columns=1,
        rows=2,
        object_fit="none",
        height="auto",
        scale=1,
        min_width=50,
        show_download_button=True,
        preview=True,
        selected_index=0,
        value=['https://7072-prod-6gml0tp96725fdc6-1302632202.tcb.qcloud.la/homegallery/IMG_3149.PNG?sign=0c8850014a78e3a3725d132b7298da09&t=1697089390']
    )

chatapp.launch()

Colab link: https://colab.research.google.com/drive/1jmJdiF08LW75ewzI5c_G3pRQr9XXjczl?usp=sharing

Going to close, let us know if you have other issues upgrading.