Kal1510 commited on
Commit
be2269d
·
verified ·
1 Parent(s): b148874

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +192 -41
app.py CHANGED
@@ -308,6 +308,141 @@ def format_output(plan_text):
308
 
309
  # demo.launch()
310
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  import gradio as gr
312
  import base64
313
 
@@ -317,7 +452,7 @@ def get_base64_image(image_path):
317
  return base64.b64encode(img_file.read()).decode('utf-8')
318
 
319
  # Your image path - REPLACE THIS WITH YOUR ACTUAL IMAGE PATH
320
- IMAGE_PATH = "fantasy-landscape-floating-islands-illustration.jpg" # or "C:/path/to/your/background.jpg"
321
 
322
  # Get base64 encoded image
323
  try:
@@ -334,85 +469,101 @@ CSS = f"""
334
  background-attachment: fixed !important;
335
  min-height: 100vh;
336
  padding: 30px;
337
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
338
  }}
339
 
 
340
  .main-title {{
341
  text-align: center;
342
- font-size: 72px !important;
343
- font-weight: 800;
344
- color: #ffffff !important;
345
  margin-bottom: 15px;
346
- text-shadow: 3px 3px 12px #000000;
347
- padding: 30px;
348
- background: rgba(20, 20, 40, 0.7);
349
- border-radius: 20px;
 
 
 
 
 
350
  text-transform: uppercase;
351
- letter-spacing: 3px;
352
- border: 2px solid rgba(255,255,255,0.2);
 
353
  }}
354
 
 
355
  .sub-title {{
356
  text-align: center;
357
- font-size: 22px;
358
- color: #ffffff;
359
  margin-bottom: 40px;
360
- text-shadow: 2px 2px 6px #000000;
361
- background: rgba(0, 0, 0, 0.6);
362
- padding: 15px;
363
- border-radius: 10px;
 
 
364
  max-width: 80%;
365
  margin-left: auto;
366
  margin-right: auto;
 
 
 
367
  }}
368
 
369
  .gradio-button {{
370
- background-color: #4CAF50 !important;
371
- color: white !important;
372
- font-size: 18px !important;
373
- padding: 16px 24px !important;
374
- border-radius: 8px !important;
375
  margin-top: 20px !important;
376
- border: none !important;
 
377
  transition: all 0.3s ease !important;
378
  }}
379
 
380
  .gradio-button:hover {{
381
- background-color: #3e8e41 !important;
382
  transform: scale(1.05) !important;
383
- box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
384
  }}
385
 
386
  #output-box {{
387
  height: 600px;
388
  overflow-y: scroll;
389
- padding: 25px;
390
- background-color: rgba(255, 255, 255, 0.92) !important;
391
- border: 1px solid #cccccc !important;
392
  border-radius: 15px !important;
393
- box-shadow: 0 6px 20px rgba(0,0,0,0.15) !important;
 
394
  }}
395
 
396
  .textbox {{
397
- background: rgba(255,255,255,0.9) !important;
 
398
  }}
399
  """
400
 
401
  def generate_fantasy_outline(idea):
402
  # Replace this with your actual generation logic
403
- return f"<h2>Outline for:</h2><h3>{idea}</h3><p>1. Introduction to the magical world...</p>"
404
-
405
- def format_output(outline):
406
  return f"""
407
- <div style="
408
- background: rgba(255,255,255,0.9);
409
- padding: 20px;
410
- border-radius: 10px;
411
- ">
412
- {outline}
413
- </div>
414
  """
415
 
 
 
 
416
  def create_gradio_app():
417
  with gr.Blocks(css=CSS) as demo:
418
  gr.Markdown("""<div class='main-title'>FANTASY NOVEL OUTLINE GENERATOR</div>""")
@@ -432,7 +583,7 @@ def create_gradio_app():
432
  output_html = gr.HTML(label="Your Generated Outline", elem_id="output-box")
433
 
434
  generate_btn.click(
435
- fn=lambda idea: format_output(generate_fantasy_outline(idea)),
436
  inputs=[user_idea],
437
  outputs=output_html
438
  )
 
308
 
309
  # demo.launch()
310
 
311
+ # import gradio as gr
312
+ # import base64
313
+
314
+ # # Function to encode the image
315
+ # def get_base64_image(image_path):
316
+ # with open(image_path, "rb") as img_file:
317
+ # return base64.b64encode(img_file.read()).decode('utf-8')
318
+
319
+ # # Your image path - REPLACE THIS WITH YOUR ACTUAL IMAGE PATH
320
+ # IMAGE_PATH = "fantasy-landscape-floating-islands-illustration.jpg" # or "C:/path/to/your/background.jpg"
321
+
322
+ # # Get base64 encoded image
323
+ # try:
324
+ # encoded_image = get_base64_image(IMAGE_PATH)
325
+ # except FileNotFoundError:
326
+ # print(f"Error: Image not found at {IMAGE_PATH}")
327
+ # encoded_image = ""
328
+
329
+ # CSS = f"""
330
+ # .gradio-container {{
331
+ # background: url('data:image/jpeg;base64,{encoded_image}') !important;
332
+ # background-size: cover !important;
333
+ # background-position: center !important;
334
+ # background-attachment: fixed !important;
335
+ # min-height: 100vh;
336
+ # padding: 30px;
337
+ # font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
338
+ # }}
339
+
340
+ # .main-title {{
341
+ # text-align: center;
342
+ # font-size: 72px !important;
343
+ # font-weight: 800;
344
+ # color: #ffffff !important;
345
+ # margin-bottom: 15px;
346
+ # text-shadow: 3px 3px 12px #000000;
347
+ # padding: 30px;
348
+ # background: rgba(20, 20, 40, 0.7);
349
+ # border-radius: 20px;
350
+ # text-transform: uppercase;
351
+ # letter-spacing: 3px;
352
+ # border: 2px solid rgba(255,255,255,0.2);
353
+ # }}
354
+
355
+ # .sub-title {{
356
+ # text-align: center;
357
+ # font-size: 22px;
358
+ # color: #ffffff;
359
+ # margin-bottom: 40px;
360
+ # text-shadow: 2px 2px 6px #000000;
361
+ # background: rgba(0, 0, 0, 0.6);
362
+ # padding: 15px;
363
+ # border-radius: 10px;
364
+ # max-width: 80%;
365
+ # margin-left: auto;
366
+ # margin-right: auto;
367
+ # }}
368
+
369
+ # .gradio-button {{
370
+ # background-color: #4CAF50 !important;
371
+ # color: white !important;
372
+ # font-size: 18px !important;
373
+ # padding: 16px 24px !important;
374
+ # border-radius: 8px !important;
375
+ # margin-top: 20px !important;
376
+ # border: none !important;
377
+ # transition: all 0.3s ease !important;
378
+ # }}
379
+
380
+ # .gradio-button:hover {{
381
+ # background-color: #3e8e41 !important;
382
+ # transform: scale(1.05) !important;
383
+ # box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
384
+ # }}
385
+
386
+ # #output-box {{
387
+ # height: 600px;
388
+ # overflow-y: scroll;
389
+ # padding: 25px;
390
+ # background-color: rgba(255, 255, 255, 0.92) !important;
391
+ # border: 1px solid #cccccc !important;
392
+ # border-radius: 15px !important;
393
+ # box-shadow: 0 6px 20px rgba(0,0,0,0.15) !important;
394
+ # }}
395
+
396
+ # .textbox {{
397
+ # background: rgba(255,255,255,0.9) !important;
398
+ # }}
399
+ # """
400
+
401
+ # def generate_fantasy_outline(idea):
402
+ # # Replace this with your actual generation logic
403
+ # return f"<h2>Outline for:</h2><h3>{idea}</h3><p>1. Introduction to the magical world...</p>"
404
+
405
+ # def format_output(outline):
406
+ # return f"""
407
+ # <div style="
408
+ # background: rgba(255,255,255,0.9);
409
+ # padding: 20px;
410
+ # border-radius: 10px;
411
+ # ">
412
+ # {outline}
413
+ # </div>
414
+ # """
415
+
416
+ # def create_gradio_app():
417
+ # with gr.Blocks(css=CSS) as demo:
418
+ # gr.Markdown("""<div class='main-title'>FANTASY NOVEL OUTLINE GENERATOR</div>""")
419
+ # gr.Markdown("""<div class='sub-title'>Transform your creative vision into a fully-developed fantasy world</div>""")
420
+
421
+ # with gr.Row():
422
+ # with gr.Column(scale=1):
423
+ # user_idea = gr.Textbox(
424
+ # label="Your Fantasy Novel Concept",
425
+ # placeholder="A hidden prophecy... a forgotten magic... an unlikely hero...",
426
+ # lines=5,
427
+ # interactive=True
428
+ # )
429
+ # generate_btn = gr.Button("Craft My Outline", elem_classes="gradio-button")
430
+
431
+ # with gr.Column(scale=2):
432
+ # output_html = gr.HTML(label="Your Generated Outline", elem_id="output-box")
433
+
434
+ # generate_btn.click(
435
+ # fn=lambda idea: format_output(generate_fantasy_outline(idea)),
436
+ # inputs=[user_idea],
437
+ # outputs=output_html
438
+ # )
439
+
440
+ # return demo
441
+
442
+ # if __name__ == "__main__":
443
+ # app = create_gradio_app()
444
+ # app.launch()
445
+
446
  import gradio as gr
447
  import base64
448
 
 
452
  return base64.b64encode(img_file.read()).decode('utf-8')
453
 
454
  # Your image path - REPLACE THIS WITH YOUR ACTUAL IMAGE PATH
455
+ IMAGE_PATH = "fantasy-landscape-floating-islands-illustration.jpg"
456
 
457
  # Get base64 encoded image
458
  try:
 
469
  background-attachment: fixed !important;
470
  min-height: 100vh;
471
  padding: 30px;
472
+ font-family: 'Palatino Linotype', 'Book Antiqua', serif;
473
  }}
474
 
475
+ /* ENHANCED MAIN TITLE */
476
  .main-title {{
477
  text-align: center;
478
+ font-size: 84px !important; /* Increased from 72px */
479
+ font-weight: 900;
480
+ color: #f8f4e6 !important; /* Parchment color */
481
  margin-bottom: 15px;
482
+ text-shadow:
483
+ 3px 3px 0 #2a2a2a, /* Dark shadow for depth */
484
+ -1px -1px 0 #2a2a2a,
485
+ 1px -1px 0 #2a2a2a,
486
+ -1px 1px 0 #2a2a2a,
487
+ 1px 1px 0 #2a2a2a;
488
+ padding: 40px;
489
+ background: rgba(40, 30, 30, 0.65); /* Deep wine background */
490
+ border-radius: 25px;
491
  text-transform: uppercase;
492
+ letter-spacing: 4px; /* More spacing between letters */
493
+ border: 3px solid #d4af37; /* Gold border */
494
+ margin-bottom: 30px;
495
  }}
496
 
497
+ /* ENHANCED SUBTITLE */
498
  .sub-title {{
499
  text-align: center;
500
+ font-size: 28px !important; /* Increased from 22px */
501
+ color: #f0e6d2 !important; /* Light parchment */
502
  margin-bottom: 40px;
503
+ text-shadow:
504
+ 2px 2px 4px #000000,
505
+ -1px -1px 0 #2a2a2a;
506
+ background: rgba(60, 40, 40, 0.7); /* Darker background */
507
+ padding: 20px;
508
+ border-radius: 15px;
509
  max-width: 80%;
510
  margin-left: auto;
511
  margin-right: auto;
512
+ font-style: italic;
513
+ border-left: 4px solid #d4af37; /* Gold accent */
514
+ border-right: 4px solid #d4af37;
515
  }}
516
 
517
  .gradio-button {{
518
+ background: linear-gradient(to bottom, #d4af37, #b8860b) !important;
519
+ color: #2a2a2a !important;
520
+ font-size: 20px !important;
521
+ padding: 18px 28px !important;
522
+ border-radius: 10px !important;
523
  margin-top: 20px !important;
524
+ border: 2px solid #f8f4e6 !important;
525
+ font-weight: bold;
526
  transition: all 0.3s ease !important;
527
  }}
528
 
529
  .gradio-button:hover {{
530
+ background: linear-gradient(to bottom, #f8d030, #d4af37) !important;
531
  transform: scale(1.05) !important;
532
+ box-shadow: 0 6px 16px rgba(0,0,0,0.4) !important;
533
  }}
534
 
535
  #output-box {{
536
  height: 600px;
537
  overflow-y: scroll;
538
+ padding: 30px;
539
+ background-color: rgba(248, 244, 230, 0.95) !important; /* Parchment background */
540
+ border: 2px solid #d4af37 !important;
541
  border-radius: 15px !important;
542
+ box-shadow: 0 8px 25px rgba(0,0,0,0.2) !important;
543
+ color: #333333;
544
  }}
545
 
546
  .textbox {{
547
+ background: rgba(255,255,255,0.95) !important;
548
+ border: 1px solid #d4af37 !important;
549
  }}
550
  """
551
 
552
  def generate_fantasy_outline(idea):
553
  # Replace this with your actual generation logic
 
 
 
554
  return f"""
555
+ <h2 style='color: #5e2c04; border-bottom: 2px solid #d4af37; padding-bottom: 8px;'>Outline for:</h2>
556
+ <h3 style='color: #8b4513;'>{idea}</h3>
557
+ <ol style='color: #333333; font-size: 17px; line-height: 1.6;'>
558
+ <li><strong>Prologue:</strong> The ancient prophecy revealed...</li>
559
+ <li><strong>Chapter 1:</strong> The ordinary world disrupted...</li>
560
+ <li><strong>Chapter 2:</strong> First encounter with magic...</li>
561
+ </ol>
562
  """
563
 
564
+ def format_output(outline):
565
+ return outline # Now handled in generate_fantasy_outline
566
+
567
  def create_gradio_app():
568
  with gr.Blocks(css=CSS) as demo:
569
  gr.Markdown("""<div class='main-title'>FANTASY NOVEL OUTLINE GENERATOR</div>""")
 
583
  output_html = gr.HTML(label="Your Generated Outline", elem_id="output-box")
584
 
585
  generate_btn.click(
586
+ fn=lambda idea: generate_fantasy_outline(idea),
587
  inputs=[user_idea],
588
  outputs=output_html
589
  )