devXpert commited on
Commit
e181f7c
·
verified ·
1 Parent(s): 3df63a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -17
app.py CHANGED
@@ -1,22 +1,18 @@
1
- import gradio as gr
2
  from transformers import pipeline
 
3
 
4
- # Load the text-to-text generation model
5
- generator = pipeline("text2text-generation", model="google/flan-t5-small")
6
 
7
- # Define the function to generate website code
8
- def generate_website(prompt):
9
- # Instruction prompt to ensure web-style code output
10
- full_prompt = f"Generate a modern HTML, CSS, and JavaScript website. {prompt}"
11
-
12
- result = generator(full_prompt, max_length=1024, do_sample=True)[0]['generated_text']
13
  return result
14
 
15
- # Build a simple Gradio UI
16
- gr.Interface(
17
- fn=generate_website,
18
- inputs=gr.Textbox(label="Describe the website you want", placeholder="e.g. A modern cafe website using beige and brown colors..."),
19
- outputs=gr.Textbox(label="Generated Website Code"),
20
- title="AI Website Code Generator",
21
- description="Enter a prompt to generate a full website (HTML/CSS/JS)."
22
- ).launch()
 
1
+ # app.py
2
  from transformers import pipeline
3
+ import gradio as gr
4
 
5
+ # Use a better model trained for HTML generation
6
+ generator = pipeline("text2text-generation", model="mrm8488/t5-base-finetuned-web-code")
7
 
8
+ def generate_site(prompt):
9
+ result = generator(prompt, max_length=2048, do_sample=True)[0]["generated_text"]
 
 
 
 
10
  return result
11
 
12
+ iface = gr.Interface(fn=generate_site,
13
+ inputs=gr.Textbox(lines=10, placeholder="Enter your website prompt..."),
14
+ outputs="text",
15
+ title="AI Website Generator",
16
+ description="Enter a prompt to generate a modern HTML/CSS/JS website")
17
+
18
+ iface.launch()