better interface
Browse files11 unmodified lines12131415161716 unmodified lines343536373839404142434445464748495019 unmodified lines707172737475767 unmodified lines8485868788899025 unmodified lines11611711811911 unmodified lines)model.to(device)def output_generate(image):im = transform(image).unsqueeze(0).to(device)16 unmodified linesreturn open_clip.decode(generated[0].detach()).split("<end_of_text>")[0].replace("<start_of_text>", "")paths = sorted(pathlib.Path("images").glob("*.jpg"))with gr.Blocks(css=""".message.svelte-w6rprc.svelte-w6rprc.svelte-w6rprc {font-size: 20px; margin-top: 20px}#component-21 > div.wrap.svelte-w6rprc {height: 600px;}""") as iface:state = gr.State([])# gr.Markdown(title)# gr.Markdown(description)# gr.Markdown(article)with gr.Row():with gr.Column(scale=1):19 unmodified linestop_p = gr.Slider(minimum=0.0,maximum=1.0,value=1.0,step=0.1,interactive=True,label="Top p (used with nucleus sampling)",7 unmodified linesvalue=20, label="Maximum Sequence Length", precision=0, interactive=True)with gr.Column(scale=1.8):with gr.Column():caption_output = gr.Textbox(lines=1, label="Caption Output")25 unmodified lines# article="""""",# examples=[path.as_posix() for path in paths],# )iface.launch()11 unmodified lines12131415161718192021222316 unmodified lines404142434445464748495019 unmodified lines707172737475767 unmodified lines8485868788899025 unmodified lines11611711811912012112212312411 unmodified lines)model.to(device)title="""<h1 align="center">CoCa: Contrastive Captioners</h1>"""description=("""<br> An open source implementation of <strong>CoCa: Contrastive Captioners are Image-Text Foundation Models</strong> <a href=https://arxiv.org/abs/2205.01917>https://arxiv.org/abs/2205.01917.</a><br> Built using <a href=https://github.com/mlfoundations/open_clip>open_clip</a> with an effort from <a href=https://laion.ai/>LAION</a>.<br> For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings.<a href="https://huggingface.co/spaces/laion/CoCa?duplicate=true"> <img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>""")def output_generate(image):im = transform(image).unsqueeze(0).to(device)16 unmodified linesreturn open_clip.decode(generated[0].detach()).split("<end_of_text>")[0].replace("<start_of_text>", "")paths = sorted(pathlib.Path("images").glob("*.jpg"))with gr.Blocks() as iface:state = gr.State([])gr.Markdown(title)gr.Markdown(description)with gr.Row():with gr.Column(scale=1):19 unmodified linestop_p = gr.Slider(minimum=0.0,maximum=1.0,value=0.5,step=0.1,interactive=True,label="Top p (used with nucleus sampling)",7 unmodified linesvalue=20, label="Maximum Sequence Length", precision=0, interactive=True)with gr.Column(scale=1):with gr.Column():caption_output = gr.Textbox(lines=1, label="Caption Output")25 unmodified lines# article="""""",# examples=[path.as_posix() for path in paths],# )examples = gr.Examples(examples=[path.as_posix() for path in paths],inputs=[image_input],)iface.launch()
app.py+16-11