Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Lade dein Modell
|
| 5 |
+
generator = pipeline(
|
| 6 |
+
"text-generation",
|
| 7 |
+
model="[dein-username]/HTML5-Willy-small1"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
def generate_html(prompt):
|
| 11 |
+
"""Generiere HTML5 Code"""
|
| 12 |
+
result = generator(
|
| 13 |
+
prompt,
|
| 14 |
+
max_length=300,
|
| 15 |
+
temperature=0.7,
|
| 16 |
+
top_p=0.9,
|
| 17 |
+
do_sample=True
|
| 18 |
+
)
|
| 19 |
+
return result[0]['generated_text']
|
| 20 |
+
|
| 21 |
+
# Erstelle Interface
|
| 22 |
+
demo = gr.Interface(
|
| 23 |
+
fn=generate_html,
|
| 24 |
+
inputs=gr.Textbox(
|
| 25 |
+
label="HTML5 Prompt",
|
| 26 |
+
placeholder="z.B. <!DOCTYPE html>",
|
| 27 |
+
lines=3
|
| 28 |
+
),
|
| 29 |
+
outputs=gr.Textbox(
|
| 30 |
+
label="Generated Code",
|
| 31 |
+
lines=10
|
| 32 |
+
),
|
| 33 |
+
title="🎮 HTML5-Willy-small1",
|
| 34 |
+
description="HTML5 Code-Generator powered by AI",
|
| 35 |
+
examples=[
|
| 36 |
+
["<!DOCTYPE html>"],
|
| 37 |
+
["<canvas id='game'"],
|
| 38 |
+
["<form>"],
|
| 39 |
+
["body { background:"],
|
| 40 |
+
]
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
if __name__ == "__main__":
|
| 44 |
+
demo.launch()
|