Skip to content

web demo share (text 2 img) #8

Description

@baiyutang
import gradio as gr

from VisCPM import VisCPMPaint

# 修改你的模型地址
model_path = '/opt/ai/VisCPM/viscpm_paint_balance_checkpoint.pt'
painter = VisCPMPaint(model_path, image_safety_checker=False, prompt_safety_checker=False, add_ranker=True)
print("load  image model  success !")


def gen_img(txt, imgs):
    image = painter.generate(txt)
    imgs.append(image)
    return "",imgs,imgs


with gr.Blocks() as demo:
    imgs = gr.State([])
    gallery = gr.Gallery(label="生成图片")
    txt_message = gr.Textbox(label="输入文字")
    txt_message.submit(gen_img, [txt_message, imgs], [txt_message, gallery,imgs])

demo.queue(concurrency_count=1, max_size=20).launch(share=False, debug=True, server_port=7866,
                                                    server_name="0.0.0.0")

以上内容来自群友分享,欢迎加入社群交流

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions