| import openai |
| import gradio as gr |
| from PIL import Image |
| import requests |
| from io import BytesIO |
|
|
| |
| openai.api_key = "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" |
|
|
| def generate_fashion_design(description): |
| """Generate a fashion design using OpenAI's DALL·E model.""" |
| response = openai.Image.create( |
| prompt=f"Fashion design based on: {description}", |
| n=1, |
| size="512x512" |
| ) |
|
|
| |
| image_url = response["data"][0]["url"] |
| image = Image.open(BytesIO(requests.get(image_url).content)) |
| return image |
|
|
| |
| iface = gr.Interface( |
| fn=generate_fashion_design, |
| inputs=gr.Textbox(placeholder="Enter a description or mood board details..."), |
| outputs=gr.Image(type="pil"), |
| title="AI Fashion Design Generator", |
| description="Generate AI-based fashion designs from text descriptions or mood boards." |
| ) |
|
|
| if __name__ == "__main__": |
| iface.launch() |
|
|