V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
AnyISalIn
V2EX  ›  程序员

发现 gradio.app 用来开发 demo 程序很方便

  •  
  •   AnyISalIn ·
    anyisalin · 292 天前 · 2146 次点击
    这是一个创建于 292 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近研究 stable-diffusion-webui ,开发了一个云推理的插件 https://github.com/omniinfer/sd-webui-cloud-inference

    开发插件的过程中,发现 https://gradio.app/docs 这个框架写出来的代码很简洁,适合写 demo 程序。

    11 条回复    2023-07-11 11:13:46 +08:00
    Winrey
        1
    Winrey  
       292 天前
    但是到现在 gradio 对动态可变数量也没有什么好的组件
    AnyISalIn
        2
    AnyISalIn  
    OP
       292 天前
    @Winrey 嗯,这是一个比较大的问题,目前大家是通过一个手动 refresh button 来解决的,通过 js 定时 refresh 也可以解决部分问题。
    alexapollo
        3
    alexapollo  
       292 天前   ❤️ 1
    https://github.com/geekan/MetaGPT/

    python startup.py "写一个基于 gradio 的 xxx 系统"
    Betsy
        4
    Betsy  
       292 天前 via iPhone
    Streamlit 呢?
    zhzy
        5
    zhzy  
       292 天前
    是挺方便,就是不太好看。
    如果为了好看去改样式,好像又不是很合理...
    shic
        6
    shic  
       292 天前   ❤️ 1
    还有 nicegui ,pywebio
    akaHenry
        7
    akaHenry  
       292 天前
    @shic python web gui 方案, 写 web app, 使用 docker 部署, 挺方便.

    但是, 通病问题, 打包成 desktop app, 坑非常多.

    PyInstaller 之类的工具, 真的是一言难尽. 限制了英语场景.

    之前尝试打包 nicegui, 包是打出来, 但是不 work, 也看不到报错 log. 而且还有内存泄露, 进程不停的崩溃+重开.

    离谱.
    SoulMelody
        8
    SoulMelody  
       291 天前
    @akaHenry 可以试试 cx_Freeze ,除了不支持单文件模式,打个包还是不在话下的
    akaHenry
        9
    akaHenry  
       291 天前
    @SoulMelody

    试了下 cx_Freeze, 确实打出来的包, 看起来正常多了. (包内容文件, 依赖似乎都在)


    https://github.com/better-py/learn-py/blob/main/packages/py-try/try-nicegui/build2.py#L61


    我在 macOS 下, 用 cx_Freeze 打包 nicegui 示例. 不过打开还是会崩溃, 查到的崩溃 log 如下:

    nicegui 默认使用 fastapi 启动了 端口. (web 方式).

    这里的报错, 是端口有问题. 感兴趣的话, 可以看我上面贴的链接, 是不是我的 build 配置参数有问题?



    "reportNotes" : [
    "_dyld_process_info_create failed with 6",
    "dyld_process_snapshot_get_shared_cache failed",
    "Failed to create CSSymbolicatorRef - corpse still valid ¯\\_(ツ)_\/¯",
    "thread_get_state(PAGEIN) returned 0x10000003: (ipc\/send) invalid destination port",
    "thread_get_state(EXCEPTION) returned 0x10000003: (ipc\/send) invalid destination port",
    "thread_get_state(FLAVOR) returned 0x10000003: (ipc\/send) invalid destination port"
    ]
    akaHenry
        10
    akaHenry  
       291 天前
    打包脚本, 运行入口在这里:

    https://github.com/better-py/learn-py/blob/main/packages/py-try/try-nicegui/Taskfile.yml#L56


    ```

    poetry run python build2.py bdist_dmg

    ```
    SoulMelody
        11
    SoulMelody  
       291 天前
    @akaHenry https://github.com/zauberzeug/nicegui/issues/355 看起来是 nicegui 打包运行时必须改成使用 reload=False
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   867 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 20:48 · PVG 04:48 · LAX 13:48 · JFK 16:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.