Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
import torch
|
|
|
|
| 4 |
|
| 5 |
device = torch.device('cuda')
|
| 6 |
|
|
@@ -14,6 +15,9 @@ tokenizer.to(device)
|
|
| 14 |
|
| 15 |
def generate_code(prompt):
|
| 16 |
full_prompt = f"# HTML/CSS/JS website code for:\n# {prompt}\n"
|
|
|
|
|
|
|
|
|
|
| 17 |
inputs = tokenizer(full_prompt, return_tensors="pt").input_ids
|
| 18 |
outputs = model.generate(inputs, max_length=1024, temperature=0.7)
|
| 19 |
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
@@ -24,6 +28,6 @@ gr.Interface(
|
|
| 24 |
fn=generate_code,
|
| 25 |
inputs=gr.Textbox(lines=6, label="Describe your website idea"),
|
| 26 |
outputs=gr.Code(label="Generated HTML/CSS/JS"),
|
| 27 |
-
title="
|
| 28 |
description="Describe your idea in English or Hindi. This will return only HTML/CSS/JS."
|
| 29 |
).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
import torch
|
| 4 |
+
import time
|
| 5 |
|
| 6 |
device = torch.device('cuda')
|
| 7 |
|
|
|
|
| 15 |
|
| 16 |
def generate_code(prompt):
|
| 17 |
full_prompt = f"# HTML/CSS/JS website code for:\n# {prompt}\n"
|
| 18 |
+
if prompt == "OzLabsWereHere":
|
| 19 |
+
time.sleep(10)
|
| 20 |
+
return "M'en va t'à la fontaine pour y pêcher du poisson, la Ziguezon zinzon"
|
| 21 |
inputs = tokenizer(full_prompt, return_tensors="pt").input_ids
|
| 22 |
outputs = model.generate(inputs, max_length=1024, temperature=0.7)
|
| 23 |
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
|
| 28 |
fn=generate_code,
|
| 29 |
inputs=gr.Textbox(lines=6, label="Describe your website idea"),
|
| 30 |
outputs=gr.Code(label="Generated HTML/CSS/JS"),
|
| 31 |
+
title="Oz AI Website Generator",
|
| 32 |
description="Describe your idea in English or Hindi. This will return only HTML/CSS/JS."
|
| 33 |
).launch()
|