sagar007 commited on
Commit
d692c8b
·
verified ·
1 Parent(s): b3f66be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -60
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: linear-gradient(135deg, #f5f7fa, #c3cfe2);
39
- font-family: Arial, sans-serif;
 
40
  }
41
- #custom-header {
42
- text-align: center;
43
- background: rgba(255, 255, 255, 0.8);
44
  padding: 20px;
45
- border-radius: 10px;
 
 
 
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
- #custom-header h1 {
52
- color: #4A90E2;
53
- font-size: 2em;
54
- margin-bottom: 10px;
 
 
55
  }
56
- .llama-image {
57
- position: relative;
58
- transition: transform 0.3s;
59
- display: inline-block;
60
- margin-top: 20px;
61
  }
62
- .llama-image:hover {
63
- transform: scale(1.05);
64
  }
65
- .llama-image img {
66
- width: 200px;
67
  border-radius: 10px;
68
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
69
  }
70
- .llama-description {
71
- position: absolute;
72
- bottom: -30px;
73
- left: 50%;
74
- transform: translateX(-50%);
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
- .llama-image:hover .llama-description {
84
- opacity: 1;
 
85
  }
86
- .gradio-container {
87
- max-width: 900px !important;
88
- margin: auto;
89
- padding-top: 1.5rem;
 
 
 
 
 
90
  }
91
- .container {
92
- background-color: #ffffff;
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
- <div id="custom-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
- <div class="llama-image">
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.Column(elem_classes="container"):
113
- prompt = gr.Textbox(lines=5, label="Prompt")
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
- submit_btn = gr.Button("Generate", variant="primary")
117
- output = gr.Textbox(lines=10, label="Generated Text")
118
-
119
- submit_btn.click(generate_text, inputs=[prompt, max_length, temperature], outputs=output)
 
 
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()