Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -308,86 +308,113 @@ def format_output(plan_text):
|
|
308 |
|
309 |
# demo.launch()
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
def create_gradio_app():
|
312 |
-
|
313 |
-
background_image = gr.Image("your_image_path.jpg", visible=False, elem_id="bg-image")
|
314 |
-
|
315 |
-
with gr.Blocks(css="""
|
316 |
-
:root {
|
317 |
-
--bg-opacity: 0.9;
|
318 |
-
}
|
319 |
-
#bg-image {
|
320 |
-
display: none; /* Hide the actual image element */
|
321 |
-
}
|
322 |
-
.gradio-container {
|
323 |
-
background: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)),
|
324 |
-
url('file=fantasy-landscape-floating-islands-illustration.jpg') !important;
|
325 |
-
background-size: cover !important;
|
326 |
-
background-position: center !important;
|
327 |
-
background-attachment: fixed !important;
|
328 |
-
min-height: 100vh;
|
329 |
-
padding: 30px;
|
330 |
-
font-family: 'Segoe UI', sans-serif;
|
331 |
-
}
|
332 |
-
.main-title {
|
333 |
-
text-align: center;
|
334 |
-
font-size: 72px !important;
|
335 |
-
font-weight: 800;
|
336 |
-
color: #ffffff;
|
337 |
-
margin-bottom: 15px;
|
338 |
-
text-shadow: 3px 3px 12px #000000;
|
339 |
-
padding: 30px;
|
340 |
-
background: rgba(20, 20, 40, 0.7);
|
341 |
-
border-radius: 20px;
|
342 |
-
text-transform: uppercase;
|
343 |
-
letter-spacing: 3px;
|
344 |
-
border: 2px solid rgba(255,255,255,0.2);
|
345 |
-
}
|
346 |
-
.sub-title {
|
347 |
-
text-align: center;
|
348 |
-
font-size: 22px;
|
349 |
-
color: #ffffff;
|
350 |
-
margin-bottom: 40px;
|
351 |
-
text-shadow: 2px 2px 6px #000000;
|
352 |
-
background: rgba(0, 0, 0, 0.6);
|
353 |
-
padding: 15px;
|
354 |
-
border-radius: 10px;
|
355 |
-
max-width: 80%;
|
356 |
-
margin-left: auto;
|
357 |
-
margin-right: auto;
|
358 |
-
}
|
359 |
-
.gradio-button {
|
360 |
-
background-color: #4CAF50 !important;
|
361 |
-
color: white !important;
|
362 |
-
font-size: 18px !important;
|
363 |
-
padding: 16px 24px !important;
|
364 |
-
border-radius: 8px !important;
|
365 |
-
margin-top: 20px !important;
|
366 |
-
border: none !important;
|
367 |
-
transition: all 0.3s ease !important;
|
368 |
-
}
|
369 |
-
.gradio-button:hover {
|
370 |
-
background-color: #3e8e41 !important;
|
371 |
-
transform: scale(1.05) !important;
|
372 |
-
box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
|
373 |
-
}
|
374 |
-
#output-box {
|
375 |
-
height: 600px;
|
376 |
-
overflow-y: scroll;
|
377 |
-
padding: 25px;
|
378 |
-
background-color: rgba(255, 255, 255, 0.92);
|
379 |
-
border: 1px solid #cccccc;
|
380 |
-
border-radius: 15px;
|
381 |
-
box-shadow: 0 6px 20px rgba(0,0,0,0.15);
|
382 |
-
}
|
383 |
-
.gradio-row {
|
384 |
-
margin-bottom: 30px;
|
385 |
-
}
|
386 |
-
.gradio-column {
|
387 |
-
padding: 15px;
|
388 |
-
}
|
389 |
-
""") as demo:
|
390 |
-
|
391 |
gr.Markdown("""<div class='main-title'>FANTASY NOVEL OUTLINE GENERATOR</div>""")
|
392 |
gr.Markdown("""<div class='sub-title'>Transform your creative vision into a fully-developed fantasy world</div>""")
|
393 |
|
@@ -410,6 +437,8 @@ def create_gradio_app():
|
|
410 |
outputs=output_html
|
411 |
)
|
412 |
|
413 |
-
demo
|
414 |
|
415 |
-
|
|
|
|
|
|
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 |
|
|
|
437 |
outputs=output_html
|
438 |
)
|
439 |
|
440 |
+
return demo
|
441 |
|
442 |
+
if __name__ == "__main__":
|
443 |
+
app = create_gradio_app()
|
444 |
+
app.launch()
|