File size: 923 Bytes
2f06631
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import base64
import io
from PIL import Image

def text_to_image(prompt):
    # This is a placeholder function
    # In a real scenario, this would use your actual model
    svg_content = f'''<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512">
        <rect width="512" height="512" fill="#f0f0f0"/>
        <text x="50%" y="50%" font-size="24" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">
            {prompt}
        </text>
    </svg>'''
    
    # Convert SVG to PNG
    img = Image.new('RGB', (512, 512), color='white')
    
    return img

# Create Gradio interface
demo = gr.Interface(
    fn=text_to_image,
    inputs=gr.Textbox(label="Prompt"),
    outputs=gr.Image(type="pil", label="Generated Image"),
    title="Vector Graphics Generator",
    description="Generate vector graphics from text prompts"
)

if __name__ == "__main__":
    demo.launch()