Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web demo share (text 2 img) #8

Closed
baiyutang opened this issue Jul 5, 2023 · 0 comments
Closed

web demo share (text 2 img) #8

baiyutang opened this issue Jul 5, 2023 · 0 comments

Comments

@baiyutang
Copy link

baiyutang commented Jul 5, 2023

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")

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

@yaoyuanTHU yaoyuanTHU pinned this issue Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants