Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -33,89 +33,90 @@ def generate_text(prompt, max_length, temperature):
|
|
33 |
|
34 |
return tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
|
35 |
|
|
|
36 |
css = """
|
37 |
body {
|
38 |
-
background:
|
39 |
-
|
|
|
40 |
}
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
padding: 20px;
|
45 |
-
|
|
|
|
|
|
|
46 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
47 |
-
position: relative;
|
48 |
-
max-width: 800px;
|
49 |
-
margin: 20px auto;
|
50 |
}
|
51 |
-
|
52 |
-
color: #
|
53 |
-
|
54 |
-
|
|
|
|
|
55 |
}
|
56 |
-
.
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
margin-top: 20px;
|
61 |
}
|
62 |
-
.
|
63 |
-
|
64 |
}
|
65 |
-
.
|
66 |
-
width: 200px;
|
67 |
border-radius: 10px;
|
68 |
-
|
69 |
}
|
70 |
-
.
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
background-color: #4A90E2;
|
76 |
-
color: white;
|
77 |
-
padding: 5px 10px;
|
78 |
-
border-radius: 5px;
|
79 |
-
opacity: 0;
|
80 |
-
transition: opacity 0.3s;
|
81 |
-
white-space: nowrap;
|
82 |
}
|
83 |
-
.
|
84 |
-
|
|
|
85 |
}
|
86 |
-
.
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
-
.
|
92 |
-
background-color: #
|
93 |
-
border-radius: 10px;
|
94 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
95 |
-
padding: 20px;
|
96 |
-
margin-top: 20px;
|
97 |
}
|
98 |
"""
|
99 |
|
|
|
100 |
with gr.Blocks(css=css) as iface:
|
101 |
-
gr.HTML(
|
102 |
-
|
|
|
103 |
<h1>Llama-3.1-Storm-8B Text Generation</h1>
|
104 |
<p>Generate text using the powerful Llama-3.1-Storm-8B model. Enter a prompt and let the AI create!</p>
|
105 |
-
<
|
106 |
-
<img src="https://cdn-uploads.huggingface.co/production/uploads/64c75c1237333ccfef30a602/tmOlbERGKP7JSODa6T06J.jpeg" alt="Llama">
|
107 |
-
<div class="llama-description">Llama-3.1-Storm-8B Model</div>
|
108 |
-
</div>
|
109 |
</div>
|
110 |
-
|
|
|
111 |
|
112 |
-
with gr.
|
113 |
-
prompt = gr.Textbox(
|
114 |
max_length = gr.Slider(minimum=1, maximum=500, value=128, step=1, label="Max Length")
|
115 |
temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature")
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
120 |
|
|
|
121 |
iface.launch()
|
|
|
33 |
|
34 |
return tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
|
35 |
|
36 |
+
# Custom CSS
|
37 |
css = """
|
38 |
body {
|
39 |
+
background-color: #1a1a2e;
|
40 |
+
color: #e0e0e0;
|
41 |
+
font-family: 'Arial', sans-serif;
|
42 |
}
|
43 |
+
.container {
|
44 |
+
max-width: 900px;
|
45 |
+
margin: auto;
|
46 |
padding: 20px;
|
47 |
+
}
|
48 |
+
.gradio-container {
|
49 |
+
background-color: #16213e;
|
50 |
+
border-radius: 15px;
|
51 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
|
52 |
}
|
53 |
+
.header {
|
54 |
+
background-color: #0f3460;
|
55 |
+
padding: 20px;
|
56 |
+
border-radius: 15px 15px 0 0;
|
57 |
+
text-align: center;
|
58 |
+
margin-bottom: 20px;
|
59 |
}
|
60 |
+
.header h1 {
|
61 |
+
color: #e94560;
|
62 |
+
font-size: 2.5em;
|
63 |
+
margin-bottom: 10px;
|
|
|
64 |
}
|
65 |
+
.header p {
|
66 |
+
color: #a0a0a0;
|
67 |
}
|
68 |
+
.header img {
|
69 |
+
max-width: 200px;
|
70 |
border-radius: 10px;
|
71 |
+
margin-top: 15px;
|
72 |
}
|
73 |
+
.input-group, .output-group {
|
74 |
+
background-color: #1a1a2e;
|
75 |
+
padding: 20px;
|
76 |
+
border-radius: 10px;
|
77 |
+
margin-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
+
.input-group label, .output-group label {
|
80 |
+
color: #e94560;
|
81 |
+
font-weight: bold;
|
82 |
}
|
83 |
+
.generate-btn {
|
84 |
+
background-color: #e94560 !important;
|
85 |
+
color: white !important;
|
86 |
+
border: none !important;
|
87 |
+
border-radius: 5px !important;
|
88 |
+
padding: 10px 20px !important;
|
89 |
+
font-size: 16px !important;
|
90 |
+
cursor: pointer !important;
|
91 |
+
transition: background-color 0.3s ease !important;
|
92 |
}
|
93 |
+
.generate-btn:hover {
|
94 |
+
background-color: #c81e45 !important;
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
"""
|
97 |
|
98 |
+
# Gradio interface
|
99 |
with gr.Blocks(css=css) as iface:
|
100 |
+
gr.HTML(
|
101 |
+
"""
|
102 |
+
<div class="header">
|
103 |
<h1>Llama-3.1-Storm-8B Text Generation</h1>
|
104 |
<p>Generate text using the powerful Llama-3.1-Storm-8B model. Enter a prompt and let the AI create!</p>
|
105 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/64c75c1237333ccfef30a602/tmOlbERGKP7JSODa6T06J.jpeg" alt="Llama">
|
|
|
|
|
|
|
106 |
</div>
|
107 |
+
"""
|
108 |
+
)
|
109 |
|
110 |
+
with gr.Group(elem_classes="input-group"):
|
111 |
+
prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...", lines=5)
|
112 |
max_length = gr.Slider(minimum=1, maximum=500, value=128, step=1, label="Max Length")
|
113 |
temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature")
|
114 |
+
generate_btn = gr.Button("Generate", elem_classes="generate-btn")
|
115 |
+
|
116 |
+
with gr.Group(elem_classes="output-group"):
|
117 |
+
output = gr.Textbox(label="Generated Text", lines=10)
|
118 |
+
|
119 |
+
generate_btn.click(generate_text, inputs=[prompt, max_length, temperature], outputs=output)
|
120 |
|
121 |
+
# Launch the app
|
122 |
iface.launch()
|