|
import gradio as gr |
|
from PIL import Image, ImageDraw, ImageFont |
|
import io |
|
|
|
|
|
|
|
def create_html_page(input_image): |
|
|
|
image = Image.open(input_image) |
|
|
|
|
|
|
|
new_image = Image.new('RGB', (image.width, image.height + 50), color = 'white') |
|
new_image.paste(image, (0, 0)) |
|
draw = ImageDraw.Draw(new_image) |
|
|
|
|
|
color = (0, 0, 0) |
|
|
|
text = 'model output text' |
|
draw.text((0, image.height), text, fill=color) |
|
|
|
|
|
|
|
|
|
return image |
|
|
|
|
|
image_input = gr.inputs.Image(type='filepath', label="Input Image") |
|
image_caption_checkbox = gr.inputs.Checkbox(label="Image Caption", default=True) |
|
dense_caption_checkbox = gr.inputs.Checkbox(label="Dense Caption", default=True) |
|
semantic_segment_checkbox = gr.inputs.Checkbox(label="Semantic Segment", default=False) |
|
image_caption_device = gr.inputs.Radio(choices=['cuda', 'cpu'], default='cpu', label='Image Caption Device') |
|
dense_caption_device = gr.inputs.Radio(choices=['cuda', 'cpu'], default='cuda', label='Dense Caption Device') |
|
semantic_segment_device = gr.inputs.Radio(choices=['cuda', 'cpu'], default='cuda', label='Semantic Segment Device') |
|
controlnet_device = gr.inputs.Radio(choices=['cuda', 'cpu'], default='cpu', label='ControlNet Device') |
|
|
|
|
|
iface = gr.Interface(fn=create_html_page, inputs=[image_input], outputs=["image"]) |
|
|
|
iface.launch() |