Update app.py
Browse files
app.py
CHANGED
|
@@ -1,85 +1,47 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from diffusers import StableDiffusionPipeline
|
| 3 |
-
import torch
|
| 4 |
import random
|
| 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 |
-
"Testimonials section wireframe with user avatars and quotes.",
|
| 44 |
-
"Pricing section wireframe with different plan options.",
|
| 45 |
-
"Call to action section wireframe with a prominent button.",
|
| 46 |
-
"Gallery section wireframe with image placeholders.",
|
| 47 |
-
"Team section wireframe with team member profiles.",
|
| 48 |
-
"FAQ section wireframe with collapsible questions and answers.",
|
| 49 |
-
"Contact section wireframe with a form and contact information.",
|
| 50 |
-
"Footer section wireframe with links and copyright information.",
|
| 51 |
-
]
|
| 52 |
-
|
| 53 |
-
# Generate colors
|
| 54 |
-
primary_color = f"#{random.randint(0, 0xFFFFFF):06x}"
|
| 55 |
-
secondary_color = f"#{random.randint(0, 0xFFFFFF):06x}"
|
| 56 |
-
text_color = "#333333" # Dark gray for text
|
| 57 |
-
background_color = "#f4f4f4" # light gray for background
|
| 58 |
-
return header, body_text, images, testimonials, image_descriptions,primary_color,secondary_color,text_color,background_color
|
| 59 |
-
|
| 60 |
-
# Create the Gradio interface
|
| 61 |
-
iface = gr.Interface(
|
| 62 |
-
fn=generate_landing_page,
|
| 63 |
-
inputs=gr.Textbox(lines=2, placeholder="Enter your landing page prompt here..."),
|
| 64 |
-
outputs=[
|
| 65 |
-
gr.Textbox(label="Header", elem_classes=["google-font-header"]),
|
| 66 |
-
gr.Textbox(label="Body Text", lines=10, elem_classes=["google-font-body"]),
|
| 67 |
-
gr.Gallery(label="Wireframe Images", show_label=True, columns=2),
|
| 68 |
-
gr.Textbox(label="Testimonials", lines=5),
|
| 69 |
-
gr.Textbox(label="Image Descriptions", lines=10),
|
| 70 |
-
gr.Textbox(label="Primary Color"),
|
| 71 |
-
gr.Textbox(label="Secondary Color"),
|
| 72 |
-
gr.Textbox(label="Text Color"),
|
| 73 |
-
gr.Textbox(label="Background Color")
|
| 74 |
],
|
|
|
|
| 75 |
title="Landing Page Wireframe Generator",
|
| 76 |
-
description="
|
| 77 |
-
css="""
|
| 78 |
-
@import url('https://fonts.googleapis.com/css2?family=Roboto+Slab&family=Roboto:wght@400;700&display=swap');
|
| 79 |
-
.google-font-header { font-family: 'Roboto Slab', serif; font-size: 2em; }
|
| 80 |
-
.google-font-body { font-family: 'Roboto', sans-serif; font-size: 1em; }
|
| 81 |
-
""",
|
| 82 |
)
|
| 83 |
|
| 84 |
-
|
| 85 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
import random
|
| 3 |
|
| 4 |
+
def generate_wireframe(prompt, header_font, body_font, primary_color, secondary_color):
|
| 5 |
+
wireframe = {
|
| 6 |
+
"title": prompt,
|
| 7 |
+
"fonts": {
|
| 8 |
+
"header": header_font,
|
| 9 |
+
"body": body_font
|
| 10 |
+
},
|
| 11 |
+
"colors": {
|
| 12 |
+
"primary": primary_color,
|
| 13 |
+
"secondary": secondary_color
|
| 14 |
+
},
|
| 15 |
+
"content": {
|
| 16 |
+
"header": f"{prompt} - A Landing Page",
|
| 17 |
+
"paragraphs": [f"This is paragraph {i+1} of content for {prompt}." for i in range(10)],
|
| 18 |
+
"testimonials": [
|
| 19 |
+
{"name": f"User {i+1}", "review": f"This is a testimonial {i+1} for {prompt}."}
|
| 20 |
+
for i in range(5)
|
| 21 |
+
],
|
| 22 |
+
"images": [
|
| 23 |
+
{"description": f"Description for image {i+1} related to {prompt}."}
|
| 24 |
+
for i in range(10)
|
| 25 |
+
]
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
return wireframe
|
| 29 |
+
|
| 30 |
+
header_font_choices = ["Roboto", "Lato", "Montserrat", "Poppins", "Open Sans"]
|
| 31 |
+
body_font_choices = ["Roboto", "Lato", "Montserrat", "Poppins", "Open Sans"]
|
| 32 |
+
|
| 33 |
+
demo = gr.Interface(
|
| 34 |
+
fn=generate_wireframe,
|
| 35 |
+
inputs=[
|
| 36 |
+
gr.Textbox(label="Landing Page Prompt"),
|
| 37 |
+
gr.Dropdown(header_font_choices, label="Header Font"),
|
| 38 |
+
gr.Dropdown(body_font_choices, label="Body Font"),
|
| 39 |
+
gr.ColorPicker(label="Primary Color"),
|
| 40 |
+
gr.ColorPicker(label="Secondary Color")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
],
|
| 42 |
+
outputs=gr.JSON(),
|
| 43 |
title="Landing Page Wireframe Generator",
|
| 44 |
+
description="Generate a structured wireframe for a landing page based on a user prompt."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
)
|
| 46 |
|
| 47 |
+
demo.launch()
|
|
|