gdo commited on
Commit
a978c34
·
verified ·
1 Parent(s): 56ca324

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -78
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
- # Initialize the text-to-image pipeline
7
- pipe = pipeline("text-to-image", model="stabilityai/stable-diffusion-v1-5")
8
-
9
- # Define the function to generate the landing page wireframe
10
- def generate_landing_page(prompt):
11
- """Generates a landing page wireframe based on the user prompt."""
12
-
13
- # Generate images (replace with actual wireframe generation if possible)
14
- image_prompts = [
15
- f"A wireframe illustration of a {prompt} landing page hero section.",
16
- f"A wireframe illustration of a {prompt} landing page feature section.",
17
- f"A wireframe illustration of a {prompt} landing page testimonial section.",
18
- f"A wireframe illustration of a {prompt} landing page pricing section.",
19
- f"A wireframe illustration of a {prompt} landing page call to action section.",
20
- f"A wireframe illustration of a {prompt} landing page gallery section.",
21
- f"A wireframe illustration of a {prompt} landing page team section.",
22
- f"A wireframe illustration of a {prompt} landing page FAQ section.",
23
- f"A wireframe illustration of a {prompt} landing page contact section.",
24
- f"A wireframe illustration of a {prompt} landing page footer section.",
25
- ]
26
- images = pipe(image_prompts)["images"]
27
-
28
- # Generate content
29
- header = f"Your {prompt.capitalize()} Solution"
30
- body_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " * 10
31
-
32
- testimonials = [
33
- "\"This is amazing!\" - John Doe",
34
- "\"I love it!\" - Jane Smith",
35
- "\"Best product ever!\" - David Lee",
36
- "\"Highly recommended!\" - Sarah Jones",
37
- "\"Changed my life!\" - Michael Brown",
38
- ]
39
-
40
- image_descriptions = [
41
- "Hero section wireframe with a large title and call to action button.",
42
- "Features section wireframe with icons and descriptions.",
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="Enter a prompt to generate a landing page wireframe and content.",
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
- # Launch the Gradio app
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()