import os import gradio as gr def get_openai_key(): return os.getenv("OPENAI_API_KEY","") def process_image(openai_api_key,image_src): print(openai_api_key) print(image_src) # Combine the outputs into a single HTML output custom_output = f'''

Image->Text:

''' return custom_output openai_api_key = gr.Textbox(value=get_openai_key(),label="OpenAI API Key",type="password") image_input = gr.inputs.Image(type='filepath', label="Input Image") title_with_logo = \ f'Understanding Image with Text' extra_title = r'![vistors](https://visitor-badge.glitch.me/badge?page_id=fingerrec.Image2Paragraph)\n\n' interface = gr.Interface( fn=lambda openai_api_key,image, options: process_image(openai_api_key,image), inputs=[openai_api_key, image_input, gr.CheckboxGroup( label="Options", choices=["Image Generation", "Semantic Segment"], ), ], outputs=gr.outputs.HTML(), title=title_with_logo, description=extra_title +""" Image.txt. This code support image to text transformation. Then the generated text can do retrieval, question answering et al to conduct zero-shot. \n Github: https://github.com/showlab/Image2Paragraph \n Twitter: https://twitter.com/awinyimgprocess/status/1646225454599372800?s=46&t=HvOe9T2n35iFuCHP5aIHpQ \n For online demo, we use smallest model to speed up. For better result, look for github for using large models. \n Ttext2image model is controlnet, which used canny edge as reference. \n To speed up, we generate image with small size 384, run the code local for high-quality sample. """ ) # Launch the interface interface.launch()