|
|
import gradio as gr |
|
|
import requests |
|
|
|
|
|
def generate_icon(description): |
|
|
""" |
|
|
Generates an icon based on text input using the Iconify API. |
|
|
""" |
|
|
|
|
|
icon_name = description.replace(' ', '-').lower() |
|
|
iconify_url = f"https://api.iconify.design/mdi:{icon_name}.svg" |
|
|
|
|
|
|
|
|
response = requests.get(iconify_url) |
|
|
if response.status_code == 200: |
|
|
|
|
|
return f'<img src="{iconify_url}" width="100" height="100">' |
|
|
else: |
|
|
return "β Icon not found. Try a different description." |
|
|
|
|
|
|
|
|
demo = gr.Interface( |
|
|
fn=generate_icon, |
|
|
inputs=gr.Textbox(label="Enter Icon Description"), |
|
|
outputs=gr.HTML(label="Generated Icon"), |
|
|
title="AI-Powered Icon Generator", |
|
|
description="Generate icons based on text descriptions using the Iconify API." |
|
|
) |
|
|
|
|
|
demo.launch() |
|
|
|