dineth554 commited on
Commit
4ef9d83
·
verified ·
1 Parent(s): b22fdb6

Upload frontend/app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. frontend/app.py +5 -33
frontend/app.py CHANGED
@@ -110,23 +110,6 @@ margin-top: 30px !important;
110
  }
111
  """
112
 
113
- LEGION_JS = """
114
- function updateStatus() {
115
- fetch('http://localhost:8081/api/status')
116
- .then(r => r.json())
117
- .then(d => {
118
- const el = document.getElementById('api-status');
119
- if (el) el.innerText = d.status === 'ok' ? 'API: ONLINE (' + d.device + ')' : 'API: OFFLINE';
120
- })
121
- .catch(() => {
122
- const el = document.getElementById('api-status');
123
- if (el) el.innerText = 'API: OFFLINE';
124
- });
125
- }
126
- setInterval(updateStatus, 5000);
127
- updateStatus();
128
- """
129
-
130
  # ============================================================
131
  # API Helper Functions
132
  # ============================================================
@@ -181,8 +164,7 @@ def generate_text_video(
181
  )
182
  if resp.status_code != 200:
183
  return f"Error: {resp.text}"
184
-
185
- # Save the returned video file
186
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
187
  output_path = f"/tmp/legion_t2v_{timestamp}.mp4"
188
  with open(output_path, "wb") as f:
@@ -239,14 +221,11 @@ def generate_image_video(
239
 
240
  def preview_watermark(text: str, position: str, font_size: int, opacity: float) -> Optional[str]:
241
  try:
242
- # Create a test frame
243
  frame = Image.new("RGB", (480, 480), (20, 20, 35))
244
  draw = ImageDraw.Draw(frame)
245
- # Add some background pattern
246
  for i in range(0, 480, 20):
247
  draw.line([(i, 0), (i, 480)], fill=(30, 30, 50), width=1)
248
  draw.line([(0, i), (480, i)], fill=(30, 30, 50), width=1)
249
- # Draw watermark
250
  try:
251
  font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", font_size)
252
  except:
@@ -264,14 +243,11 @@ def preview_watermark(text: str, position: str, font_size: int, opacity: float)
264
  "bottom-right": (w - text_w - margin, h - text_h - margin),
265
  }
266
  x, y = pos_map.get(position, pos_map["bottom-right"])
267
- # Background box
268
  draw.rectangle(
269
  [x - 10, y - 10, x + text_w + 10, y + text_h + 10],
270
  fill=(0, 0, 0, int(40 * opacity))
271
  )
272
- # Text
273
  draw.text((x, y), text, font=font, fill=(255, 255, 255, int(255 * opacity)))
274
- # Save preview
275
  preview_path = "/tmp/qwatermark_preview.png"
276
  frame.save(preview_path)
277
  return preview_path
@@ -299,11 +275,11 @@ with gr.Blocks(
299
  ⚔️ LEGION VIDEO GENERATION
300
  </h1>
301
  <p style="color: #8888aa; font-size: 1.1em; margin-top: 5px;">
302
- The Ultimate AI Video Engine — HunyuanVideo 1.5
303
  </p>
304
  <div style="display: flex; justify-content: center; gap: 20px; margin-top: 10px;">
305
  <span class="status-badge">🔥 T2V + I2V</span>
306
- <span class="status-badge" id="api-status">Loading...</span>
307
  </div>
308
  """)
309
 
@@ -464,11 +440,7 @@ with gr.Blocks(
464
  gr.HTML("""
465
  <div class="footer">
466
  <p>
467
- <strong>⚔️ LEGION VIDEO GENERATION</strong> — Powered by
468
- <a href="https://github.com/Tencent-Hunyuan/HunyuanVideo-1.5" target="_blank">
469
- HunyuanVideo 1.5
470
- </a>
471
- (8.3B params) | Apache 2.0 License
472
  </p>
473
  <p style="font-size: 0.8em; margin-top: 5px;">
474
  Text-to-Video | Image-to-Video | QWatermark System
@@ -489,4 +461,4 @@ if __name__ == "__main__":
489
  share=False,
490
  show_error=True,
491
  quiet=False,
492
- )
 
110
  }
111
  """
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  # ============================================================
114
  # API Helper Functions
115
  # ============================================================
 
164
  )
165
  if resp.status_code != 200:
166
  return f"Error: {resp.text}"
167
+
 
168
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
169
  output_path = f"/tmp/legion_t2v_{timestamp}.mp4"
170
  with open(output_path, "wb") as f:
 
221
 
222
  def preview_watermark(text: str, position: str, font_size: int, opacity: float) -> Optional[str]:
223
  try:
 
224
  frame = Image.new("RGB", (480, 480), (20, 20, 35))
225
  draw = ImageDraw.Draw(frame)
 
226
  for i in range(0, 480, 20):
227
  draw.line([(i, 0), (i, 480)], fill=(30, 30, 50), width=1)
228
  draw.line([(0, i), (480, i)], fill=(30, 30, 50), width=1)
 
229
  try:
230
  font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", font_size)
231
  except:
 
243
  "bottom-right": (w - text_w - margin, h - text_h - margin),
244
  }
245
  x, y = pos_map.get(position, pos_map["bottom-right"])
 
246
  draw.rectangle(
247
  [x - 10, y - 10, x + text_w + 10, y + text_h + 10],
248
  fill=(0, 0, 0, int(40 * opacity))
249
  )
 
250
  draw.text((x, y), text, font=font, fill=(255, 255, 255, int(255 * opacity)))
 
251
  preview_path = "/tmp/qwatermark_preview.png"
252
  frame.save(preview_path)
253
  return preview_path
 
275
  ⚔️ LEGION VIDEO GENERATION
276
  </h1>
277
  <p style="color: #8888aa; font-size: 1.1em; margin-top: 5px;">
278
+ The Ultimate AI Video Engine — Text-to-Video & Image-to-Video
279
  </p>
280
  <div style="display: flex; justify-content: center; gap: 20px; margin-top: 10px;">
281
  <span class="status-badge">🔥 T2V + I2V</span>
282
+ </div>
283
  </div>
284
  """)
285
 
 
440
  gr.HTML("""
441
  <div class="footer">
442
  <p>
443
+ <strong>⚔️ LEGION VIDEO GENERATION</strong> — v1.0 | Apache 2.0 License
 
 
 
 
444
  </p>
445
  <p style="font-size: 0.8em; margin-top: 5px;">
446
  Text-to-Video | Image-to-Video | QWatermark System
 
461
  share=False,
462
  show_error=True,
463
  quiet=False,
464
+ )