File size: 1,730 Bytes
ee2879f
 
 
 
 
 
a30857f
 
edffb64
c265fbf
 
 
 
 
 
4cc8653
ee2879f
 
 
 
 
edffb64
ee2879f
 
a30857f
4cc8653
 
ee2879f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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'''
    <h2>Image->Text:</h2>
    '''
    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()